You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To properly consume some metrics, I need to set a default value on a label.
This label value is defined by an optional match group, example config (ref label version):
Note that version is fed by an optional regex match.
I'd love to be able to write something along the lines of
labels:
module: "$1"
version: "${2:-unversioned}"
though I don't care much about the specific syntax (using bash syntax here, which is also commonly used in ENV substitions, eg in docker compose files).
The text was updated successfully, but these errors were encountered:
The problem I'm trying to solve is dumb: I need to sort versions via string comparison (this is how tomcat determines the latest / active version of an app). And an empty label value does sort higher than any other value, but it should sort lowest.
This use case is slightly ridiculous, but I'm sure there are other use cases that benefit from a default label value. Providing a default label value simply improves readability of metrics, which is a benefit in its own.
For now I workaround this problem with multiple, more specific match rules, but this is quite cumbersome and error prone:
rules:
# first rule with only matches `name` with a version, second rule matches without. only first match is used.# this is, so that we always have a value in the version label, so that we can string sort by this, in order to find the latest version# in the same way tomcat does... the default version string must thus be sorted before numbers, '-' does that.
- pattern: 'Catalina<j2eeType=WebModule, name=//(?:localhost/)?([-a-zA-Z0-9+&@/%?=~_|!:.,;]*[-a-zA-Z0-9+&@/%=~_|])(?:##(.+)), J2EEApplication=none, J2EEServer=none><>startTime:'name: tomcat_module_started_atlabels:
module: "$1"version: "$2"help: Tomcat WebModule startTime (unix time)type: GAUGE
- pattern: 'Catalina<j2eeType=WebModule, name=//(?:localhost/)?([-a-zA-Z0-9+&@/%?=~_|!:.,;]*[-a-zA-Z0-9+&@/%=~_|]), J2EEApplication=none, J2EEServer=none><>startTime:'name: tomcat_module_started_atlabels:
module: "$1"version: '-'# ← ← ← ← ← ← note the default value herehelp: Tomcat WebModule startTime (unix time)type: GAUGE
To properly consume some metrics, I need to set a default value on a label.
This label value is defined by an optional match group, example config (ref label
version
):Note that
version
is fed by an optional regex match.I'd love to be able to write something along the lines of
though I don't care much about the specific syntax (using bash syntax here, which is also commonly used in ENV substitions, eg in docker compose files).
The text was updated successfully, but these errors were encountered: