Timelion condtion function example


(Jeremy Colton) #1

Hi,

I have built this TimeLion query that works:

.es('PID:123 AND event:"Button%20Clicked"').divide(.es('PID:123 AND event:*')).multiply(100).lines().label('Rate as %')

But sometimes there are no values to plot, so TimeLion draws nothing leaving an empty gap in the line graph.

I tried using the fit('none') function but it didn't draw a direct line between the surrounding data points. Instead it plateaued the data which is incorrect:

.es('PID:fashionseoul AND event:"Trendi%20Button%20Clicked"').divide(.es('PID:fashionseoul AND event:*')).multiply(100).lines().fit('none').label('Rate as %').legend('ne')

So I saw there is a condtion() function that may help. How do I use this function such that if a data point is null, to set it to 0 (zero) ?

Many thanks.


(Marco Bertani-├śkland) #2

There is an example on using condition at the bottom here: https://github.com/elastic/timelion/pull/78

But you probably just need an if?

.es('PID:123 AND event:"Button%20Clicked"').divide(.es('PID:123 AND event:*')).if(eq, null, 0).multiply(100).lines().label('Rate as %')


(system) #3