36

I was curious concerning the workings of Prometheus. Using the Prometheus interface I am able to see a drop-down list which I assume contains all available metrics. However, I am not able to access the metrics endpoint which lists all of the scraped metrics. The http://targethost:9090/metrics endpoint only displays the metrics concerning the Prometheus server itself. Is it possible to access a similar endpoint which lists all available metrics. I could perform a query based on {__name__=~".+"} but I would prefer to avoid this option.

Tony.H
  • 631
  • 1
  • 6
  • 14

2 Answers2

51

The endpoint for that is http://localhost:9090/api/v1/label/__name__/values

API Reference

Vishrant
  • 15,456
  • 11
  • 71
  • 120
vinodk
  • 719
  • 6
  • 5
  • 10
    Show all available metrics, use `__name__` instead: http://localhost:9090/api/v1/label/__name__/values – Haoyuan Ge Jul 30 '20 at 03:01
  • 1
    The http://localhost:9090/api/v1/metadata api endpoint also shows HELP description. [API reference](https://prometheus.io/docs/prometheus/latest/querying/api/#querying-metric-metadata) – Sergey Ponomarev Nov 30 '21 at 10:03
1

Prometheus provides /federate API, which can be used for returning all the scraped metrics. For example, the following curl query returns all the metrics in Prometheus text exposition format (e.g. in the same format as /metrics output), which were scraped recently:

curl -G http://demo.robustperception.io:9090/federate -d 'match[]={__name__!=""}'

P.S. VictoriaMetrics supports additional start and end query args, which can be used for returning metrics scraped at a specific time range - see these docs.

valyala
  • 11,669
  • 1
  • 59
  • 62