How to know active alarms one day in the past

Hello.

How could I known active alarms one day in the past? I’m using ignition 7.9.9.

system.alarm.queryJournal gets the changes in the state. But if there’s an alarm that is active from the previous days and doesn’t change this day, queryJournal doesn’t get it.

In fact, the report I have to do is: what alarms and how many occurrences there were each alarm one day in the past, and how many time was active each one this day. But the first step is to known what alarms there where one concrete day in the past.

Thank you.

You might have to do both queries: one on the journal and one on the current, then filter out the current for those that started or were active yesterday.

Thank you for the response.

This is valid for today. But one day in the past can be a day of the past year. So I cannot use current, right? Or I’m wrong?

Im not really sure what you’re getting at, but If an alarm stays active and is never cleared, (I dont think) it will ever make it into the journal.
To get the alarms that were active yesterday however, you will still be able to do an alarmStatus query and filter out alarms after yesterday, and add the remaining to the journal alarms from yesterday.

Mmm. I want to know active alarms on December 2, 2019, for example.

There’s no problem with alarms that have changes on this day. But maybe there were alarms that becomes active on November 30, 2019 and were cleared on December 10, 2019.

If you use a journal query that includes active unack’d alarms (or whichever state it was in) for that date, 2nd December, then it should return the active alarm that first became active in November. Have you tried this?

Thank you for your time nminchin.

I made a journal query in one day including all four alarm states and only returns alarms that changed its state on that day. Active alarms from previous days that remain active in that day doesn’t appear.

So, is not possible to known what alarms where active one particular day of the past? Only what alarms changed its state?

Interesting, I haven’t actually tried it myself. You might need to query the journal sql table yourself, using an SQL query and the system.db.runPrepQuery function.
But that sounds like a bug to me, @PGriffith?

Sorry by my insistence in this post but I’m a bit frustrated with alarms. I’m searching in forum about querystatus and queryjournal and I found some posts without a clear response or maybe too old.

If I make a queryStatus I get something very similar to queryJournal output. In fact, the doc says

" *details for when the alarm became active, acknowledged, and cleared are combined into a single item. This differs from system.alarm.queryJournal() which splits these events into separate items."

But I have registers (with dataSet) with only one event time and a state. And various register with different timestamps for the same alarm. I read in a forum post of 2015 something like there’s more than one state in a register (like docs says) but not my current output.

The output for queryJournal and queryStatus are very similar (like I read in some other forum post). In queryStatus I have registers with alarm events for previous days. I supose in queryJournal there are more aged values than in queryStatus?

Such a simple request like know what alarms were active each day of the past year, seems as difficult as rebuild all alarm events from january… Maybe there’s an alarm that was active on january that remained active for example until june (I’m exaggerating to show clearly my doubt). This alarm is not shown in a queryJournal of march. Is like I’m explainning or I’m already a bit obfuscated with alarms?

Thank you.

That’s expected behavior, because there’s literally nothing else to return in that case. If an alarm event hasn’t triggered in a given time range, then there simply is no way to know what state it’s in without widening the time range. What else would the function do? Returning a default state for unknown would itself be inaccurate/misleading.

When nminchin said that maybe was a bug, I thought that maybe was a design decisition. I understand the problem and I understand that if it returns events, are events.

But if I have some thousands of alarms and my client now wants to know what alarms were active one day and how many time in the past year, I wanted to know if the only way to calculate it is to start from january rebuilding each day to be sure that I’m showing all alarms that were in march, and that it was not a simple query to queryjournal. So, I understand I have to rebuild all alarm events from january.

Thank you.

I think I will save in a table what alarms remain active at the end of each day. With this info and queryjournal it will be more feasible to know what alarms were active one concrete day in the past and how many time.