Get all events within a time range

Hi all,

what would be the best way to get events within a time range?

I get events from machines (state running/not running).
From an ui i get start and end times together with some context.
Now i want to have the sum of all time intervalls where machine state is running within that given time range.

1st Idea: writing a fish that just stores the events in an array together with the timestamp.
I’m afraid that perfomance would be bad if i have a lot of events.

2nd idea: using to read events into memory

Any suggestions?



Hi Michael,

the important question here is whether start and end time are part of one single event per timespan, or whether each event shall end the old and start a new timespan. In the latter case I’d queryAql() all interesting events and reduce them to your wanted sum while processing the result. In the former case you can even do the whole shebang in AQL using a query like the following:

FEATURES(timeRange aggregate)
FROM 'my-tags' & from(2021-10-01T00:00) & to(2021-10-01T12:00)
FILTER _.state = "running"
AGGREGATE SUM(_.end - _.start)

(assuming that start and end are numbers, e.g. microseconds since the Unix epoch)



Hi Roland,

thanks for the input.

AQL is available only in Actyx 2.0, right?
We’re using Actyx 1, I guess it’s time to update …


Ah, yes, that’s right. And the features I used above are only in the latest versions of Actyx and Node Manager (plus I forgot that aggregate is still an alpha feature, so it needs the zøg pseudo-feature in addition). The usage above is reasonably stable, but there is no strict guarantee that aggregation in general won’t still change regarding syntax and precise functionality.