V7.6 Alarm Journal export to CSV

Hi Guys,

Is there an easy way to export the new Alarm Journal table to CSV?

Cheers for any help.

Tim…

You’ll want to use the new scripting function system.alarm.queryJournal() to get information from a specific journal, and then call getDataset() to get the journal information returned as a dataset, since system.dataset.exportCSV() requires a dataset. You would then use exportCSV() as usual:

data = system.alarm.queryJournal(journalName="Journal").getDataset() filePath = system.dataset.exportCSV("data.csv",1,data) if filePath != None: system.net.openURL("file://"+filePath)

Thanks James,

I am finding that I am only getting these headers with no data

EventId, Source, DisplayPath, EventTime, EventState, Priority, IsSystemEvent

I would like to be able to get the filtered data from the displayed Journal thats in the root container with the headers as shown Event Time, Name, Priority, Ack’ed By, Event State…

Cheers

Tim…

1 Like

Hi, I got this script from Robert Mckenzie to export the alarm journal to a .csv using a startdate/end date filter. Maybe others will also find this useful. (now if only we could also print the alarm journal without having to create a report … )

Here’s the script you can put on a button that will print the events of the alarm Journal. Also, you can use the Alarm Journal binding function to populate a dataset in any other component.

get filters

start = event.source.parent.getComponent(‘Alarm Journal’).startDate
end = event.source.parent.getComponent(‘Alarm Journal’).endDate

export the journal to csv

journal = system.alarm.queryJournal(start, end, “Journal”).getDataset()
system.dataset.exportCSV(“data.csv”, 1, journal)

Robert McKenzie
Training and Support Services
Inductive Automation

Is there a SQL query that we can run to return a dataset in the same format as the Alarm Journal object? The queryJournal script is a good start, but I really don’t have any use for the EventId column, and it would be really nice to have the ‘Ack’d By’ column and the Priority expressed as plain text.

claytonic47

this post may be useful, the script can be modified to give you what you want

https://www.inductiveautomation.com/forum/viewtopic.php?f=70&t=12141

Right on, that script looks quite powerful. However, I still can’t get an ‘Ack’ed By’ column. If you examine each AlarmEvent object with getAckData() only the acknowledge event time is returned, not the user who acknowledged it.

I’ve figured out a way to do this with a SQL Query:
(only tested using V7.7.2)

SELECT alarm_events.eventtime as 'Event Time', substring(alarm_events.source,instr(alarm_events.source, "/alm:")+5) as 'Name', alarm_events.displaypath as 'Display Path', REPLACE(REPLACE(REPLACE(alarm_events.eventtype, 0, 'Active'), 1, 'Clear'), 2, 'Ack') as 'Event State', REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(alarm_events.priority, 0, 'Diagnostic'), 1, 'Low'), 2, 'Medium'), 3, 'High'), 4, 'Critical') as 'Priority', IF(propname = 'ackUser', substring(strvalue, instr(strvalue, "/usr:")+5), null) as "Ack'ed By" FROM alarm_event_data inner join alarm_events on alarm_events.id = alarm_event_data.id where dtype != 0 and alarm_events.eventtime > '{Root Container.Alarm Journal.startDate}' and alarm_events.eventtime < '{Root Container.Alarm Journal.endDate}' order by alarm_event_data.id desc
Hope this helps anyone else who might be looking :slight_smile:

1 Like