# List of All Historical Tags

**URL:** <https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594>\
**Category:** Ignition\
**Created:** [November 16, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594 "2022-11-16T17:09:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 16, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/1 "2022-11-16T17:09:06Z")

</div>

New to Ignition so I apologize if this is an easy one...

I have an Ignition SCADA delivered from the vendor and want to get a full list of the tags used that are configured for Tag History. I can't seem to find a way to do this in the Designer as the tag export doesn't give the history parameters.

Is there a way to list all the tags that have "History Enabled" and ideally what the history parameters are? I have thousands of tags so going manually through the Tag Browser will take years.

---

<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:** [November 16, 2022, 6:14pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/2 "2022-11-16T18:14:48Z")

</div>

If you upgrade to 8.1.19 or newer, you can use the Tag Report Tool:  
[https://docs.inductiveautomation.com/display/DOC81/Tag+Report+Tool](https://docs.inductiveautomation.com/display/DOC81/Tag+Report+Tool)

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 16, 2022, 6:48pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/3 "2022-11-16T18:48:01Z")

</div>

Thanks for the quick reply. Any chance this tool is available outside the designer (separate app), I'm stuck at version 8.1.2?

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [November 16, 2022, 6:53pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/4 "2022-11-16T18:53:34Z")

</div>

I think this gets all the tags with historian enabled, but there may be corner cases I didn't account for. It may choke on large tag trees, so use cautiously.

```auto
seedPath = '[default]'
def browseRecursive(path, results=[]):
	browseResults = system.tag.browse(
		path,
		{}
	).getResults()
	for i in browseResults:
		results.append(i)
		if i['hasChildren']:
			browseRecursive(i['fullPath'],results)
		
	return results

asdf = browseRecursive(seedPath)
allTheTuples = []
for i in asdf:
	try:
		for j in i['attributes']:
			allTheTuples.append((i['fullPath'],j.getId()))
	except:
		pass

for i in allTheTuples:
	if i[1] == 'history':
		print i[0]

```

---

<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:** [November 16, 2022, 6:58pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/5 "2022-11-16T18:58:35Z")

</div>

Perhaps this version didn't have recursive browse that was actually usable (I can't remember when it was fixed), but this work around recursive browse was _extremely_ slow (like using Windows file Explorer to search for files), so others finding this in later versions **should not use it!**.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [November 16, 2022, 7:15pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/6 "2022-11-16T19:15:59Z")

</div>

Ignition Version 8.1.17  
Tag tree: 5885 (including folders, UDT types, UDT sub-members, etc.)

This script took the following times over 9 runs:

```auto
Time (ms)
796
805
805
791
792
830
747
803
796
830
Average = 799.5

```

As @nminchin said, other versions may perform differently.

You can set `seedPath` to a smaller folder if you want to test performance before running against your whole tree. I always copy the tag tree to a development gateway before I do any work (like running this script), so long-running scripts, though annoying, aren't an existential threat to production.

---

<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:** [November 16, 2022, 7:19pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/7 "2022-11-16T19:19:02Z")

</div>

800ms is huge for only 5000 tags. I ran it on 400k tags at one stage and it took many seconds from memory

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [November 16, 2022, 7:27pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/8 "2022-11-16T19:27:24Z")

</div>

I agree that it's far from optimum. I wouldn't run it in a production setting, but it may be worth using as a one-off on a development gateway. For history specifically, you could probably do a similar thing with `system.tag.getConfiguration` and track where historyEnabled is present and true.

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 16, 2022, 7:56pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/9 "2022-11-16T19:56:15Z")

</div>

I ran the script, my Tag Provider has about 50000 tags and it took about 20 seconds.

It listed out all the tags but only their names - hoping to get details on history (enabled, deadband, tag group, etc.)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 16, 2022, 9:02pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/10 "2022-11-16T21:02:07Z")

</div>

If you have access to the SQL tables you can select the tags from there, build a tag list and then do a system.tag.read and parse that out.

For only active tags you could do

```auto
SELECT [tagpath]
  FROM [sqlth_te]
  WHERE [retired] IS NULL
  ORDER BY tagpath

```

To get tags that have history but were retired

```auto
SELECT DISTINCT [tagpath]
  FROM [sqlth_te]
  ORDER BY tagpath

```

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 16, 2022, 9:21pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/11 "2022-11-16T21:21:57Z")

</div>

I did this originally but unfortunately the DB doesn't have the history config info.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [November 16, 2022, 9:29pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/12 "2022-11-16T21:29:09Z")

</div>

You can use [system.tag.getConfiguration](https://docs.inductiveautomation.com/display/DOC81/system.tag.getConfiguration) in a script to get the configuration.

---

<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:** [November 16, 2022, 9:35pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/13 "2022-11-16T21:35:39Z")

</div>

fwiw, this is what I use to find tags with history:

```auto
# Description:
# Get list of historical tags from Ignition. Writes csv list into clipboard.

from java.lang.System import nanoTime as nt
t = [nt()]
tags = system.tag.browse(path="[default]", filter={"recursive": True, "valueSource": "opc", "tagType": "AtomicTag"})
t.append(nt())

# remove tags in UDT definitions
tags = [tag['fullPath'] for tag in tags if "_types_" not in str(tag['fullPath'])]

tagsHistEnTags = ['{}.historyEnabled'.format(tag) for tag in tags]
tagsHistEnTagVals = system.tag.readBlocking(tagsHistEnTags)
t.append(nt())

histTags = [tag for tag, en in zip(tags, tagsHistEnTagVals) if en.value == True]

print 'Tag count: ', len(histTags)

csv = '"TagPath"'
for tag in histTags:
	csv += '\r\n"{}"'.format(tag)

### REQUIRES MY shared.util.clipboard LIBRARY
shared.util.clipboard.writeText(csv)
print 'Time taken: ', (t[-1]-t[0])/1000000000.0, 's'

```

---

<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:** [November 16, 2022, 9:39pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/14 "2022-11-16T21:39:21Z")

</div>

And, if you want to read a selection of properties from tags, I use this below. You could merge this into the script above to read all of the history properties of the tags found.

```auto
# Date: 2022-10-19
"""
Description:
	Finds tags and reads a list of properties for them. Returns a CSV of tagPaths and their property values into the clipboard.
"""
# SETUP
REMOVE_TAGS_IN_UDTS = True # set to True to remove tags found that are inside of UDT instances
path = '[default]' # the tag path to search for tags in
readProps = [] # the tag properties to read
readProps.append('opcItemPath')
readProps.append('enabled')
readProps.append('engUnit')
readProps.append('formatString')
readProps.append('scaleMode')
readProps.append('engLow')
readProps.append('engHigh')
readProps.append('rawLow')
readProps.append('rawHigh')
readProps.append('scaledLow')
readProps.append('scaledHigh')
######

tags = system.tag.browse(path = path, filter={'recursive': True, 'tagType': 'AtomicTag'})

if REMOVE_TAGS_IN_UDTS:
	udts = system.tag.browse(path=path, filter={'recursive': True, 'tagType': 'UdtInstance'})
	tagPaths = [str(tag['fullPath']) for tag in tags if not any(str(udt['fullPath']) in str(tag['fullPath']) for udt in udts)]
	print len(tags)-len(tagPaths), 'tags removed that were part of UDT instances.'
else:
	tagPaths = [str(tag['fullPath']) for tag in tags]

### filter the tag paths if required ###
#tagPaths = [path for path in tagPaths if 'Unit Parameters' in path]

print 'Number of tags: ', len(tagPaths)

allVals = [tagPaths]
for prop in readProps:
	paths = ['{}.{}'.format(tag, prop) for tag in tagPaths]
	vals = system.tag.readBlocking(paths)
	vals = [val.value for val in vals]
	allVals.append(vals)

csv = '"' + '","'.join(['tagPath'] + readProps) + '"\r\n'
csv += ''.join('"' + '","'.join(map(str, row)) + '"\r\n' for row in zip(*allVals))

### REQUIRES MY shared.util.clipboard LIBRARY
shared.util.clipboard.writeText(csv)
print 'Copied to clipboard.'

```

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 16, 2022, 9:52pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/15 "2022-11-16T21:52:31Z")

</div>

Thanks for the above code, working with it now to suit my application but I get an error with running it with the clipboard line (InputError: No module named share)

---

<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:** [November 16, 2022, 9:54pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/16 "2022-11-16T21:54:22Z")

</div>

My `shared.util.clipboard` library is needed which i've posted in other topics. just remove that if you don't want to copy to clipboard and just write to the console with `print` instead

---

<div class="post-metadata">

**Author:** ![hmiCanuck](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hmiCanuck](https://forum.inductiveautomation.com/u/hmiCanuck)\
**Post date:** [November 16, 2022, 10:56pm UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/17 "2022-11-16T22:56:42Z")

</div>

@nminchin

Just wanted to say thanks for the scripts - got everything working great now.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 17, 2022, 9:45am UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/18 "2022-11-17T09:45:06Z")

</div>

You could initialize your list upon declaration:

```python
readProps = [
    "opcItemPath",
    "enabled",
    ...
]

```

Or is there a reason you're using `append` ?  
I find it more readable this way, maybe you don't ?

---

<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:** [November 17, 2022, 10:12am UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/19 "2022-11-17T10:12:03Z")

</div>

Maybe I'm strange, but I tend to prefer using append as it's then consistent how you add elements to the list if you were to add elements down further in the script. Instead of declaring it like you did and then swapping to using append later on 🤷‍♂️

Either way obviously works though. PyCharm always has a whinge at my way of doing things and offers to convert it to your way, haha

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 17, 2022, 10:18am UTC](https://forum.inductiveautomation.com/t/list-of-all-historical-tags/66594/20 "2022-11-17T10:18:54Z")

</div>

Well I pretty much never use `append`, so here's that.

I should try PyCharm some day...
