The endpoint for that is http://localhost:9090/api/v1/label/__name__/values
API Reference
Answer from vinodkottem on Stack OverflowThe endpoint for that is http://localhost:9090/api/v1/label/__name__/values
API Reference
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.
Prometheus get list of all metrics and descriptions - Stack Overflow
Prometheus metrics and API Star
Pretty simple integration, but the Prometheus client for python really needs to be used in multi-process mode with most production scale web applications, since (in my experience) you aren't going to get decent performance without spreading you queries across multiple instances.
More on reddit.compython , how to import prometheus endpoint metrics for processing by another system
Using Prometheus to ingest from foreign APIs
You can fetch all metrics with following curl expression:
url=http://{urIPorhostname}:9090
curl -s $url/api/v1/label/__name__/values | jq -r ".data[]" | sort
All the metrics for a particular instance IP:9100 can be obtained via the following PromQL query:
{instance="IP:9100"}
This query returns all the metrics, which have the given instance="IP:9100" label. See time series selector docs for more details. See also PromQL tutorial.
The {instance="IP:9100"} query can be sent to the following Prometheus querying APIs:
- /api/v1/query - this endpoint returns matching time series values at the given timestamp specified via
timequery arg. For example,curl 'http://prometheus:9090/api/v1/query?query={instance="IP:9100"}'. Make sure you properly encodedqueryarg with percent encoding. See this demo. - /api/v1/series - this endpoint returns matching time series without any data, e.g. only metric names and labels are returned. For example,
curl 'http://prometheus:9090/api/v1/series?match[]={instance="IP:9100"}'. Make sure you properly encodedmatch[]arg with percent encoding. See this demo - /api/v1/query_range - this endpoint returns calculated datapoints for matching time series on the selected time range
[start ... end]with the givenstepinterval between samples. See more details about calculated datapoints in these docs.
If you want returning just unique metric names without labels, then you can query /api/v1/label/__name__/values endpoint: curl http://prometheus:9090/api/v1/label/__name__/values . The __name__ is a special label name used in Prometheus for referring to metric names. Note that multiple time series may share the same metric name. For example, http_requests_total{path="/foo"} and http_requests_total{path="/bar"} time series share http_requests_total metric name, while they differ by path label values.
» npm install prometheus-api-metrics
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
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.