Grafana:面板[时间序列转换]将许多系列合并为一个
我正在构建一个Grafana面板,以显示何时断路器(resilicence4j)改变状态。将指标发送到Prometheus看起来很像:
metric_name{instance=A, name=cb1, state=closed, value=1}
metric_name{instance=A, name=cb1, state=open, value=0}
metric_name{instance=A, name=cb1, state=half_open, value=0}
当断路器进入特定状态时,它的价值将为1,所有其他指标可以保证。结果:
时间 | 实例 | 名称 | 状态 |
---|---|---|---|
2022-06-24 17:00 | a | CB1 | CLAN CLOST |
2022-06-24 17:00:15 | A | CB1 | OPEN |
2022-06-25 17:00 | :00:00 a | CB1 | HAFFEN_OPEN |
2022-06-26 17:00:45 | A | CB1 | 关闭 |
2022-06-24 17:00:00 | A | CB2 | CLASS |
2022-06-24 17:00:15 | A | CB2 | CLEAS |
2022-06-25 17 | :00:00:00:30 A | CB2 A CB2 | OPEN |
2022-06 -26 17:00:45 | A | CB2 | Half_open |
2022-06-24 17:00 | b | CB | OPAR |
2022-06-24 17:00:15 | CB | CB | HAFFEN_OPEN |
2022-06-25 | B | CB CB | B CB CL CLEC |
17:00:00: 30 -06-26 17:00:45 | B | CB | 关闭 |
我想建立一个时间序列面板,我的轴x将是时间值,我的轴是状态(名称,而不是值),每个实例和名称都将成为系列。我尝试了许多转换的组合来做类似的事情,但是我从来没有得到预期的结果。有线索如何做?
I'm building a Grafana panel to show when a circuit breaker (resilicence4j) changes its state. Metrics being sent to Prometheus looks like:
metric_name{instance=A, name=cb1, state=closed, value=1}
metric_name{instance=A, name=cb1, state=open, value=0}
metric_name{instance=A, name=cb1, state=half_open, value=0}
It's guaranteed when a circuit breaker enters in a particular state, its value will be 1 and all others will be 0. So using Grafana transformations (keeping only metrics which value = 1) I reached the following table result:
Time | instance | name | state |
---|---|---|---|
2022-06-24 17:00:00 | A | cb1 | closed |
2022-06-24 17:00:15 | A | cb1 | open |
2022-06-25 17:00:30 | A | cb1 | half_open |
2022-06-26 17:00:45 | A | cb1 | closed |
2022-06-24 17:00:00 | A | cb2 | closed |
2022-06-24 17:00:15 | A | cb2 | closed |
2022-06-25 17:00:30 | A | cb2 | open |
2022-06-26 17:00:45 | A | cb2 | half_open |
2022-06-24 17:00:00 | B | cb | open |
2022-06-24 17:00:15 | B | cb | half_open |
2022-06-25 17:00:30 | B | cb | closed |
2022-06-26 17:00:45 | B | cb | closed |
I want to build a time series panel that my axis X would be the time value, my axis Y would be state (name, not value) and each group of instance and name would be a series. I've tried many combinations of transformations to do something like this, but I've never got the expected result. Any clues how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用时间序列面板,您需要查询结果中的数字值才能可视化。同样,y轴始终是数字。因此,您的初始查询结果应包含 state 作为数字值。另外,每列都被视为系列,因此您的列应为 a_cb1 , a_cb2 , b_cb ,并包含相应的数字状态值。
然后,您可以使用代码> 将状态映射到单词。然后,当您悬停在系列中时,这些单词将显示在工具提示中,但是,Y轴将始终保持数字。
我建议您看看状态时间表可视化。您可以使用相同的查询结果和值映射,但是显示单词,根本没有y轴。
With the Time Series panel, you need numeric values in your query result for visualization. Also, the y-axis is always numeric. So your initial query result should contain the state as a numeric value. Also each column is treated as a series, so your columns should be for example A_cb1, A_cb2, B_cb and contain the respective numeric state values.
You can then use
Value mappings
to map the state to words. Those words will then be displayed in the tooltip when you hover over the series, however, the y-axis will always stay numeric.I recommend you have a look at the State Timeline panel for your visualization. You could use the same query result and value mappings, but have the words displayed and no y-axis at all.