Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P4978
nginx-prometheus.conf
Active
Public
Actions
Authored by
•
ema
on Feb 23 2017, 5:00 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F5794134: nginx-prometheus.conf
Feb 23 2017, 5:00 PM
2017-02-23 17:00:01 (UTC+0)
Subscribers
None
lua_shared_dict prometheus_metrics 10M;
init_by_lua '
prometheus = require("prometheus").init("prometheus_metrics")
metric_requests = prometheus:counter(
"nginx_http_requests_total", "Number of HTTP requests", {"host", "status"})
metric_latency = prometheus:histogram(
"nginx_http_request_duration_seconds", "HTTP request latency", {"host"})
';
log_by_lua '
local host = ngx.var.host:gsub("^www.", "")
metric_requests:inc(1, {host, ngx.var.status})
metric_latency:observe(ngx.now() - ngx.req.start_time(), {host})
';
server {
listen 9145;
allow 127.0.0.1;
deny all;
location /metrics {
content_by_lua 'prometheus:collect()';
}
}
Event Timeline
•
ema
created this paste.
Feb 23 2017, 5:00 PM
2017-02-23 17:00:01 (UTC+0)
Log In to Comment