Tags with alarms listing from database query

Forgive me if this has been asked before…I couldn’t find this question posted previously and did not figure it out browsing the database tables.

I would like to use a SQL query to obtain a listing of tags configured with alarms (we are re-evaluating our priority scheme and desire to utilize Excel spreadsheets for analysis).

I’ve very comfortable with SQL…just need to know where this information is located within the Ignition schema.,

Thanks in advance for any assistance!


It’s not. Or rather, it’s in Ignition’s internal DB, not any DB connection. The supported way to get comprehensive information about tags would be to export the entire tag hierarchy as XML. From the designer’s tag browser.

Its not easy to get. You could export as @pturmel said, however if you use any bindings for priority, enabled etc - they will not be evaluated. I’ve been trying to do something like this for a while and unfortunately haven’t found something reliable that will find all alarms, enabled or not, and will give their evaluated statuses.

seems like you could use a combination of the browseTags and getAlarmStates functions to accomplish what you want. But like what was said already, if you have a binding on your priority, that will be an issue.

Here is a start for you…

tags = system.tag.browseTagsSimple("5000-003","ASC")
for tag in tags:
		tagDefs = system.tag.getAlarmStates(tag.path)
		for tagDef in tagDefs:    
		    for prop in tagDef.getAlarmProperties():
		    	if prop.property == 'priority':
		    		print tag.path, tagDef.alarm, prop.value
		print tag

Thanks for the answers. I did try a tag export but did not see a field which would denote an alarm is set on the tag. Rather, I see a complete tag listing. How would I filter this so I can work with just tags with alarms?

Thanks again,


Thank you. While I am good with SQL I’m still learning scripting with Ignition. Where would I run this code to get output?

Sorry for the newbie question. I appreciate your patience!


I built it in the script console, but you can run it on a button if you want to do other stuff. You could easily modify to put everything into a dataset and put into a table… or export as a csv.

I would start out by just trying one folder at a time. Replace 5000-003 with your folder name.

Thanks again. I do get output this way but don’t see anything which would denote the priority field. We’re trying to make better use of the priorities for report and messaging purposes, and it would be of great help to see what tags are alarmed and if alarmed…what priority they might be…

Is this something I should be perhaps contact support about?

You should see an output like this, tagname, alarm name, then priority. I put apostrophe to kind of show the breaks.

‘5000-003/Volts’ ‘High High Alarm’ ‘Critical’
‘5000-003/Volts’ ‘Low Low Alarm’ ‘Critical’
‘5000-003/Volts’ ‘Low Alarm’ ‘High’
‘5000-003/Volts’ ‘High Alarm’ ‘High’

Ahh…I see it now! I added “,” to your print statement to further assist in a Excel copy/paste.

I wonder how difficult it would be start at the tag root folder and iterate through the entire tag tree?

Thank you again!!

how many tags do you have? shouldnt be hard. look at the documentation for the scripting system.tag.browseTagsSimple and it should explain what to do.

I have around 2,400 tags…although many of them are not alarmed. I’ll look through the literature (with your suggestion) and work through it. I’m also planning on speaking with support to perhaps find the ‘best’ way to do this.

I’ll report back on our progress. Thank you.

that shouldnt be bad. It would probably take 5-10 minutes to run the script.

For everyone’s future reference, I worked with Kevin at Inductive and we (he) came up with this script which does what I asked. Simply replace the sample file path with your own. This script outputs a CSV file.

Many thanks for all the help here…much appreciated!!

import xml.etree.ElementTree as ET

def DFS(root, tagpath):

	if 'path' in root.attrib and 'name' in root.attrib:
		name = root.attrib['name']
		path = root.attrib['path']
		if path != "": tagpath += path + '/'
		if name != "": tagpath += name + '/'
		for child in root:
			DFS(child, tagpath)

	elif root.tag == "Alarms":
		for alarm in root:
			alarmName = alarm.attrib['name']
			alarmPriority = 1	
			# If the alarm doesn't have a priority property,
			# it's implied to have an priority of 1
			for prop in alarm:
				if prop.attrib['name'] == 'priority':
					alarmPriority = int(prop.text)
			data.append([tagpath, alarmName, alarmPriority])
def recurse(root):
	for child in root:
		DFS(child, '')
filepath = r"**C:\Users\sample_user\Documents\tags_all.xml**"
tree = ET.parse(filepath)
root = tree.getroot()

header = ['tag Path', 'alarm', 'priority']
data = []


dataset = system.dataset.toDataSet(header, data)
system.dataset.exportCSV('alarm priorities.csv', 1, dataset)

I’m interested in this but I think your formatting got messed up after def recurse(root), could you take a look? Looks like the two lines after that should be indented, is that correct?

I just edited it for you @jkelleyus. Instead of using Blockquotes you just needed a triple back quote before and after the snippet.

1 Like

Thank you, sir!!! Appreciate the help and advice…

I’m trying to run this on a tag export from a 8.04 system. The script runs and creates the xml file but it is empty with the exception of the header columns. I see in the export that the “Alarms” property is listed as a Compound Property. Is this causing my empty file perhaps?

1 Like