Influx as event store

Hi guys,
l’m curious if anyone has ever tried using influx as an event store.
Basically I have a bunch of devices that emit state changes, but not full states. I would need a way to snapshot state from events stored in influx for a particular point in time. Do you see a possible way of doing this in influx?

For example, imagine the following table of events where id is the only tag and lines are ordered by time

id, propA, propB, propC
1, a, ,
2, , b,
1, a1, ,c
1, , b1 ,

If I query for the state of id=1 at a point in time after the latest insertion I would expect to see (a1, b1, c). Note that these measurements can be arbitrarily dispersed in time…

@gonber We have a couple of usecases with data like this. You would need to pull all events from the beginning of the series to recreate the state?

no. it would be enough if the latest measurement for every field would be returned. but I need it to query state at earlier times, and not only the now. thanks for your support!

@gonber Happy to help! :blush:

Thats definately supported. The performance is pretty good on LAST() too.

I imagine you’re referring to something like
select last(*) from meas where time <= some_past_timestamp group by 'id'

Suppose now I need to generate a daily snapshot. I tried
select last(*) from meas where time <= some_past_timestamp group by time(1d),'id'

The latter does not work when there’s a day for which there’s no measurement. What do you suggest in that case?

Another question is: is there a way to use last(*) such that the result columns have the same name as the original, this is withouth ‘last_’ prepended?

Thanks!

@gonber The only way to not have last_ prepended is to explicitly specify the fields and an AS clause: LAST(field1) AS field1, LAST(field2) AS field2 .

Does fill(previous) should work as for that as long as your some_past_timestamp includes at least 1 point.

I’ve been struggling how to do something similar and show it in grafana.
To put a concrete example on it, imaging that I have n servers in a pool, each of which will notify me when it goes up or comes down. The natural thing to put into influx is the events (say a 1 for up, and a 0 for down with a commensurate timestamp) tagged with the server name and pool - like the original post proposed.

The question then is how one would be able to chart, over time, the trends of servers that are up or down in grafana. Hopefully not out of scope here… but if it is, feel free to point me at somewhere else to make the inquiry.