Querying VIA Prometheus API

20 views
Skip to first unread message

Tekraj Chhetri

unread,
Mar 4, 2020, 1:41:36 PM3/4/20
to Prometheus Users
Hi,

I am new to this and would like your help.

I have an access to prometheus via API. I can query the list of available metrics using http://serveraddress:9090/api/v1/label/__name__/values . But how to query all the values of the available metrics?

I also can query using http://serveraddress:9090/api/v1/query?query=process_virtual_memory_bytes but it seems that i have to do individually and not all metrics that i can see using label/__name__/values are available here.


Thank you.

Brian Candler

unread,
Mar 4, 2020, 4:39:48 PM3/4/20
to Prometheus Users
It's a bad idea to query all metrics, as it will touch all timeseries and create a huge amount of work in I/O and memory usage.  But you can, and on a small test system it will probably be OK: the query is

{__name__=~".+"}

On a production system: you always want to ensure you're not touching every timeseries.  Normally you'd do that by giving the metric name:

process_virtual_memory_bytes
is the same as
{__name__="process_virtual_memory_bytes"}

If you have another way to narrow it down to just a subset of series it should be OK, e.g.

{__name__=~".+",instance="foo.example.com"}


Julien Pivotto

unread,
Mar 4, 2020, 4:45:32 PM3/4/20
to Brian Candler, Prometheus Users
Hi there,
In this case it can be written simply as {instance="foo.example.com"}.

Regards,

>
>
> --
> 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-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/0b630da0-73db-4eb0-be16-841d59dc5d5a%40googlegroups.com.


--
(o- Julien Pivotto
//\ Open-Source Consultant
V_/_ Inuits - https://www.inuits.eu
signature.asc

Tekraj Chhetri

unread,
Mar 4, 2020, 5:00:17 PM3/4/20
to Prometheus Users
Thank you all for your suggestion and quick reply. Really appreciated your help.  
Reply all
Reply to author
Forward
0 new messages