Trending
Trending with the Factry Histo...
Query with regular expressions
what is a regular expression? regular expressions (regex) are a powerful way to search and filter text patterns in the context of factry historian, regex can help you select groups of measurements without typing each name manually create dynamic dropdown filters in grafana that adapt to new data work with large or inconsistent naming conventions across assets a regex is essentially a pattern for example ^temp → matches all measurements starting with temp pressure$ → matches all measurements ending with pressure why use regex? faster configuration when you have hundreds of sensors reduces human error by relying on naming patterns keeps dashboards flexible, even when new sensors are added in the future use regex to trend sensor data or create dropdown filters imagine you’re working with the faketory demo dataset you want to see how temperature and flow behave across multiple mixers instead of manually selecting each measurement, regex can help you target the right group when creating a grafana variable, the grafana regex option in the variable configuration works on the underlying uuids, not the displayed values so while you see the labels (e g mixer01 temp), the regex actually applies to their uuids in practice, this means the regex option in grafana variables is not very usable with factry historian datasource instead, use regex directly in your measurement or asset queries 1\ measurements measurements are the raw data records stored in historian suppose your factry historian has these measurements mixer01 temp mixer02 temp mixer03 flow you can use a regex like mixer temp to fetch all temperature measurements from all mixers in one query 2\ assets assets represent real world equipment in your plant for example, your factry historian might have assets mixer01 mixer02 mixer03 instead of selecting each asset manually, you can configure the query editor to fetch data with a regex that matches all mixers mixer this is particularly useful when new assets are added later, they’ll automatically be included in your dashboard for more details, see regex patterns in grafana datasource troubleshooting when using regex in the factry historian datasource, you might encounter some recurring issues here’s how to spot and resolve them regex returns no results cause the regex pattern doesn’t match the actual measurement or asset names in historian example your measurement is mixer01 temp , but your regex is ^temp → no match fix copy the exact measurement/asset names from historian test the regex in a sandbox regexror or regex101 adjust your regex until the match works (e g mixer temp ) regex is too broad cause greedy patterns like include far more than you intended example regex temp → matches mixer01 temp , but also ambienttemp , tempsensorbackup , etc fix narrow down the regex scope use anchors ( ^ for start, $ for end) to target exactly what you want example ^mixer01 temp$ → only returns mixer01 temp regex in grafana variables doesn’t work as expected cause in grafana, the regex in variable configuration is applied to the uuids , not the display names you might see mixer01 temp in the dropdown, but the regex is actually applied on its uuid fix avoid using regex inside grafana variable config instead, apply regex directly in your factry historian datasource query (measurements, assets, or asset properties) aggregation mismatch across data types cause mixing numeric and non numeric values with an unsupported aggregation example applying mean() across both temperature (numeric) and state (boolean) the datasource automatically falls back to last() for all measurements fix split queries by data type numeric values → use aggregations like mean, min, max string/boolean values → use last, first, mode add separate queries to the same panel so each data type trends correctly