Audit the historian for most active tags

I’m looking for a simple way to identify which tags log the most data to the historian. This is for a large system, north of 10k historian tags.

It’s easy enough to spot check an individual tag using system.tag.queryTagCalculation() and get a count for a time range. For instance, I can check if a tag logs 2 values/hour or 2000 values/hour and adjust history configurations accordingly. I could take it a step farther and iterate through all of my tags, but this feels like a messy approach (not to mention would take a good long while to run).

Does anyone have a more comprehensive or efficient method that’s worked for them? Perhaps something that can be run as a report or query? :crossed_fingers:

Quick spot check could be something like

SELECT
tagid, count(tagid) as cnt
FROM
[sqlt_data_********]
group by tagid

Replace [sqlt_data_********] with the name of one of your history tables.

1 Like

For outside of the database, you could use, system.tag.browseHistoricalTags in conjunction with system.tag.getConfiguration to build a report of tags and sample rates.

You could even automate making the change with system.tag.configure but that might be a little too hands off.

Should have known SQL would be the easy path here haha. This is a great start, thank you!

When I have some time I’ll expand on this to tie in tag paths etc

To expand on @MMaynard’s answer.

SELECT tagpath, count(tagid) as counts
  FROM [sqlth_1_data]
  inner join [sqlth_te] on [sqlth_1_data].tagid = [sqlth_te].id 
  group by tagpath
  order by counts desc