Mathematic Calculation


(Amit) #1

Hi,

I am trying to create timelion, have 4 fields lets say a,b,c,d. It should perform mathematics calculation like a+b/c+d and it should have one line output.

Any idea how to do it?

Thanks...


(Peter Pisljar) #2

that should be quite simple, but you have not mentioned how you want to aggregate your fields ...

lets say your data looks like this:

 date           | a | b | c | d
 1.1.2017 12:00 | 1 | 1 | 2 | 1
 1.1.2017 12:45 | 2 | 1 | 2 | 1
 1.1.2017 13:00 | 1 | 1 | 1 | 1
 2.1.2017 12:00 | 1 | 3 | 2 | 1

now in timelion you'll be looking at your daily data for example .... how do you want to treat multiple records from the same day ? do you want to look at average, sum, min, max... ?

so lets say you want to do a sum aggregation then your timelion expression would look something like this:

.es(metric=sum:a).add(.es(metric=sum:b).divide(.es(metric=sum:c).add(metric=sum:d))

(Amit) #5

It works... Thank You!


(system) #6

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