I am using Grafana with ElasticSearch as the datasource, i wrote a simple Lucene Query for Grafana Stat panel and i am summing up that value for visualization. The sum metric works fine and i could see the metrics getting displayed. But my requirement is Not just to sum this metric but be able to compute the Difference of the sum which was some duration ago.

For example

previousSum = sum which was 5 minutes ago

currentSum = current Sum

where previousSum, currentSum are being computed for the same metric.

and then compute (previousSum - currentSum)/currentSum to get the % change for that specific metric. Any help is greatly appreciated.

thanks.