Regular Expressions 101

Community Patterns

1...34567...125

Prometheus Exposition metric line

1

Regular Expression
Rust

r"
^(?P<metric>[a-zA-Z_:][a-zA-Z0-9_:]*]*)(?P<labels>\{.*\})?[\t ]*(?P<value>[0-9E.]*)[\t ]*(?P<timestamp>[0-9]+)?$
"
gm

Description

Prometheus exposition metric line format. Parses metric lines with named capture groups for metric name, labels, value, and timestamp. Excludes comment, type, and help lines.

https://prometheus.io/docs/instrumenting/exposition_formats/#line-format

Submitted by james-jra - a year ago