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
Answer from Boris Ivanov on Stack OverflowYou 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.
promql - Prometheus endpoint of all available metrics - 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
» npm install prometheus-api-metrics
» pip install prometheus-api-client
The 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.