string value replacement from the lable value

27 views
Skip to first unread message

MySQL tute's (Mohan Kumar HG)

unread,
Feb 7, 2023, 7:36:14 AM2/7/23
to Prometheus Users
Hi Team,

we have a custom metrics and it shows the output like "LOW-003-MK_dwm"
stack_info{job="LOW-003-MK_dwm"}

and i want to remove the 4 character and add the new character called "-node-exporter".

so finally my output would look like   " LOW-003-MK-node-exporter  "
stack_info{job="LOW-003-MK-node-exporter  "}


can some some please help to write the query.


Daz Wilkin

unread,
Feb 9, 2023, 12:31:30 AM2/9/23
to Prometheus Users
Perhaps:

- source_labels: [job]
  target_label: job
  regex: LOW-003-MK_[a-z]{3}
  replacement: LOW-003-MK-node-exporter

You can plug the above into https://relabeler.promlens.com

Brian Candler

unread,
Feb 12, 2023, 9:41:56 AM2/12/23
to Prometheus Users
Beware that "job" is a reserved label name in Prometheus; it is only supposed to be used for the name of the scrape job which obtained the metric.  You can overwrite it, but it's at your own peril.
Reply all
Reply to author
Forward
0 new messages