Historical Alarm Storage
Purpose
This target writes alarm activation and recovery records at or above a selected level to a database. Use the stored records for historical alarm queries and reports.
Configure forwarding group ranges, offline cache, and runtime state through Data Forwarding. This page covers only the alarm table, level filter, dual-database mirror, and debug panels specific to historical alarms.
Open the plugin
Open Development Configuration → Data Forwarding and:
- Save the forwarding-group variable range.
- Add a target, choose Historical Alarm Storage, and fill in the basic target information.
- Open Target properties and configure the relational database, table, retention, time zone, and minimum alarm level.
- Optionally select a saved Historical alarm table script or enable the relational dual-database mirror. These modes are mutually exclusive.
- Save and enable the target, then activate and recover an approved test alarm.
Basic target information
| Setting | Default | Configuration |
|---|---|---|
| Group | - | Select a saved forwarding group. |
| Target name | - | Required and unique within the group. |
| Enable | Enabled | Disable to stop alarm-table initialization and writes. |
| Log level | Info | Temporarily use Debug for database or alarm-write diagnostics. |
| Start timeout | 60 seconds | Valid range is 1 to 3600 seconds. |
Target properties
| Setting | Default | Configuration |
|---|---|---|
| Database type | SqlServer | Supports SqlServer, MySql, Sqlite, and PostgreSql. |
| Split-table strategy | No split | Relational databases can split by day, week, month, quarter, year, or a custom split service. |
| Connection string | Development SQL Server example | Replace with the actual endpoint, database, account, and password; the account needs create, query, insert, and delete permissions. |
| Historical alarm table | historyAlarm | Table storing alarm activation and recovery records. Use a separate name for each target when appropriate. |
| Retention days | 3650 | Positive integer; values below 1 are normalized to 1. Cleanup uses alarm EventTime. |
| Historical alarm table script | Empty | Select a saved Dynamic SQL expression. The script owns table creation, writes, and cleanup; empty uses the standard table. |
| Time-zone offset | +08:00 | Enter a fixed offset such as +08:00 or -05:00; empty means UTC. Use the same convention when querying. |
| Minimum alarm level | 0 | Stores only alarms where AlarmLevel >= this value; lower-level alarms and recoveries are ignored. |
| Dual-database mirror | Disabled | Relational standard tables only; fill a different physical backup database. |
Relational connection strings
| Database | Example |
|---|---|
| SQL Server | Server=127.0.0.1,1433;Database=thingsgateway_alarm;User Id=history_user;Password=<password>;TrustServerCertificate=True; |
| MySQL | Server=127.0.0.1;Port=3306;Database=thingsgateway_alarm;Uid=history_user;Pwd=<password>; |
| SQLite | Data Source=DB/alarm.db;journal mode=WAL |
| PostgreSQL | Host=127.0.0.1;Port=5432;Database=thingsgateway_alarm;Username=history_user;Password=<password>; |
Dual-database mirroring supports SQL Server, MySQL, SQLite, and PostgreSQL. The primary and backup must be different physical databases, and Historical alarm table script must be empty. The automatic check, automatic fill, and capacity fields are the same as Historical Data Storage.
Target-variable properties
This plugin has no target-variable properties. Alarm inclusion is controlled only by the forwarding-group range and Minimum alarm level.
Cache and capacity
| Setting | Default | Configuration |
|---|---|---|
| Enable failed-write retry cache | Disabled | Enable to retain alarms when the database is unavailable and replay them after recovery. |
| Cache file maximum rows | 262144 | Maximum CacheDB outbox alarm rows. |
| Upload chunk size | 2000 | Maximum alarms per write or replay batch. |
| Memory queue limit | 100000 | Maximum in-memory alarm records. |
| Filter offline data | Disabled | The property is exposed by the common target, but alarm acceptance is controlled by group range and minimum alarm level. |
| Upload concurrency | 1 | Default serial write; increase only after database load testing. |
Target debug
Open Development Configuration → Data Forwarding, select the forwarding group and target, and open Debug.
| Feature | Purpose |
|---|---|
| Forwarding pipeline | Shows the forwarding group range and alarm data entering the target. |
| Cache outbox | Shows pending alarms, retained retries, and the latest error. |
Forwarding pipeline

Use the pipeline to confirm the forwarding group range, target state, and alarm data entering the target.
Cache outbox

The cache outbox shows the alarm queue, CacheDB pending rows, retained retries, and latest error. When offline cache is enabled, pending alarms are written after the database recovers.
Verify the target
- Enable the forwarding group and target, then confirm that the target is online.
- Use an approved test variable to activate and recover an alarm at or above Minimum alarm level.
- Query the historical alarm table and confirm that both activation and recovery records were written.
Troubleshooting
| Symptom | Check |
|---|---|
| Alarm is not stored | The alarm was activated, its level meets the minimum, and the target is online. |
| Target does not start | Database connection, table name, split-table strategy, and account permissions. |
| Alarms are not written after recovery | Offline cache setting, cache outbox, and target log. |
| Dual-database mirror cannot start | The primary and backup are different, both database types are supported, and the historical alarm table script is empty. |
Related links
- Data Forwarding: Forwarding groups, ranges, triggers, cache, redundancy, and target runtime operations.
- Alarm Configuration: Configure alarm conditions and levels.
- Plugin Manual Index: Other collection and data-forwarding plugins.