【问题标题】:How to calculate percentage in grafana datasource elastic如何计算grafana数据源弹性中的百分比
【发布时间】:2020-05-31 21:37:42
【问题描述】:

需要你的帮助,

目前我有如下价值弹性数据样本:

Completed : 100
Declined : 20
Canceled : 5

如何在 grafana 中使用公式创建具有上述条件的百分比成功率结果:

已完成/(已完成 + 已拒绝 + 已取消)

expected result :

success rate : 99,13 %

需要您的反馈,谢谢。

【问题讨论】:

标签: elasticsearch grafana grafana-templating grafana-api grafana-variable


【解决方案1】:

警报引擎会发布一些关于自身的内部指标。您可以阅读有关 Grafana 如何发布内部指标的更多信息。

Total number of alerts  counter alerting.active_alerts
Alert execution result  counter alerting.result
Notifications sent counter  counter alerting.notifications_sent
Alert execution timer   timer   alerting.execution_time

也可以在https://grafana.com/docs/grafana/latest/alerting/找到信息

【讨论】:

    【解决方案2】:

    一个解决方案可以通过插件grafana-meta-queries 来完成,它提供了一种使用grafana 中请求的混合结果进行算术运算的方法。

    1. 安装插件(你需要在 grafana/plugin 目录下创建一个 git clone 并重启你的服务器)
    2. 创建一个面板并将其放入提供 Completed/Declined/Canceled 结果的 3 个查询中
    3. 在同一个面板中放入另一个带有 MetaQueries 的数据源查询,并在此查询中进行算术类型的查询,您将操作与另一个查询的结果放在一起,看起来像这样

    B['已完成'] / (C['已拒绝']+B['已完成'] +D['已取消'])

    我已经尝试过使用 grafana 7.3.4 和 elastic-oss 7.9.1 以及最新版本的插件的解决方案,并且可以正常工作。

    这里是面板集的屏幕截图:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-20
      • 1970-01-01
      • 2021-04-17
      • 2021-04-12
      • 1970-01-01
      • 2020-09-01
      • 2019-01-26
      相关资源
      最近更新 更多