Inter record functions in Kibana?


(Cristian) #1

Hi All!
I have forex information for each day. Close, Open, Low, High.
Now, I would like to calculate the difference in % between a point in time, lets say today (t0), and the day before (-t1). That is: (|t0-t1|/((t0-t1)/2))*100
Are there any "inter record" functions to use for this in Kibana? How can I "fetch" a value from another row?
I would like to display this data in a table per day. So each row would have the data for that date but also the calculated fields.

Desired result:
Date, Open, Close, High,Low, % Diff
2017-08-01, 10, 11, 13, 9, 10%
207-07-31, 9, 10, 12, 8, x%

Any suggestions?


(Lukas Olson) #2

I'm not sure of a way to get the percent difference, but you can use the "Derivative" aggregation to get the actual difference. So instead of what you suggested, it might look like the following:

Date, Open, Close, High,Low,Diff
2017-08-01, 10, 11, 13, 9, 4
207-07-31, 9, 10, 12, 8, x

(Cristian) #3

Thanks and sorry for late reply. Dont how the "derivative" works at all. Do you know an example somewhere that I can read? Dont really understand the manual (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html)

Br
Cristian


(Cristian) #4

Any other suggestion how to solve this?


(Cristian) #5

Is this possible to do in Logstash? when reading the new info is it possible to fetch data from the index and do the calculations?


(Cristian) #6

Ok. So I tried the Derivative function but this gives me only the difference to the row before. A better aggregation is "Serial Differencing"-aggregation where I can pin point the row that should be used in the difference. Much better. I still have a problem though. I would like to create my own calculation based on that difference. Is this possible? I would like create a Metric that uses two other metrics ( the serial difference and a sum) as input.

Also, I would like calculate the difference between different fields. The "Serial Differencing agg" calculates on one field. Is it possible to calculate the serial diff between lets say "High"-value today and "Open"-value 3 rows ago?
Br
Cristian


(system) #7

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