Counter and metric data leaves the system in five ways: the downloads on the pages themselves, Excel reports (the counter tracking list), the Reports page (tables, charts, PDF), REST with an access key and writing to an external database. Every value is also published as a tag (OPC UA, Data Bridge). This page explains which one to use when.
Which way, when
| Need | Way |
|---|---|
| A quick look at consumption day by day or month by month | Counters and Metrics › Period report tab |
| A table that shows counters group by group with closing index and difference | Counters and Metrics › Excel reports tab (counter tracking list) |
| A report with charts and PDF; a wall screen | Add-ons › Reports |
| An ERP or BI tool comes and reads the report | An access key for the report (REST, JSON) |
| MergenHub sends the report itself at set times | A Data Bridge report agent (REST or MQTT) |
| Period values are queried with SQL | Write counter data to an external database |
| SCADA screen, alarm, OPC UA client | The _Counters. and _Metrics. tags |
Downloads on the pages
The Period report, Water Footprint, Water Efficiency and Water Flow Diagram pages have Excel and CSV buttons. The Excel files are multi-sheet, with headings and number formats (numbers can be summed).
Counter tracking list (grouped Excel report)
A period table that shows counters side by side, group by group: coloured group headers at the top (e.g. PRODUCTION, CONSUMPTION, RECOVERY), Closing index and Difference columns under every counter, a total column at the end of every top group and a TOTAL row at the bottom. The table is dynamic: when you add a counter to a group it enters the report by itself.
- Make sure your counters are in the right group; the group tree is the header structure of the report.
- On the Excel reports tab click New report. The editor opens with all groups ticked and the preview is drawn straight away.
- Untick the groups or counters you do not want; change the order with the arrows on the row.
- Click a group and choose its Header colour. The colour belongs to the group and is the same in every report.
- Choose the columns: Closing index, Difference (period consumption), group total, totals in the last row.
- Save.
With the report open, the period (hour, day, week, month, year), the range and the dates are chosen from the bar above the table; you do not need a separate report per period. Download Excel writes the table as shown, with merged, coloured headers.
.json) and applied to another system or site with From template; the template refers to counters by code, not by id.The Reports page (report designer)
Add-ons › Reports builds reports from the records in the system: live values, data log history, alarm history, the event and audit logs, and counter and metric period values.
- Table report: a list or a summary table (grouping and calculations), side-by-side columns and a chart; downloads as Excel, PDF and CSV.
- Report page: panels placed on a grid in a visual editor; live cards show tag and metric values live and can be shown on a wall screen in Full screen mode.
Reading from an external system with an access key (REST)
An Excel report is opened to an external system only with an access key; no user name or password is given to the external system.
- Click the plug icon on the report row; under New key enter a name for the key (e.g. ERP nightly transfer).
- Choose the Scope (This report only is recommended) and Valid for (30 days, 90 days, 1 year, no expiry).
- Create key. The key is shown once; copy it immediately. The server stores only its hash.
- The external system sends this header with every request:
Authorization: Bearer mhkey_…
GET /config/v1/meteringreports/<report id>/run?shape=records&grain=Day&range=Custom&from=2026-01-01&to=2026-01-31
| Rule | Description |
|---|---|
| Read only | The key reads the report; it cannot reach any other address, setting or write operation. |
| HTTPS | Requests from the internet are accepted over HTTPS only; requests from the local network are also read over HTTP. |
| Revoking | Deleting the key in the window invalidates it immediately. |
To have MergenHub send the report itself, define a report agent in the Data Bridge (see Data Bridge).
Writing counter data to an external database
Define a named database connection under Settings › Data sources (MySQL 8+ / MariaDB, SQL Server or ODBC), then open the Write counter data to an external database card on the same page.
- Choose the data source and the table prefix (
mh_by default). The tables are created if they do not exist:mh_counter_period,mh_metric_period. - Tick the periods to write: hour, day, week, month, year. Optionally write period metrics as well.
- Enter the write interval and save; the first run starts immediately.
The primary record stays in MergenHub's own database: the external database is a copy, and if it is unreachable no measurement is lost. Writing is repeatable (the same period is updated, no duplicates); Rewrite everything writes the whole history again.
-- Daily well production for this month
SELECT period_start, counter_name, total, unit
FROM mh_counter_period
WHERE period_type = 'day' AND category = 'WATER_PRODUCTION'
ORDER BY period_start, counter_name;
Tags, OPC UA and AI
- Every counter and metric is published as a
_Counters.<Code>or_Metrics.<Code>tag; it appears on the OPC UA server in the folders of the same name and is sent over MQTT or REST by Data Bridge agents. - The AI assistant and MCP clients read counters, metrics and the water reports: "How much water was drawn from the well last month?", "Where is the recovery ratio against its target?".
- Counter, metric and manual input definitions, the water profiles and the reports are included in the project package.
MergenHub