Regular Expressions 101

Community Patterns

1...56789...879

Support metrics.agent.grafana.com/path or prometheus.io/path with or without K/V pairs for multiple ports

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^([^;,\n]*)(;.*\b\1\b=|;.*;|;)([^;=,\n]+)(,.*|;)?$
/
gm

Description

# allow override of default /probe path, both of the following annotations are supported:
#   metrics.agent.grafana.com/path: /~/ready
#   prometheus.io/path: /~/healthy
#   or
#   metrics.agent.grafana.com/path: /~/ready
#   prometheus.io/path: /~/healthy
- action: replace
  source_labels:
    - __meta_kubernetes_service_annotation_prometheus_io_path
    - __meta_kubernetes_service_annotation_metrics_agent_grafana_com_path
  separator: ;
  regex: ^([^;,\n]*)(;.*\b\1\b=|;.*;|;)([^;=,\n]+)(,.*|;)?$
  replacement: $2
  target_label: __tmp_path
Submitted by AaronB - a year ago