Get all metric names per HTTP API

14,716 views
Skip to first unread message

antonios....@gmx.de

unread,
Oct 25, 2017, 6:23:45 AM10/25/17
to Prometheus Users
Hi,

i try to get a list of all metric names of all targets stored in prometheus.

When i do a curl -s 'http://localhost:9090/metrics', i get only the local server metrics.
Also i did not find any way by using the HTTP API.

Is this possible?


Thanks,
Toni.

Conor Broderick

unread,
Oct 25, 2017, 6:33:23 AM10/25/17
to antonios....@gmx.de, Prometheus Users
You could try:

$ curl localhost:9090/api/v1/label/__name__/values

Which will return all label values for the __name__ label.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/0fcbca5f-ff5e-4893-8e5c-3b746548959e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

antonios....@gmx.de

unread,
Oct 25, 2017, 6:53:05 AM10/25/17
to Prometheus Users
Jep, really easy compared with my tries :-)

Thanks.

manju...@gmail.com

unread,
Apr 19, 2019, 11:57:05 AM4/19/19
to Prometheus Users
Thanks, this helped :-)


On Wednesday, 25 October 2017 06:33:23 UTC-4, Conor Broderick wrote:
You could try:

$ curl localhost:9090/api/v1/label/__name__/values

Which will return all label values for the __name__ label.
On 25 October 2017 at 11:23, <antonios....@gmx.de> wrote:
Hi,

i try to get a list of all metric names of all targets stored in prometheus.

When i do a curl -s 'http://localhost:9090/metrics', i get only the local server metrics.
Also i did not find any way by using the HTTP API.

Is this possible?


Thanks,
Toni.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.



--

cata...@gmail.com

unread,
May 17, 2019, 2:47:27 PM5/17/19
to Prometheus Users
where can I find more about the API endpoints, I have google and googled, I basically want to HTTP API call a specific target and a time series of memory usage metrics for that target.
Is this possible?

cata...@gmail.com

unread,
May 17, 2019, 2:51:35 PM5/17/19
to Prometheus Users
where can I find more about the API endpoints, I have google and googled, I basically want to HTTP API call a specific target and a time series of memory usage metrics for that target.
Is this possible?

On Wednesday, October 25, 2017 at 6:33:23 AM UTC-4, Conor Broderick wrote:
You could try:

$ curl localhost:9090/api/v1/label/__name__/values

Which will return all label values for the __name__ label.
On 25 October 2017 at 11:23, <antonios....@gmx.de> wrote:
Hi,

i try to get a list of all metric names of all targets stored in prometheus.

When i do a curl -s 'http://localhost:9090/metrics', i get only the local server metrics.
Also i did not find any way by using the HTTP API.

Is this possible?


Thanks,
Toni.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.



--

Callum Styan

unread,
May 21, 2019, 7:12:12 PM5/21/19
to Prometheus Users
The docs for the HTTP api are here: https://prometheus.io/docs/prometheus/latest/querying/api/

If you look here: https://prometheus.io/docs/prometheus/latest/querying/api/#expression-queries specifically just below the first code block, you can see the parameters the query API will take. 

The first parameter is query=<string>: Prometheus expression query string.

So you would put the query for the series you want (your memory usage series) and a label selector for the target there.

tim taler

unread,
May 22, 2019, 6:50:46 AM5/22/19
to Prometheus Users
and if you want to do anything on the commandline with the result you might want to have a look at jq ...
something like:

curl http://localhost:9090/api/v1/query?query="node_cpu_seconds_total" | jq '.data.result[] | { instance: .metric.instance, mode: .metric.mode, val: .value[1]}'  | perl -pe "s/\n//g" | perl -pe "s/}/}\n/g

change the query to your need and the jq filter to your needs, but from there one can easily grep for hosts or values
or creating reports and the like

hth 

tim taler

unread,
May 24, 2019, 11:05:41 AM5/24/19
to Prometheus Users
Yeah, well different system architectures expose different metrics with, ergo, different names and meanings.

What I usually do is to point my webbrowser to <target>:9100/metrics and safe the side for further inspection/search/reference 
there you see ALL availabel metric names ...

hth

catalyph

unread,
May 25, 2019, 6:23:12 AM5/25/19
to tim taler, Prometheus Users
Thanks. This helped, i didnt know that metrics from different systems would have different names. Like Windows has wmi_metric and linux has node_metric..



Sent from my Samsung Galaxy smartphone.
--
You received this message because you are subscribed to a topic in the Google Groups "Prometheus Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/prometheus-users/-3zL82taz7M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to prometheus-use...@googlegroups.com.

To post to this group, send email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages