# How to get active alarm count of all tags in a folder?

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [October 14, 2023, 2:08pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484 "2023-10-14T14:08:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [October 14, 2023, 2:08pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/1 "2023-10-14T14:08:12Z")

</div>

I would like to get a count of all active alarms (both ack and non-ack) in tags in a particular folder called "FAB". I have one alarm that is set to true and it is flashing on the standard alarm table in my HMI so I know the alarming is working.  
But the tag path filter seems to be broken or I am using it wrong as it always returns zero alarms unless I make the tagpath filter = "\*".

This code returns 0

```auto
pathValue = "[default]FAB/*"
alms = system.alarm.queryStatus(path = pathValue, state = [2,3])
print len(alms)

```

this code returns 1

```auto
pathValue = "*"
alms = system.alarm.queryStatus(path = pathValue, state = [2,3])
print len(alms)

```

I have tried many version of the pathValue string and nothing seems to work.  
What am I doing wrong ?

Note: the path to the tag that has the alarm associated with it is:  
[default]FAB/Pos\_1110\_Drive/OLFault

My next step is to put this value in a tag that continuously updates. What is best practice for this ?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 14, 2023, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/2 "2023-10-14T18:08:29Z")

</div>

> [@jimschaefer](#):
>
> `system.alarm.queryStatus`

Try the path without the tag provider,  
[https://docs.inductiveautomation.com/display/DOC81/system.alarm.queryStatus](https://docs.inductiveautomation.com/display/DOC81/system.alarm.queryStatus)

There are a few exchange resources you could peak at, one here,

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2392/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

---

<div class="post-metadata">

**Author:** ![schenk](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@schenk](https://forum.inductiveautomation.com/u/schenk)\
**Post date:** [October 14, 2023, 6:27pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/3 "2023-10-14T18:27:32Z")

</div>

If you do need the provider included, you can use a path (or source) like this `'prov:default:/tag:FAV/*'`

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 14, 2023, 6:38pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/4 "2023-10-14T18:38:20Z")

</div>

Or use the provider parameter.

List[String] provider - A list of tag providers to include in the query. Omitting this parameter will query all providers. [optional]

---

<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:** [October 16, 2023, 10:03am UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/5 "2023-10-16T10:03:42Z")

</div>

Note, you should _never_ call system.alarm.queryStatus from within a Vision client unless you want performance issues as this is a slow function and all scripts in Vision run in the gui thread so will lock up the interface. You didn't tag your post so not sure what you're using

---

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [October 16, 2023, 12:19pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/6 "2023-10-16T12:19:30Z")

</div>

Thanks for tip. I am hoping to create a global expression tag that contains the alarm count for various machines and areas in a factory. The vision clients only read the tags.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 16, 2023, 12:19pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/7 "2023-10-16T12:19:57Z")

</div>

> [@nminchin](#):
>
> should _never_ call system.alarm.queryStatus from within a Vision client

It is safe to call from an asynchronous function, triggered from a client timer event, and writing results to a client tag. Everything else in the Vision client should reference the client tag.

---

<div class="post-metadata">

**Author:** ![jimschaefer](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jimschaefer](https://forum.inductiveautomation.com/u/jimschaefer)\
**Post date:** [October 16, 2023, 2:52pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/8 "2023-10-16T14:52:57Z")

</div>

This worked. Thanks

Gets the count of all active acked and unacked alarms in the folder "FAB" from the default provider.

```auto

pathValue = "prov:default:/tag:FAB/*"
alms = system.alarm.queryStatus(source = pathValue , state = [2,3])
count = len(alms)

```

---

<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:** [October 16, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/9 "2023-10-16T19:31:53Z")

</div>

If you're going to do that though, wouldn't you just write to a standard tag so you're not doing this for every client?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 16, 2023, 7:36pm UTC](https://forum.inductiveautomation.com/t/how-to-get-active-alarm-count-of-all-tags-in-a-folder/80484/10 "2023-10-16T19:36:35Z")

</div>

Yes, unless there is a per-client difference in how the query is called.
