Transform - Rename By Regex

mssu_12345_FailCode_PROPANE_FAIL_AwaitingDocumentsFromCounterparty_GB{instance=“XX-de5a-XXYY.abc.nsroot.net:33581”, job=“MssuExporter”}

I have this metric coming in via Prometheus. I just want to display “AwaitingDocumentsFromCounterparty” as the name if the metric

Tried using transform - Rename by Regex.

Match : .*(FAIL)
Replace : left as blank

gives me “AwaitingDocumentsFromCounterparty_GB{instance=“XX-de5a-XXYY.abc.nsroot.net:33581”, job=“MssuExporter”}” .

Just want “AwaitingDocumentsFromCounterparty”

what if you just use AwaitingDocumentsFromCounterparty in the regex? or are there other flavors

Thank You for the response

cant, i will be pulling 120 metrics and each of them will have a different fail code . am looking for code that can only extract that subset of characters after the string FAIL, so that i don’t have to repeat the code 120 times

1 Like

Wouldn’t something like
(.*)_FAIL_(.*?)_(.*) work (with replacement $2)? The (.*?) means “take as little as possible”

1 Like

Thank You . This works

Is there a way i can achieve this using only Match and not giving anything in replace

The reason i ask is, i have to use a similar regex in the Variables to provide a filter/drop down with all the available error codes

Under Dashboard Settings–Variables–Edit , i only see a Regex option and no Match and replace

I’m not sure (you’ll have to test it for your example) but I think the same regex would work without parenthesis in the first group.
.*_FAIL_(.*?)_(.*)
Regex’s not my specialty, so I don’t know either what happens, but it worked for me :smile:

2 Likes

Thank You. This worked perfectly fine

1 Like