Skip to content

Commit 53693f1

Browse files
committed
metrics: create 3scale backend status
1 parent 6f25e5d commit 53693f1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local prometheus = require('apicast.prometheus')
2+
local metrics_updater = require('apicast.metrics.updater')
3+
4+
local format = string.format
5+
6+
local _M = {}
7+
8+
local backend_response_metric = prometheus(
9+
'counter',
10+
'backend_response',
11+
"Response status codes from 3scale's backend",
12+
{ 'status' }
13+
)
14+
15+
function _M.inc(status)
16+
if not status or status == 0 then
17+
ngx.log(ngx.WARN, 'Invalid status received')
18+
end
19+
20+
local label = format("%dxx", status/100)
21+
22+
metrics_updater.inc(backend_response_metric, label)
23+
end
24+
25+
return _M

0 commit comments

Comments
 (0)