javayamlprometheusjmxsre

Eliminate specific value from Jmx exporter through config Yaml


Here is the current Jmx exporter pattern:

pattern: 'metrics<name=resilience4jCircuitbreakerState.name.(.*).state.(.*), type=gauges><>Value'
name: 'x.y.z.resilience4j.circuitbreaker.state'
labels: {name: "$1", kind: "$2" }
type: GAUGE

Current Output:

x_y_z_resilience4j_circuitbreaker_state{kind="open",name="a",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="b",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="half_open",name="c",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="half_open",name="d",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="forced_open",name="e",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="disabled",name="f",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="disabled",name="g",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="forced_open",name="h",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="i",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="j",} 1.0

Which actually works fine. But to improve cardinality we decided not to expose 0.0 values modifying the Yml (if there is anyway).

The expected output for the above pieces of sample is,

x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="b",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="i",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="j",} 1.0

Please feel free to comment below.


Solution

  • Finally below regex works for me,

    ^(?!0(\.0)?$)
    

    Here is the verification of my result,

    Click here to verify the result