# Defined alarms in the system

**URL:** <https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696>\
**Category:** Ignition\
**Created:** [September 15, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696 "2020-09-15T15:52:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![latifa.rhandour](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@latifa.rhandour](https://forum.inductiveautomation.com/u/latifa.rhandour)\
**Post date:** [September 15, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/1 "2020-09-15T15:52:24Z")

</div>

Hi,

Is there a way to get the list of all the configured alarms in the system?

The idea is to display in a table the list of defined alarms (with their label) so that users can see all configured alarms.

Thanks in advance for your answers!

Latifa

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [September 15, 2020, 3:59pm UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/2 "2020-09-15T15:59:21Z")

</div>

Hi @latifa.rhandour, this post has a way for obtaining tags with alarms.

> [@List of alarm tags](http://forum.inductiveautomation.com/t/list-of-alarm-tags/9607/2):
>
> Perhaps you could use the [system.alarm.queryStatus()](https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_alarm_querystatus.htm) function and use a wild card to get all the alarms. Best,

Then you could built your dataset with this for displaying in a table.

Edit: [system.alarm.queryStatus - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/system.alarm.queryStatus)

---

<div class="post-metadata">

**Author:** ![latifa.rhandour](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@latifa.rhandour](https://forum.inductiveautomation.com/u/latifa.rhandour)\
**Post date:** [September 16, 2020, 11:32am UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/3 "2020-09-16T11:32:35Z")

</div>

Hi @code_skin , thanks for your answer!  
I thought about using system.alarm.queryStatus() but I’m not sure i can get all configured alarms with this. I think i can only get activeUnacked, activeAcked, clearUnacked, clearAcked …  
So if an alarm never went active it won’t appear in the dataset

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [September 16, 2020, 12:24pm UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/4 "2020-09-16T12:24:54Z")

</div>

> [@latifa.rhandour](#):
>
> but I’m not sure i can get all configured alarms with this.

I use this function often to get all the alarm tags defined in the system.

Try this to see if you can work with it:

- Create a new window,
- drag a button and a power table on the window
- paste the below in the buttons actionPerformed

```auto
alarmTags = system.alarm.queryStatus(source=["*"])
event.source.parent.getComponent('Power Table').data = alarmTags.getDataset()

```

This will return a full list of all tags that have alarms configured regardless of the alarm state.

From the manual:  
`Queries the current state of alarms.`

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 16, 2020, 12:55pm UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/5 "2020-09-16T12:55:56Z")

</div>

> [@Best way to generate an alarm list](http://forum.inductiveautomation.com/t/best-way-to-generate-an-alarm-list/11773/4):
>
> Sorry all… but, I’ve tried to use the queryStatus above to get a list of all alarms, however I only get 27 alarms returned, where there should be hundreds. I ran this in two locations: my local dev environment, no connection to PLCs where I got the 27 alarms; I also ran it on the production gateway where it returned a large number of alarms. I’m now not confident the “full” alarm list that I gave the customer using this function is in fact a full list at all… Why would these results be differen…

I found that using statusquery didn't get a full list. I don't think I ever was able to get a full list...  
Or maybe I had to use system.tag.browse for it or the other config one?

---

<div class="post-metadata">

**Author:** ![ali.khalil](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ali.khalil/32/18169_2.png) [@ali.khalil](https://forum.inductiveautomation.com/u/ali.khalil)\
**Post date:** [September 16, 2020, 1:01pm UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/6 "2020-09-16T13:01:24Z")

</div>

Hi Latifa,

I think you can achieve your requirement by combining:

- [system.tag.browseTags](https://docs.inductiveautomation.com/display/DOC79/system.tag.browseTags)
- [system.tag.getAlarmStates](https://docs.inductiveautomation.com/display/DOC79/system.tag.getAlarmStates)

In this example I am writing the results to a Dataset type tag, of course you can get more information / props if you need.

```auto

# This function was designed to run from a Gateway Scoped call. Client based calls (such as those triggered by a button press) should search in an asynchronous thread.
  
# Define the search as a function. This makes recursion easier.
def manualSearch(initPath):
     
    # If troubleshooting, you could print out the initPath here
     
    # Create a result set of just tags. This call could be modified to look for a specific sub of tags,
    # such as just UDT instances
    tagSet = system.tag.browseTags(parentPath = initPath, tagPath = '*',                                   
                                    recursive=False)
     
    # Create a result set of just folders. We'll iterate over this set and call browseTags() again for the results.                                             
    folderSet = system.tag.browseTags(parentPath = initPath, tagPath = '*',
                                        tagType = 'Folder',
                                        recursive=False)
                                         
    # Iterate through our folders...                                  
    for folder in folderSet:
     
        # If troubleshooting, you also could print out folder.path here.
         
        # ...And start the process over again until we run out of folders.
        tagSet+=manualSearch(folder.fullPath)
     
    # Return the list of tags.
    return tagSet
 
# Call this on the manual tag provider. Change the intialPath here if searching through a specific Tag Provider.
myTags = manualSearch("[Sample_Tags]")

idx=0
headers=["ID","Alarm"]
data=[]
for myTag in myTags:
	
	try:
		tagDefs = system.tag.getAlarmStates(str(myTag))
		for tagDef in tagDefs:
			idx=idx+1
			AlmDef= tagDef.alarm
			data.append([idx,AlmDef])
	except:
		pass
print idx
AlmSet = system.dataset.toDataSet(headers, data)
system.tag.write("[Sample_Tags]AlmDefs",AlmSet)

```

---

<div class="post-metadata">

**Author:** ![latifa.rhandour](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@latifa.rhandour](https://forum.inductiveautomation.com/u/latifa.rhandour)\
**Post date:** [September 22, 2020, 9:07am UTC](https://forum.inductiveautomation.com/t/defined-alarms-in-the-system/38696/7 "2020-09-22T09:07:35Z")

</div>

That worked perfectly! Thanks a lot!
