Hi,

I am trying to plot two charts to show correlation between them.

My first plot shows the phase error, the events for which are coming at regular interval (every second, except when there is some problem at which time there will be some gap).

My second plot is to show state transition. This state transition events are sparse and we get only a few data points (depending on the value of phase error).

So I read up this: https://www.elastic.co/blog/sparse-timeseries-and-timelion

and prepared following Timelion queries:

Phase Error: .es(*exists*:n_pll_phase_error).if(eq, 0, null, .es(metric="max:n_pll_phase_error"))

State Transition: .es(*exists*:n_pll_to_state).if(eq, 0, null, .es(metric="max:n_pll_to_state"))

And here is the incoming data for state transitions:

Within the same interval, phase error have 147,593 incoming events.

With the above queries, I see following two charts. Phase error is good but State transition is just a line.

I zoom in and don't see any data for second chart.

I use points() function and see all the 7 events.

.es(*exists*:n_pll_to_state).if(eq, 0, null, .es(metric="max:n_pll_to_state")).points()

Instead of points(), I use fit(none) then the chart almost looks correct.

.es(*exists*:n_pll_to_state).if(eq, 0, null, .es(metric="max:n_pll_to_state")).fit(none)

The reason I say almost is cause the first event came in transitioning from state 1 to state 3 but in the fit it shows state as 3 from the beginning of time which is misleading.

What I would to see instead is below chart:

Where the read line indicates the state change happened from 1 to 3 and happened at 00:32 (no assumption about prior state since it doesn't know what it was). Similarly, towards the end the line ends at 01:06 indicating that's all it knows.

If this is not doable, then I'd at least like to be able to show the initial state transition from 1 to 3 (its fine if fit() extrapolates the same data to past and future.)

Any other tips as to what's the best way to show state transitions?

Thanks

Nikhil