简体   繁体   中英

Prometheus metric relabel for value

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

请尝试以下操作:

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

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM