0

这是当前的Jmx 导出器模式:

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

电流输出:

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

这实际上工作正常。但是为了提高基数,我们决定不公开修改 Yml 的 0.0 值(如果有的话)。

上述样本的预期输出是,

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

请随时在下面发表评论。

4

2 回答 2

0

看起来您有 5 个x_y_z__resilience4j_circuitbreaker_state指标name,每个指标都有不同的kind标签,一个的值为 ,1.0其他的值为0.0

在这种情况下,如果您不公开0.0并且断路器在所有状态中发生更改,所有指标都将报告1.0

要减少基数,您应该删除kind标签并将值设置为状态。

而不是这个:

x_y_z__resilience4j_circuitbreaker_state{kind="disabled",name="a",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="a",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="open",name="a",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="half_open",name="a",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="forced_open",name="a",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="disabled",name="b",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="b",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="open",name="b",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="half_open",name="b",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="forced_open",name="b",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="disabled",name="c",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="closed",name="c",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="open",name="c",} 0.0
x_y_z__resilience4j_circuitbreaker_state{kind="half_open",name="c",} 1.0
x_y_z__resilience4j_circuitbreaker_state{kind="forced_open",name="c",} 0.0

你应该报告这样的事情:

x_y_z__resilience4j_circuitbreaker_state{name="a"} 1.0 # 1 represents "closed"
x_y_z__resilience4j_circuitbreaker_state{name="b"} 2.0 # 2 represents "open"
x_y_z__resilience4j_circuitbreaker_state{name="c"} 3.0 # 3 represents "half_open"
于 2021-01-10T14:33:31.177 回答
0

最后下面的正则表达式对我有用,

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

这是我的结果的验证,

点击这里验证结果

于 2021-02-04T03:23:50.213 回答