add label from one metrics to matching label to other metrics

2,001 views
Skip to first unread message

sunils...@gmail.com

unread,
Oct 17, 2020, 4:20:41 AM10/17/20
to Prometheus Users
Hi 
I have to label from one metrics to remaining other metrics .  Can we do it using relabel_config in pometheus.yml.

Example : 
Below metrics holds topic and source label :
source_topic_metrics(topic=topic1, source=source1)
source_topic_metrics(topic=topic2, source=source2)

Other metrics holds details like : 
fluentd_input_rate(topic=topic1, host=host1)
fluentd_input_rate(topic=topic2, host=host1)
kafka_log_size(topic=topic1)
kafka_log_size(topic=topic2)

I want to add labels from above query and want output as :
fluentd_input_rate(topic=topic1, host=host1, source=source1)
fluentd_input_rate(topic=topic2, host=host1, source=source2)
kafka_log_size(topic=topic1, source=source1)
kafka_log_size(topic=topic2 source=source2)

So here , common match is topic, based on this label match I want to add source label in each metrics . 

Thanks
Sunil Sagar

Brian Candler

unread,
Oct 17, 2020, 4:49:54 AM10/17/20
to Prometheus Users
You can only use relabel_config if you know prior to each scrape the extra labels you want to add.

If you want to combine labels from two different metrics, then create a PromQL query that does the join, and when you have that working, put it into a recording rule.  You can find examples of the join here:


Reply all
Reply to author
Forward
0 new messages