# Alarm Journal Export

**URL:** <https://forum.inductiveautomation.com/t/alarm-journal-export/102512>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [February 18, 2025, 7:40pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512 "2025-02-18T19:40:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asjal\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Asjal\_Ahmad](https://forum.inductiveautomation.com/u/Asjal_Ahmad)\
**Post date:** [February 18, 2025, 7:40pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/1 "2025-02-18T19:40:47Z")

</div>

I am trying to export the Alarm Journal data into a csv in an efficient manner, as outlined in this post. I'm using Vision.

> [@Alarm Journal CSV export](https://forum.inductiveautomation.com/t/alarm-journal-csv-export/58100/2):
>
> The right way to do it would be to issue your own system.alarm.queryJournal call to match the filters on the component, which gives you access to the same underlying data. The more efficient, but not directly supported way, would be to get a reference to the underlying table component inside the AJT component, then extract it’s model, which will have a getAlarmAt(row) field (and getRowCount() method), which would give you full access to the reconstructed alarm event and allow you to pull whatev…

I went through the javadocs, but I'm unable to get a reference to the model that I can use a `getAlarmAt(int row)` method. How can I get to that method using my reference to the Alarm Journal table?  
`alarm_journal= event.source.parent.getComponent('Alarm Journal')`

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 22, 2025, 5:56pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/2 "2025-02-22T17:56:19Z")

</div>

> [@Asjal\_Ahmad](#):
>
> How can I get to that method using my reference to the Alarm Journal table?

The model is buried deep in the journal component, and I'm not sure if it can be accessed directly.

However, it can be accessed through the journal's subcomponents. I threw this script together on a test button, and it works:

```python
# Returns the first nested component of a given class
# container = The object containing nested components to be recursively searched
# className = the __name__ of the class given as a string
def getComponentOfClass(container, className):
	for component in container.components:
		if component. __class__. __name__ == className:
			return component
		else:
			foundComponent = getComponentOfClass(component, className)
			if foundComponent:
				return foundComponent

# Find the inner table in the alarm journal component
alarmJournal = event.source.parent.getComponent('Alarm Journal')
innerTable = getComponentOfClass(alarmJournal, 'AlarmJournalTable$3')

# Define the parameters needed to convert the table model to an Ignition dataset
data = []
headers = [innerTable.getColumnName(column) for column in xrange(innerTable.columnCount)]

# Extract the row data from the inner table
# If any special filters are needed, do it here in the for loop
for row in xrange(innerTable.rowCount):
	data.append([innerTable.getValueAt(row, column) for column in xrange(innerTable.columnCount)])

# Create the journal data to an Ignition dataset and export it as a CSV
dataset = system.dataset.toDataSet(headers, data)
system.dataset.exportCSV('journalData', True, dataset)

```

The script simply digs the inner table out, retrieves the data, and converts it to an extractable Ignition dataset.

Out of curiosity. what is the reason for not constructing an [alarm query call](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-alarm/system-alarm-queryJournal)? It seems like that approach would be simpler.

---

<div class="post-metadata">

**Author:** ![Asjal\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Asjal\_Ahmad](https://forum.inductiveautomation.com/u/Asjal_Ahmad)\
**Post date:** [February 24, 2025, 9:04pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/3 "2025-02-24T21:04:18Z")

</div>

Thank you for your solution! I was just hoping if I could find a way to directly access the table without having to make the query. The table is already being displayed on the page. Having to do another query seemed redundant, and even your solution also involves constructing the dataset in an O(n) manner. I guess I'll have to do it anyway.

Regardless, thanks a lot! Your solution helps me understand the underlying model, which I could not figure out earlier.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 24, 2025, 10:43pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/4 "2025-02-24T22:43:57Z")

</div>

Untested, but should work.

```python
from org.apache.commons.lang3.reflect import FieldUtils

alarmJournal = event.source.parent.getComponent('Alarm Journal')

model = FieldUtils.readField(alarmJournal, "model", True)
data = FieldUtils.readField(model, "data", True)
ds = data.getDataset()

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 24, 2025, 10:53pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/5 "2025-02-24T22:53:14Z")

</div>

> [@paul-griffith](#):
>
> Untested

```python
`system.dataset.exportCSV('journalData', True, ds)`

```

🕶🕶🕶 trick  
I added the export line of code and **tested it** , and it works perfectly

---

<div class="post-metadata">

**Author:** ![danny.lazaro](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danny.lazaro/32/79188_2.png) [@danny.lazaro](https://forum.inductiveautomation.com/u/danny.lazaro)\
**Post date:** [June 20, 2025, 10:30pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/6 "2025-06-20T22:30:02Z")

</div>

> [@paul-griffith](#):
>
> `org.apache.commons.lang3.reflect`

Would this work in ignition?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 23, 2025, 3:00pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/7 "2025-06-23T15:00:26Z")

</div>

Can you rephrase the question? Basically every piece of code I share on these forums is for use in Ignition.

---

<div class="post-metadata">

**Author:** ![danny.lazaro](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danny.lazaro/32/79188_2.png) [@danny.lazaro](https://forum.inductiveautomation.com/u/danny.lazaro)\
**Post date:** [June 24, 2025, 5:50am UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/9 "2025-06-24T05:50:16Z")

</div>

Sorry, I meant to say ignition perspective.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 24, 2025, 4:04pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/10 "2025-06-24T16:04:59Z")

</div>

Then no. Perspective's component model is fundamentally different and more 'locked away' from you than Vision's.

Could you describe what you're _trying to do_ (probably in a new forum thread; this post is explicitly about the Vision component) and we can offer advice to help you reach that goal?

---

<div class="post-metadata">

**Author:** ![danny.lazaro](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danny.lazaro/32/79188_2.png) [@danny.lazaro](https://forum.inductiveautomation.com/u/danny.lazaro)\
**Post date:** [June 24, 2025, 8:46pm UTC](https://forum.inductiveautomation.com/t/alarm-journal-export/102512/11 "2025-06-24T20:46:37Z")

</div>

Sure! I was trying to do an export of the Alarm Journal in Perspective. It works but I still have some questions about the export. Check this post: [The EventState column returned by system.alarm.queryJournal - does it represent the EventType/State or the Event State - Ignition - Inductive Automation Forum](https://forum.inductiveautomation.com/t/the-eventstate-column-returned-by-system-alarm-queryjournal-does-it-represent-the-eventtype-state-or-the-event-state/107641)

P.S. Apologies for the long title.
