Active Alarm count by priority

How can I count the active alarm amount by tag?
If I use the Gateway Event Scripts to count it but all the tagwrite history will be record in audit log.
Is there any other way to count it ?

This is my code

tagProvider = "default"
unackactiveTags = []
unackactiveCounts = []

Name = 'Alarm'
unackactiveCounts.append(len(system.alarm.queryStatus(state=["ActiveUnacked"], priority=["Medium"], Name = Name)))

#system.tag.writeBlocking(unackactiveTags, unackactiveCounts)
system.tag.writeBlocking("[PUB]SCADA/Alarm/ALM_COUNT_UNACKACTIVE_MAINTENANCE", unackactiveCounts)

You could set up an alarm journal, and use SQL queries to get the data you need.

To be honest I use the Ignition Exchange page:

And just modified the perspective pages to make it more like what we need with extra statistics.

Thank you for your reply!

What are the script need to change?