简体   繁体   中英

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"}

  2. I want to use the Grafana metrics to have the total sum of both "apple" and "orange"

  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

In the script i wrote something like this _value + doc["orange"].value

and the value return in the graph is correct! :D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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