I have 6 data points in a timeboxed search of data in an index:
@timestamp state
February 17th 2019, 07:15:01.000 1
February 17th 2019, 07:15:37.000 0
February 17th 2019, 07:19:29.000 1
February 17th 2019, 07:21:51.000 0
February 17th 2019, 07:49:40.000 1
February 17th 2019, 07:51:15.000 0
This data represents when the screen is turned on and off on an Android device.
I am trying to create a visualization that shows the screen on time as shaded areas of the graph (I will be superimposing other activities over the top).
The closest I've got so far is this:
.es(q='',index=devices-,metric=max:state).fit(nearest).lines(fill=1,width=0).color("grey")
There are two difficulties I am trying to solve;
First - most importantly for the visualization - is the graph before the first datapoint. This is the rule I need:
If the first datapoint is a '1' - then the initial line to that datapoint must be '0'.
If the first datapoint is a '0' - then the initial line leading to that datapoint must be a '1'.
I have no idea how to implement this... the .fit(nearest) is extending the area to the left with the actual value.
The second issue I have is the vertical lines defining the shaded boundaries are, well, not vertical. At the timestamp it becomes '1' - I need it to step vertically up to '1'. Likewise for the datapoint of '0' - it needs to step vertically down to '0'.
The final issue is the grey areas are being significantly widened. I suspect this is due to the bucket size - but that's not the whole story. 'Auto' the 0 to 0 and 0-1 transitions are often off by 30 seconds or more. If I set 1 second bucket sizes I get too many data points to represent. If I set 2 second bucket sizes the graph looks better (except the issues above) - but the transitions are still 10-15 seconds off. I'm not sure why....
I'm obviously missing something pretty fundamental - I feel like I'm swimming upstream with this... I just cannot find it in the documentation... Does anyone have any ideas about what I should try?
Thank you,
Michael.