简体   繁体   English

Grafana将聚集用于Elasticsearch数据源的两个字段总和

[英]Grafana to use aggregration for total of two field sums of Elasticsearch data source

  1. I have two fields lets say the name is {"apple":100} and {"orange: 50"} 我有两个字段,可以说名称是{"apple":100} and {"orange: 50"}

  2. I want to use the Grafana metrics to have the total sum of both "apple" and "orange" 我想使用Grafana指标获取“苹果”和“橙色”的总和

  3. I've tried to use multiple sum metrics but that doesn't add up the both field sums. 我尝试使用多个总和度量标准,但这并没有将两个字段总和相加。

  4. After going through discussion/questions posted online i still unable to find the exact solution. 经过网上发布的讨论/问题之后,我仍然找不到确切的解决方案。

add_two_fields_value_by_using_script I've found the answer, we need to utilize the "Script" option. 我找到了答案,我们需要利用“脚本”选项。 First we set a metric to get sum of apple, then the result of sum of apple is added to doc["orange"].value 首先,我们设置一个度量以获取苹果总和,然后将苹果总和的结果添加到doc [“ orange”]。value

In the script i wrote something like this _value + doc["orange"].value 在脚本中,我写了这样的值_value + doc [“ orange”]。value

and the value return in the graph is correct! 并且图形中的值返回正确! :D :d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM