pkaramol
pkaramol

Reputation: 19422

Prometheus configuration and http_requests_total

Ι have installed prometheus with the default configuration.

I am at its web interface, on http://localhost/9090/metrics trying to fetch the time series corresponding to the total of http requests.

Filtering out by the name http_requests_total, retrieves several time series with different labels, e.g.

http_requests_total{code='200',handler='targets',instance=localhost:9090,job='prometheus',method='get'} 
http_requests_total{code='200',handler='static',instance=localhost:9090,job='prometheus',method='get'} 
http_requests_total{code='200',handler='graph',instance=localhost:9090,job='prometheus',method='get'} 
[...]

what are all these time series? how can I find the semantics behind each label?

Upvotes: 3

Views: 9611

Answers (1)

Alin Sînpălean
Alin Sînpălean

Reputation: 10124

One, if you visit http://localhost:9090/metrics in your browser, you should see something along the lines of:

# HELP prometheus_http_request_duration_seconds Histogram of latencies for HTTP requests.
# TYPE prometheus_http_request_duration_seconds histogram
prometheus_http_request_duration_seconds_bucket{handler="/",le="0.1"} 3
prometheus_http_request_duration_seconds_bucket{handler="/",le="0.2"} 3
prometheus_http_request_duration_seconds_bucket{handler="/",le="0.4"} 3
...

which should explain what the metric measures and hopefully what the labels are intended to represent. If you don't know what a counter/gauge/histogram is, then you should probably RTFM.

And if you want to go in deeper (and have access to the source code of the monitored service, as is the case with Prometheus source code), you can search said source code for the metric name. Note that the metric name in the code may be a substring of the final metric name, as a namespace may be prepended to it (the prometheus_ part in my example above) and for histograms and summaries _count or bucket or something else may be appended. So in the case of the metric above you should search the code for "http_request_duration_seconds" rather than "prometheus_http_request_duration_seconds_bucket".

Upvotes: 2

Related Questions