Thanks,
Anton
--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Code is available at https://github.com/knyar/nginx_exporter
This sounds more like a client library mixed with a custom collector than an exporter
-- "le" label should be the last one to ensure that all buckets for a given-- metric are exposed together when all metrics get sorted.This doesn't sound right, that constraint is too strict.
Thanks. It seems that I need to add some additional safety checks that would prevent:- using the same metric name with different sets of labels;- using the same histogram metric with different bucketers.
Thanks. It seems that I need to add some additional safety checks that would prevent:- using the same metric name with different sets of labels;- using the same histogram metric with different bucketers.It seems that the best way to implement this would be to require all metrics to be explicitly declared in advance.
I am planning to implement an API like this:init_by_lua:metrics = require("prometheus").init("prometheus_metrics")metrics:register_counter("nginx_http_request_size_bytes") -- counter with no labelsmetrics:register_counter("nginx_http_requests_total", {"host, "status"}) -- counter with labelsmetrics:register_histogram("nginx_http_request_duration_seconds", {"host"}) -- histogram with labelsmetrics:register_histogram("nginx_http_response_size_bytes", {"host"}, {10,100,1000,10000,100000,1000000}) -- histogram with custom bucketerlog_by_lua:metrics.c["nginx_http_request_size_bytes"]:inc(tonumber(ngx.var.request_length))
metrics.c["nginx_http_requests_total"]:inc(1, {"host1", ngx.var.status})metrics.h["nginx_http_request_duration_seconds"]:observe(ngx.now() - ngx.req.start_time(), {"host1"})metrics.h["nginx_http_response_size_bytes"]:observe(tonumber(ngx.var.bytes_sent), {"host2"})
Please let me know if you have any comments.- Anton
Usually you'd keep the metric object created in a variable and use that, rather than having to do a map lookup.