IMD SolutionComputing LibraryShop main store

Troubleshooting

Why queryTagHistory fails when the history provider is not in the path

Edge computing and IIoT Published 7 min read By IMD Solution engineering team

Short answer

A scripted queryTagHistory call with an unqualified tag path resolves through the default database, so it fails once history moves to its own store. Prefix every entry of the paths list with the historical provider's name in square brackets, read from the gateway's history-provider configuration, and keep the remaining arguments unchanged. Qualify explicitly: the bracket survives a later database move.

On this page
  1. Why an unqualified path lands on the default database
  2. Trace the fault before you edit anything
  3. Read the historical provider's name first
  4. Worked example: the substation tag that fails after the historian moves
  5. Verify against history you can name
  6. Faults that fail the same way
  7. Keep the provider explicit from here on
  8. Questions asked

The fault is in the paths list, not on the screen and not in the database server: a scripted call to system.tag.queryTagHistory whose tag paths carry no bracketed provider name resolves through the default database. That works for as long as the default database and the historian share a location, and it breaks the day history moves to its own store — the query ran before the split and threw afterwards. The fix is one string change: prefix each path with the historical provider's name in square brackets and rerun the call with its remaining arguments untouched. The sections below trace the failure from the display back to the script, show where the gateway publishes the provider name, work the substation example end to end, and separate this fault from the empty-result, timeout and disconnect failures that mimic it.

Why an unqualified path lands on the default database #

system.tag.queryTagHistory takes a list of strings, one tag path per entry, and it accepts historical tag paths — stated for Ignition 8.1 in the product documentation. The documented tag-path syntax puts a provider name in square brackets ahead of the folder hierarchy, in the shape [Tag Provider]folder/path/tag.

Without that bracketed prefix, the scripted query resolves the lookup through the default database. Records for one tag can sit in a historical provider other than that default, and one tag's records can be spread across different tables in a store, so the fallback finds the data only while the default database and the historian coincide. Bindings and configured report queries select their own data source separately, which is why a failure that follows only the scripted calls points at the script's path list and not at the screen. The fingerprint is the symptom pair: working at the shared location, throwing after the historian moved. Storage did not break; source resolution did.

Trace the fault before you edit anything #

Work down this list and stop at the first branch that matches:

  • Identify what feeds the affected chart or table: a tag-history binding, a scripted call to system.tag.queryTagHistory, or a plain SQL query against a database table. A binding and a script pick their data sources independently, so editing the binding will not repair a path built inside a script.
  • Capture the full exception text and the exact list the call received. When another function builds that list, print its output and inspect the finished strings rather than the template that produced them.
  • Read every entry for a bracketed provider name ahead of the tag hierarchy. Every entry bare while the stores sit apart is the fingerprint of this fault.
  • Check the live tag's value and quality as a separate branch. A live read with good quality proves the tag exists; it says nothing about which historian holds its records, so it never clears this one.

Read the historical provider's name first #

The string inside the brackets is the historical tag provider's name, and the gateway already publishes it: the Config section of the gateway webpage, under Tags > History, lists the configured providers, and that is also where the link that creates a new historical provider lives. Take the name from that list, not from the database connection settings — the database server, the schema, the database connection and the historical provider are separate configuration objects that many installations name alike. That shared name is exactly why the query ran at the shared location. Keep the hierarchy after the closing bracket spelled as the historian stored it, and keep to the path format the installed release documents; the form used here is the documented 8.1 syntax.

Worked example: the substation tag that fails after the historian moves #

The case: one tag, queried by script, after the historian moved off the default database.

The inputs

  • The failing call is system.tag.queryTagHistory from a project script, and its paths entry is the bare hierarchy Substation X/DNP Demo Data/T1-A, exactly as it stood when it threw.
  • The records live in a historical provider named dbname in this case; the real value is whatever name the gateway lists under Tags > History.
  • The condition that exposes the fault is the split: default database and history store on different locations.

The rule in words

Every path string is a provider name in square brackets followed by the tag hierarchy — the documented [Tag Provider]folder/path/tag shape, with the historical provider's name in the bracket position.

The arithmetic

# before: bare hierarchy, resolved through the default database
paths = ['Substation X/DNP Demo Data/T1-A']

# rule applied: bracketed provider, hierarchy unchanged
'[dbname]' + 'Substation X/DNP Demo Data/T1-A'
# = '[dbname]Substation X/DNP Demo Data/T1-A'

