Jack
Jack

Reputation: 1372

prometheus: Get latency on specific endpoint

I have a quick question, I have prometheus nginx exporter installed on my server which gives me latency on each domain I have there, for example

my query

sum(rate(nginx_http_request_duration_seconds_sum{group="x-server",host="www.site.com"}[1m])) / sum(rate(nginx_http_request_duration_seconds_count{group="x-server",host="www.site.com"}[1m])) 

and I get value of

0.033166666666147655

this is all good, but this isn't telling me exactly what latency on different locations of the site, for example I wanna get latency of this

www.site.com/display.php

is there way to achieve this?

I'm using following exporter

https://github.com/knyar/nginx-lua-prometheus

Upvotes: 1

Views: 1079

Answers (1)

trallnag
trallnag

Reputation: 2386

You will have to instrument your API directly. Either use the appropriate Prometheus client library directly or take advantage of already existing libraries / exporters built on top of it that instrument your API automatically.

I assume it would technically be possible to do it with Nginx alone, but I think it is the wrong place for endpoint aggregations. How would such a tool deal with an endpoint like /api/orders/{order_id}?{parameters}? The cardinality would go through the roof or you would have to configure everything by hand.

Upvotes: 1

Related Questions