Grafana:面板[时间序列转换]将许多系列合并为一个

发布于 2025-02-10 18:14:35 字数 2919 浏览 2 评论 0原文

我正在构建一个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:00aCB1CLAN CLOST
2022-06-24 17:00:15ACB1OPEN
2022-06-25 17:00:00:00 aCB1HAFFEN_OPEN
2022-06-26 17:00:45ACB1关闭
2022-06-24 17:00:00ACB2CLASS
2022-06-24 17:00:15ACB2CLEAS
2022-06-25 17:00:00:00:30 ACB2 A CB2OPEN
2022-06 -26 17:00:45ACB2Half_open
2022-06-24 17:00bCBOPAR
2022-06-24 17:00:15CBCBHAFFEN_OPEN
2022-06-25BCB CBB CB CL CLEC
17:00:00: 30 -06-26 17:00:45BCB关闭

我想建立一个时间序列面板,我的轴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:

Timeinstancenamestate
2022-06-24 17:00:00Acb1closed
2022-06-24 17:00:15Acb1open
2022-06-25 17:00:30Acb1half_open
2022-06-26 17:00:45Acb1closed
2022-06-24 17:00:00Acb2closed
2022-06-24 17:00:15Acb2closed
2022-06-25 17:00:30Acb2open
2022-06-26 17:00:45Acb2half_open
2022-06-24 17:00:00Bcbopen
2022-06-24 17:00:15Bcbhalf_open
2022-06-25 17:00:30Bcbclosed
2022-06-26 17:00:45Bcbclosed

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场信仰旅途 2025-02-17 18:14:36

使用时间序列面板,您需要查询结果中的数字值才能可视化。同样,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文