Create custom Alarm Event Table

To Ignition Alarm Expert:

When an alarm became active, acknowledged or cleared, it will create a new row on Alarm Event Table on Database.

I want to create my own table, for the alarms to be written to, similar to the above.
How do I sense the change of State of any configured alarms. Such that when it change I will do a write query to my custom table in database.

Thank you.

Below is the result of system.alarm.queryStatus

This is not so efficient.
I will need to poll this regularly, check EventId and State. See if it exist on my custom table. If it already exist do not write. If it doesn't exist. Do a write query.

I am looking for, to check if an alarm became active. without polling.

Like how the Journal being populated.
One line when it became active
One line when it was cleared
One line when it was acknowledge.

Oh I got it...

I got two options..
Use Pipeline.. add my Write query on the pipeline..

2nd option. On the Tag's change script, there are an alarm events.. My bad.

Thank you.

Using tag change scripts is more efficient?

I supposed. As it only runs when an alarm occurred.