hi how do i get all labels list in prometheus?

37,016 views
Skip to first unread message

Yosef Yudilevich

unread,
Aug 28, 2016, 2:38:24 AM8/28/16
to Prometheus Developers
i want to add dropdown in grafana which lets me choose label, 
and then do some filtering with it
as i see i can do it with query only

thats why i am asking here
thanks

Julius Volz

unread,
Aug 28, 2016, 6:37:30 AM8/28/16
to Yosef Yudilevich, Prometheus Developers
Are you looking for "label_values(label)" (A Grafana feature)?


--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yosef Yudilevich

unread,
Aug 28, 2016, 6:49:33 AM8/28/16
to Julius Volz, Prometheus Developers
yes
but that would give you values
and i want
names

so in first dropdown i choose name of the labels
and in the second value
i just can’t get the names


On 28 Aug 2016, at 1:37 PM, Julius Volz <juliu...@gmail.com> wrote:

label_values(label)

Yosef Yudilevich

unread,
Aug 28, 2016, 6:55:49 AM8/28/16
to Prometheus Developers
i mean sometimes i want to filter by dc, and other time by region or server_role
so i need to choose label name first andthen filter by it
thanks

in grafana there is also query() to choose from
so i thought may be there is some query for that

Yosef Yudilevich

unread,
Aug 29, 2016, 3:39:23 PM8/29/16
to Prometheus Developers
still need an help pls
or at least, that there is no way to do it

thanks

atsv...@tango.me

unread,
Aug 31, 2016, 7:44:39 AM8/31/16
to Prometheus Developers
On Sunday, August 28, 2016 at 9:38:24 AM UTC+3, Yosef Yudilevich wrote:
+1 I'm also unable to find such function in Prometheus.

pgppro...@gmail.com

unread,
Apr 27, 2017, 5:43:33 PM4/27/17
to Prometheus Developers
Bit old, but I did find a way to do it.
http://promethesusserver:port/api/v1/label/__name__/values
will return all Labels that are shown in the Graph listing.

Jasmine Hegman

unread,
May 2, 2017, 12:24:20 PM5/2/17
to Prometheus Developers, pgppro...@gmail.com
Just want to follow up with some more information..

For selecting dynamically {__name__=~".+"} will get all of your metrics.

sum by(__name__) ({__name__=~".+"})

will get just their names without extra label/redundancy cruft.

Additionally, to enable the filtering the original poster seems to desire I think he will need multiple Grafana Template Variables. Each template variable with grab the individual values for the respective keys.

The chart would then be like metric_name{templated_var_a_key="$templated_var_a"}

If you want to use the Multiple select and Select All functionality then change the query to

metric_name{templated_var_a_key=~"$templated_var_a"}

The only change needed is to switch the operator to use RegExp. Grafana will automatically pass your multiple selected values as regexp compatible, e.g. "selectA|selectB". If you have too many records for All to cram them in you can specify it to use .* instead which will do about the same for most cases.

Lastly Grafana also has a metric function, described on this page: docs.grafana.org/features/datasources/prometheus/#templated-queries

bai...@gmail.com

unread,
Apr 2, 2019, 4:03:11 AM4/2/19
to Prometheus Developers
在 2016年8月28日星期日 UTC+8下午6:37:30,Julius Volz写道:
> Are you looking for "label_values(label)" (A Grafana feature)?
>
>
> See http://docs.grafana.org/datasources/prometheus/#templated-queries
>
>
> On Sun, Aug 28, 2016 at 8:38 AM, Yosef Yudilevich <yosef.y...@gmail.com> wrote:
>
> i want to add dropdown in grafana which lets me choose label, 
> and then do some filtering with it
> as i see i can do it with query only
>
>
> thats why i am asking here
> thanks
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Hi. I want to query all values of a label by http api, such as query all instances belonging to one job. How should I do that ?

klavs....@gmail.com

unread,
Aug 17, 2020, 5:54:27 AM8/17/20
to Prometheus Developers
> Hi. I want to query all values of a label by http api, such as query all instances belonging to one job. How should I do that ?

Did you ever find a solution for the above? I need the same - get all metrics -that have as speciflc label like {job="mytestjob"}

Julius Volz

unread,
Aug 17, 2020, 12:56:56 PM8/17/20
to klavs....@gmail.com, Prometheus Developers
On Mon, Aug 17, 2020 at 11:54 AM klavs....@gmail.com <klavs....@gmail.com> wrote:
> Hi. I want to query all values of a label by http api, such as query all instances belonging to one job. How should I do that ?

Did you ever find a solution for the above? I need the same - get all metrics -that have as speciflc label like {job="mytestjob"}

If you want to constrain it by the job, you would currently have to use the series metadata API and then extract the label values from the returned series:


There is an open issue to allow providing matcher constraints for the labels metadata API as well: https://github.com/prometheus/prometheus/issues/6178
 
tirsdag den 2. april 2019 kl. 10.03.11 UTC+2 skrev bai...@gmail.com:
在 2016年8月28日星期日 UTC+8下午6:37:30,Julius Volz写道:
> Are you looking for "label_values(label)" (A Grafana feature)?
>
>
> See http://docs.grafana.org/datasources/prometheus/#templated-queries
>
>
> On Sun, Aug 28, 2016 at 8:38 AM, Yosef Yudilevich <yosef.y...@gmail.com> wrote:
>
> i want to add dropdown in grafana which lets me choose label, 
> and then do some filtering with it
> as i see i can do it with query only
>
>
> thats why i am asking here
> thanks
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Hi. I want to query all values of a label by http api, such as query all instances belonging to one job. How should I do that ?

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages