Replacing a "/" using regex

17 views
Skip to first unread message

Adso Castro

unread,
Feb 28, 2020, 3:33:28 PM2/28/20
to Prometheus Users
Hey guys,

I'm in the middle of something here, I'm trying to replace the "/" from the metric below but this isn't working at all.
I'm using a beanstalkd exporter, and the tubes are being listed with a "/" and it's messing up with some automations that we're using because of that forward slash, example below:

Query:
tubes_ready_total

Results:
{tube="some/simple/tube/one"}
{tube="some/simple/tube/two"}

I want to replace the "/" with a "_" if possible.

Would it be something like:

      metric_relabel_configs:

        - source_labels: [tube]

          action: replace

          target_label: tube

          regex: (.+)(\/);(_)

          replacement: $1:$2


Thank you.

Brian Candler

unread,
Feb 28, 2020, 6:46:45 PM2/28/20
to Prometheus Users
- source_labels: [tube]
  target_label: tube
  regex: (.*)/(.*)
  replacement: $1:$2

However you'll have to repeat this rule N times if you want to be able to replace up to N slashes.
Reply all
Reply to author
Forward
0 new messages