Prometheus metric relabel for value

322 Views Asked by At

Basically I want to relabel the metric value , path = /api/v2/users/-/hashes/004fc134-93ba-4c48-b0da-e114f2245b77/activate

to

/api/v2/users/externalhashes/ops

I tried this below but its not working. Am i missing something?

  metric_relabel_configs:
  - source_labels: [path]
    regex: (\/api\/v2\/users\/+.\/hashes\/[0-9a-z\-]{1,40}\/\w.*)
    replacement: ‘/api/v2/users/externalhashes/ops’
    target_label: path
2

There are 2 best solutions below

1
On BEST ANSWER

Try the following:

regex: '/api/v2/users/.+/hashes/[0-9a-z\-]{1,40}/\w.*'
1
On

Prometheus uses Golang re2 package to parse Regular expressions https://github.com/google/re2/wiki/Syntax

Googling quickly for a tester I found this https://regoio.herokuapp.com/

Marcelo's answer does the work :+1: