Does prometheus support multiple labels regarding the label_replace() function

2,004 views
Skip to first unread message

anton...@gmail.com

unread,
Jul 22, 2018, 10:32:50 PM7/22/18
to Prometheus Users
Does label_replace() can only support one label_replace once ?   i have a metric as test{a='1',b='name:antony age:28'},how can i make the metric like test{a='1',name="antony",age="28"}? cause i need to use this as the content of my alertmanager

Matthias Rampke

unread,
Jul 23, 2018, 2:50:40 AM7/23/18
to anton...@gmail.com, Prometheus Users
You can nest multiple label_replace calls. This isn't pretty but it works. Alternatively, you can use (metric) relabeling to do this ahead of time, or regex matching in the Alertmanager template to do it after the fact.

/MR

On Mon, Jul 23, 2018, 04:32 <anton...@gmail.com> wrote:
Does label_replace() can only support one label_replace once ?   i have a metric as test{a='1',b='name:antony age:28'},how can i make the metric like test{a='1',name="antony",age="28"}? cause i need to use this as the content of my alertmanager

--
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 post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/bb27a496-850c-4845-9a83-daede852e18d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicholas Capo

unread,
Jul 23, 2018, 7:47:40 PM7/23/18
to Matthias Rampke, Prometheus Users, anton...@gmail.com
The data you have looks kind of structured, honestly I would recommend fixing this sort of thing at the source of the data (meaning the application itself), instead of trying to mutate it into something useful after the fact.

Nicholas


anton...@gmail.com

unread,
Jul 24, 2018, 9:20:51 PM7/24/18
to Prometheus Users
Hi MR
     Actually i am now using the metric relabeling to solve the issue, it dose work ,thanks~

在 2018年7月23日星期一 UTC+8下午2:50:40,Matthias Rampke写道:

anton...@gmail.com

unread,
Jul 24, 2018, 9:22:18 PM7/24/18
to Prometheus Users
Thanks for your advise , i am now using metric relabeling to solve the issue , but i think maybe a cmdb is the best the way to solve all the similar function

在 2018年7月24日星期二 UTC+8上午7:47:40,Nicholas Capo写道:
Reply all
Reply to author
Forward
0 new messages