I’m the beginner in InfluxDB, and now I try to use it to handle IoT event data.
The data simply contains three fields: the station mac address, the device mac address and the timestamp (epoch in ms) when the station received a message from a device. And the data has now been stored in InfluxDB successfully.
Now, I have got such a problem. I want to merge these discrete data into continuous one by the following role:
For each station and for each device, if the time interval of two adjacent records (sort by the _time
field) is great than 5 minutes, the timestamp of former record will become the end time of the one continuous data and the timestamp of the latter one will be the start time of another continuous data.
For example, if the raw data likes:
station device _time
AABB CCDD 2021-08-11T01:00:00Z
AABB CCDD 2021-08-11T01:01:00Z
AABB CCDD 2021-08-11T01:03:00Z
AABB CCDD 2021-08-11T01:11:00Z
AABB CCDD 2021-08-11T01:12:00Z
AABB CCEE 2021-08-11T01:01:00Z
AABB CCEE 2021-08-11T01:11:00Z
BBAA CCDD 2021-08-11T01:00:00Z
BBAA CCDD 2021-08-11T01:01:00Z
then, the expected result may look like:
station device start end
AABB CCDD 2021-08-11T01:00:00Z 2021-08-11T01:03:00Z
AABB CCDD 2021-08-11T01:11:00Z 2021-08-11T01:12:00Z
AABB CCEE 2021-08-11T01:01:00Z 2021-08-11T01:01:00Z
AABB CCEE 2021-08-11T01:11:00Z 2021-08-11T01:11:00Z
BBAA CCDD 2021-08-11T01:00:00Z 2021-08-11T01:01:00Z
I found another post shows how to calculate the time interval. However, I’ve got no idea about how to merge the start
and end
timestamp into one point.