Compute distance between current and previous value

I have CPU Utilization data ingested into Elastic Search. My requirement is to calculate distance between 2 subsequent values e.g. current value and previous value. Please provide any pointers to achieve the same using script Query in Elastic Search.

Below is the snapshot of sample data ingested into ES. Currently I have single server with single metric only.

2017-07-2 11:47:40,server1,processor(_total)-% processor time,2.86,System Processor Time,w3wp,APM2
2017-07-2 11:48:10, server1,processor(_total)-% processor time,7.11,System Processor Time,w3wp,APM2
2017-07-2 11:48:40, server1,processor(_total)-% processor time,3.04,System Processor Time,w3wp,APM2
2017-07-2 11:49:10, server1,processor(_total)-% processor time,3.37,System Processor Time,w3wp,APM2

What do you want to do with this distance? You should probably compute that distance on the client side before sending the data to Elasticsearch. Once documents are in Elasticsearch, the order of documents does not mean much, Elasticsearch actually freely reorders documents if it allows for more efficient merges.

Thanks for the response. I cannot do processing on the client side due to some restrictions.

I have metric_time field stored in ES which can be used to get current and previous value but I am not getting any pointers how to achieve the same in query in ES. Pls let me know if you need more info on the requirements.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.