Prometheus get list of all metrics and descriptions
Asked Answered
H

2

6

I need a table of all metrics and corresponding descriptions from a prometheus exporter (e.g. node exporter).

Some exporter have such a table in their docs e.g. cadvisor: https://github.com/google/cadvisor/blob/master/docs/storage/prometheus.md#prometheus-container-metrics but node exporter doesn't have such a detailed table with metric and description.

The list of all metrics are available here http://localhost:9090/api/v1/label/__name__/values but what is with the descriptions? Is there another way to achieve that?

Huntsman answered 17/1, 2021 at 19:55 Comment(0)
F
7

Go to Prometheus > Status > Targets and get the endpoint you want, for example:

Node       = http://HOSTNAME:9100/metrics
Bitbucket  = https://BITBUCKET-SERVER:443/plugins/servlet/prometheus/metrics
Prometheus = http://PROMETHEUS-SERVER:9090/metrics
...

Execute the following command to get all metrics, values and descriptions:

wget ENDPOINT

For example:

wget http://HOSTNAME:9100/metrics
Flask answered 17/1, 2021 at 21:58 Comment(1)
It would be good if this UI Prometheus > Status > Targets thing was in the getting started page for prometheus for the time-starved developer who ignored the UI drop-downs and focused only on the promql text entryComport
W
5

Prometheus provides /api/v1/targets/metadata endpoint, which returns the list of metric names with their descriptions for targets, which match the given match_target selector. See these docs for details.

Another option is to navigate to http://prometheus:9090/targets page, to locate the needed target and to click the endpoint link. It should open the page with metrics exported by the target. This page usually contains descriptions for every exported metric. The web browser can fail opening the page if the target url isn't reachable from the web browser. In this case it would be great querying the target on behalf of Prometheus. Unfortunately Prometheus doesn't provide such an ability. But vmagent - an alternative Prometheus-compatible scraper I work on - provides such an ability on the http://vmagent:8429/targets page. Just click the response link at the Endpoint column for the corresponding target.

Weightlessness answered 22/6, 2022 at 18:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.