proposal for combining labels

16 views
Skip to first unread message

Dhiman Barman

unread,
Feb 12, 2020, 2:57:36 PM2/12/20
to prometheus-developers
Hi,

It will be useful to have a way to combine metric labels and create a new label as follows. 

metric_name{label1=a, label2=b}  => metric_name{label1=a, label2=b, combined_label=a_b}
metric_name{label1=b, label2=a}  => metric_name{label1=b, label2=a, combined_label=a_b}

The combined label will be inserted into the original metric. In the AlertManager, we can use group_by{} on the 
combined label so two separate tickets do not get created in JIRA. Furthermore, we also do not want
AlertManager to propagate the combined_label downstream. The combined label is for grouping in the 
AlertManager only. 

Will there be any issue if this feature is added in Prometheus ? 

Thanks,
Dhiman


Julien Pivotto

unread,
Feb 12, 2020, 3:02:07 PM2/12/20
to Dhiman Barman, prometheus-developers
On 12 Feb 11:57, Dhiman Barman wrote:
> Hi,
>
> It will be useful to have a way to combine metric labels and create a new
> label as follows.
>
> metric_name{label1=a, label2=b} => metric_name{label1=a, label2=b,
> combined_label=a_b}
> metric_name{label1=b, label2=a} => metric_name{label1=b, label2=a,
> combined_label=a_b}

You can use label_join
https://prometheus.io/docs/prometheus/latest/querying/functions/#label_join

Or do that with metrics relabelling.

> The combined label will be inserted into the original metric. In the
> AlertManager, we can use *group_by{}* on the
> combined label so two separate tickets do not get created in JIRA.
> Furthermore, we also do not want
> AlertManager to propagate the combined_label downstream. The combined label
> is for grouping in the
> AlertManager only.

You don't need to combine to group them together.

>
> Will there be any issue if this feature is added in Prometheus ?
>
> Thanks,
> Dhiman
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CA%2BLhoFzNHddec%3D4TOcXEAgHkJBrkzX-FXe2EjekRtp8QVMeC%3Dw%40mail.gmail.com.

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

Dhiman Barman

unread,
Feb 12, 2020, 7:37:53 PM2/12/20
to Julien Pivotto, prometheus-developers
HI,

If we use group_by() on the two labels - label1 and label2, how will it work because value pairs are (a, b) and (b, a) ? Will it not create separate alarms/notifications ? I need the value for the combined label to be "a_b" so the values need to be sorted. 
However, label_join() can be enhanced and another operator label_join_sorted() can be supported which will sort the values before creating a new metric. 

Thanks,
Dhiman

Julien Pivotto

unread,
Feb 13, 2020, 12:48:21 AM2/13/20
to Dhiman Barman, prometheus-developers
Hi,


Label values are opaque to Prometheus. It looks like you would better fix your input labels.

Regards,
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/CA%2BLhoFx_crtFSE370g8GXPBb_hiWWBOZa%2BpRmc3WTAdrivc13g%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages