Detailed alarm log to csv

Hi,
I'm trying to export the Vision alarm log to a csv file but I'm stuck trying to add additional details beyond the standard dataset returned by:

results = system.alarm.queryJournal(journalName="Journal")

I know I can get additional properties from an individual alarm object with:

results[0].label

for example, but I not sure what the most efficient way is of adding those to the list of AlarmEvent objects returned by queryJournal, prior to exporting it all to a csv.

Any help would be appreciated!

I'm not sure I completely understand what problem you are trying to solve. The additional properties are already a part of dataset, what are you trying to add?

Can you provide any code that shows what you've tried and explain what you expected and what the issue was with the actual result that was not what you expected?

For this alarm in the journal:

image

The following code:

results = system.alarm.queryJournal(journalName="AlarmJournal", startDate=system.date.addMinutes(system.date.now(),-1), endDate=system.date.now())

print results[0]
print results[0].label

csv = system.dataset.toCSV(results)

filePath = system.file.saveFile("myExport.csv", "csv", "Comma Separated Values")

if filePath:
    system.file.writeFile(filePath, csv)

Returns this in the console:

Event[name=Changed, source=prov:default:/tag:GlobalVars/BH1_setpoint_min:/alm:Changed, priority=Diagnostic, desc=null]
Changed

And this in the .csv file:

"value"
"[{Source: 'prov:default:/tag:GlobalVars/BH1_setpoint_min:/alm:Changed', Display Path: 'BH1_setpoint_min', UUID: '84408903-9ca4-43e3-b606-fbc37c724018', Current State: 'Active, Acknowledged', Priority: 'Diagnostic', Active Data: {ackUser=tag:Auto-Ack, systemAck=true, eventTime=Fri Mar 21 08:39:10 NZDT 2025}, Clear Data: null, Ack Data: {ackUser=tag:Auto-Ack, eventTime=Fri Mar 21 08:39:10 NZDT 2025}, Runtime Data: {eventState=Active, eventTime=2025-03-21 08:39:10.0}}, {Source: 'prov:default:/tag:GlobalVars/BH1_setpoint_min:/alm:Changed', Display Path: 'BH1_setpoint_min', UUID: 'da5a9dd0-10f0-420d-836e-aa85ad64d41a', Current State: 'Active, Acknowledged', Priority: 'Diagnostic', Active Data: {ackUser=tag:Auto-Ack, systemAck=true, eventTime=Fri Mar 21 08:39:19 NZDT 2025}, Clear Data: null, Ack Data: {ackUser=tag:Auto-Ack, eventTime=Fri Mar 21 08:39:19 NZDT 2025}, Runtime Data: {eventState=Active, eventTime=2025-03-21 08:39:19.0}}]"

But what I really want is the label property from here:

As circled in red in the top image.

I'm also bit confused because print results[0].label seems to return the name property rather than the label property I'm after...

In any case I just want to include the real label property "BH1 band control min limit set to 116 C" in the csv output as that gives the most information about what the alarm actually represents.

Thanks for your help :slight_smile:

Well, in the SDK it states that getLabel() Returns the "Label" property, or "Name" if not defined.

Which, since, it is clearly defined, is confusing and I would say this looks like potentially a bug.

That being said, you would need to add a column to the dataset. Something like this:

results = system.alarm.queryJournal(journalName="AlarmJournal", startDate=system.date.addMinutes(system.date.now(),-1), endDate=system.date.now())

labelColumn = [result.label for result in results]
resultsDS = results.dataset
resultsDS = system.dataset.addColumn(resultsDS,labelColumn,"Label",str)

csv = system.dataset.toCSV(results)

filePath = system.file.saveFile("myExport.csv", "csv", "Comma Separated Values")

if filePath:
    system.file.writeFile(filePath, csv)

I would recommend that you reach out to IA support and have them look over your shoulder and determine if this is a bug or if something else is going on.

Thanks heap, that's really helpful

Is your alarm journal set up to store dynamic config? That's the default, but could have been changed:

Without that setting checked, your journal query will not have any stored label to return to you.

2 Likes

PGriffith, yes the Dynamic Config is stored:

I hadn't thought to check that so thanks!