# after
paths = ['[dbname]Substation X/DNP Demo Data/T1-A']

dbname stands for the historical provider's name; put the name your own gateway lists in its place. Pass the corrected list as the function's first argument and keep the start and end times and every remaining argument unchanged, so the rerun isolates the path change.

The result

The call returns the dataset instead of raising. Read the returned timestamps and values — records inside the requested window at the expected values — rather than counting the error's disappearance as proof.

The decision

Once the history store is separate from the default database, every scripted path carries the bracketed provider; the shared-location setup was the only case in which leaving it off ever worked. If the qualified call still raises, the fault has moved to the provider or its connection status; if it returns an empty dataset instead, the fault is the tag hierarchy or the requested window.

Verify against history you can name #

Rerun the corrected call against a window that contains records already known — a stretch when the tag was logging normally — and judge presence, not an exact count: row counts move with the logging mode, buffering and any aggregation the call applies. Read three things out of the returned dataset: timestamps inside the requested window, values in the expected range, and no gap where the historian demonstrably recorded data.

Branch on what comes back:

  • An exception still: the path is qualified, so source selection is no longer the suspect — check the provider's status and its database connection before touching the script again.
  • An empty dataset: the provider resolved but handed back nothing. Check the hierarchy spelling and the window first; to see what the historian actually holds, pull its most recent records — getting the last N stored records from an Ignition tag history query shows how.
  • The expected rows: done. Change nothing else in the call.

Test the edited script in the development scope before it reaches the screens operators use.

Faults that fail the same way #

A qualified path clears one fault only. The same symptom family has neighbors with their own pages:

Keep the provider explicit from here on #

The standing decision: write the bracketed provider into every scripted history path, including the ones that work today at a shared location. The prefix costs nothing, states the script's dependency directly and survives the next database move; the coincidence that masks it does not. The change touches only which provider a query reads from — storage, retention and pruning stay with the provider configuration, which splitting retention and data pruning across history providers covers separately.

Questions asked

Does the bracketed provider change live tag reads too?

No. The bracket selects the source for the path string it sits on. A history query puts the historical provider's name in that position; an ordinary tag path puts the tag provider's name there. A live read resolving through the tag provider says nothing about which historian holds the records, so a good live value never clears a history-query fault.

What if the script queries several tags at once?

Qualify every entry in the list. Each path string resolves on its own, so one corrected entry does not repair the others, and a list mixing qualified and unqualified paths is legal. Give each entry the provider that actually stores that tag's records, because tags from different providers can sit in one query.

Why did the query work before the historian was moved?

While the default database and the history store shared a location, the unqualified path resolved to records that were in the right place by coincidence. The prefix was missing all along; the move removed the coincidence. Explicit qualification keeps the query working through further moves without touching stored data.

Is the name in brackets the database connection name?

It is the historical tag provider's name as configured in the gateway, a different object from the database server, the schema and the database connection even when installation habits give them the same name. Read the name from the provider list in the gateway's configuration, not from the connection settings.

Does the fix change where history is stored or how long it is kept?

No. The bracketed prefix only tells the query which provider to read from. Storage location, retention and pruning stay as the provider configuration has them, so no records move and none are deleted by the change.

Keep reading

  • Troubleshooting

    Remote tag history stops when gateway redundancy fails

    A running Gateway Network connection proves the transport, not the services behind it. In the reported case the redundant pair hosting the history providers had detected thread deadlocks on the backup and a disconnected redundancy peer on the primary after a direct upgrade to 8.3.4, so gateway and redundancy health must be restored before any remote provider is reconfigured.

    Edge computing and IIoT

  • Troubleshooting

    Getting backfilled Sparkplug history through Ignition reference tags

    Your settings are right; order is the missing condition. Backfill reaches the reference tags only when Store Historical Events is OFF so backfilled samples drive the Engine tag, and only when the edge replays its backlog oldest-to-newest past metric timestamp validation. Out of order, disable metric timestamp validation and keep the replayed value out of live control reads.

    Edge computing and IIoT

  • Troubleshooting

    Ignition historian logs memory tags but not OPC tag changes

    Memory tags record because their history subscription was created fresh; the migrated OPC tags carry a stale recording subscription that a storage-provider field edit alone does not rebuild. Fix one tag first: disable history, save, re-enable history with the production provider, and save again, then verify with one safely forceable fault before batching across the remaining tags.

    Edge computing and IIoT

Tag historian not logging zero: deadband and max time decide