# Alarm classes, history and counts API

> The project's alarm visual classes (colours, blink and sound per class, priority and ISA-18.2 state), the alarm history query with filters, sorting, paging and CSV export, and the alarm counts for counters and annunciators.

Product: eaxScada · Type: Reference · Editions: Starter, Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/reference/alarm-classes-and-history/
Status: migrated page, not yet verified against the current code.

Three server APIs sit behind the alarm objects on screens:

- `/api/alarms/classes`: how each alarm looks and sounds;
- `/api/alarms/history` and `/api/alarms/history.csv`: the ISA-18.2 journal;
- `/api/alarms/counts`: the standing alarms, counted for counters and annunciator tiles;
- `/api/alarms/active`: the standing alarms, with the alarm list card's filters.

Every route needs a signed-in user. Each user sees only the alarms they are allowed to see (see [Visibility](#visibility)).

---

## 1. Alarm classes

An alarm is drawn according to three things:

| Dimension | Values |
|---|---|
| **Class** | The alarm's category: `Safety`, `Process`, `Environmental`, `Equipment`, `Diagnostic`, or any category of your own. An unknown category uses the document's `default_class`. |
| **Priority** | `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`, `INFO`. |
| **Display state** | `UNACK_ALARM`, `ACK_ALARM`, `RTN_UNACK`, `SHELVED`, `SUPPRESSED` (alarm evaluation is stopped), `NORMAL` (history rows only). |

### Priority names

An alarm definition can hold a priority that is not one of the five, for example from an older project or an import. **Every surface reads such a priority the same way, and never lower than an earlier release showed it:**

| Priority in the definition | Shown, counted and filtered as |
|---|---|
| `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`, `INFO` (any case, spaces trimmed) | itself |
| `HIGHEST`, `URGENT` | `CRITICAL` |
| any other name (`WARNING`, `WARN`, `MINOR`, `NOTICE`, an unknown name), empty or missing | `HIGH` |

The rule is the server's, and every display follows it: the alarm counts (`GET /api/alarms/counts`) and the counters and annunciator tiles built on them, the alarm classes' colours and sounds, the `priority` filter of `GET /api/alarms/active`, the dashboard alarm list card, the alarm banner and summary objects (their priority filter, order and counters), the classic dashboard alarm summary, the phone view's alarm list and status level, the colour of an object in the 3D and isometric views, and the System Health alarm counts with the `eaxscada_alarms` metric.

Each class × priority × state cell gives:

- the text, background and border colours;
- a blink background, used for the "off" phase;
- blink: `none`, `slow` (0.5 Hz) or `fast` (2 Hz);
- bold and italic;
- an icon and a short label;
- for the unacknowledged states only, a sound (`none`, `horn`, `chime`, `beep` or `siren`), its repeat (`once`, `until_silenced` or `until_ack`) and its volume (0 to 1).

A sound plays only if the alarm definition has `sound_alert` on.

The classes only control how alarms look. They never change which alarms are listed, their order, or how they are acknowledged.

### 1.1 Base profiles

The project's document overrides one of two built-in profiles:

| Base | Look | Used by |
|---|---|---|
| `isa101` | ISA-101 colours: CRITICAL red `#B91C1C`, HIGH orange `#C2410C`, MEDIUM amber `#CA8A04`, LOW blue `#0369A1`, INFO slate `#475569`. A returned, unacknowledged alarm has a light background with a border in its priority colour. Sounds: horn for CRITICAL (until acknowledged) and HIGH (until silenced), chime for MEDIUM, beep for LOW, none for INFO. | new projects |
| `legacy` | The alarm banner's colours before classes existed: CRITICAL dark red, other priorities dark amber, a returned alarm cyan. One horn for every priority. | projects that already had alarms when they were upgraded |

The first start after the upgrade writes `data/alarms/classes.json` with the chosen base, so the look never changes by itself afterwards.

In both profiles, an unacknowledged alarm blinks fast and a returned unacknowledged alarm blinks slowly; INFO alarms do not blink. Every text colour has a contrast of at least 4.5:1 against its background.

### 1.2 Document

The document is stored in `data/alarms/classes.json`. On an HA cluster it is replicated with the alarm definitions.

```json
{
  "version": 1,
  "base": "isa101",
  "priorities": {
    "HIGH": { "*": { "label": "P2" }, "UNACK_ALARM": { "bg": "#C2410C" }, "sound": { "sound": "horn", "repeat": "until_silenced" } }
  },
  "states": { "SHELVED": { "bg": "#64748B", "fg": "#FFFFFF" } },
  "classes": {
    "Environmental": {
      "label": "Environment",
      "overrides": { "*": { "UNACK_ALARM": { "bg": "#065F46", "fg": "#FFFFFF" } } },
      "sound": { "*": { "sound": "chime" } }
    }
  },
  "default_class": "Process",
  "blink_respects_reduced_motion": false,
  "safety_critical_steady_allowed": false
}
```

- `"*"` stands for every priority or every state.
- `states` styles only `SHELVED`, `SUPPRESSED` and `NORMAL`.
- `blink_respects_reduced_motion`: when it is `true` and the operator's system asks for reduced motion, a blinking cell is shown steady with a high-contrast marker. By default alarms always blink.
- `safety_critical_steady_allowed`: see [Built-in safety alarms](#13-built-in-safety-alarms).

**Resolution.** For each cell, these layers are applied in order. A later layer overrides an earlier one, member by member:

1. the base profile;
2. `priorities[priority]["*"]`, then `priorities[priority][state]`;
3. `states[state]`;
4. the class overrides `["*"]["*"]`, `["*"][state]`, `[priority]["*"]`, then `[priority][state]`.

The sound is resolved the same way: the class's sound for the priority, otherwise the class's `"*"` sound, otherwise the priority's sound, otherwise the base profile's.

The resolver never returns an unreadable cell. Invalid colours, or a text colour equal to its background, fall back to the base profile's colours.

**Diagram: How the look of an alarm is resolved** (layered stack)

eaxScada builds the look of one alarm from five layers, top to bottom: the base profile, the priority, the state, the alarm class, and the readability floor. Each layer overrides the one above it member by member; a member it leaves empty keeps the earlier value. The sound is resolved apart, for the unacknowledged states only.

**Parts**

- **Base profile** (layer 1): isa101, or legacy for upgraded projects
- **Priority** (layer 2): priorities: the priority's "\*", then its state
- **State** (layer 3): states: three states only
- **Alarm class** (layer 4): the class overrides, from the widest to the narrowest
- **Never unreadable** (layer 5): applied last, whatever the document says
- **Base cell** (service or process): for the priority and the state
- **priorities\[priority\]** (service or process): "\*" first, then \[state\]
- **states\[state\]** (service or process): SHELVED, SUPPRESSED, NORMAL
- **Class overrides, in order** (service or process): \["\*"\]\["\*"\], \["\*"\]\[state\], \[priority\]\["\*"\], \[priority\]\[state\]
- **Readable colours** (check or decision): else the base colours
- **The alarm** (service or process): its class, priority and display state; unknown: the defaults
- **Sound, in order** (service or process): unacknowledged only: base, priority sound, class "\*" sound, class priority sound
- **Alarm as drawn** (service or process): colours, blink, label, icon, sound

**Connections**

- **The alarm → Base cell** (data or telemetry). An unknown class is the document's default_class (else Process), an unknown priority is HIGH and an unknown state is UNACK_ALARM.
- **Base cell → priorities\[priority\]** (data or telemetry). Each layer overrides the layer above member by member; a member it leaves empty keeps the earlier value.
- **priorities\[priority\] → states\[state\]** (data or telemetry). The state layer styles only SHELVED, SUPPRESSED and NORMAL; for the other states it is skipped.
- **states\[state\] → Class overrides, in order** (data or telemetry)
- **Class overrides, in order → Readable colours** (data or telemetry). Colours that are not valid, or a text colour equal to its background, take the base cell's colours. For the built-in safety alarms, text below 3:1 contrast takes the base colours, and a CRITICAL unacknowledged alarm made steady keeps the base blink unless safety_critical_steady_allowed is on.
- **Readable colours → Alarm as drawn** (data or telemetry)
- **The alarm → Sound, in order** (data or telemetry): unacknowledged. The sound is resolved only for UNACK_ALARM and RTN_UNACK; every other state has no sound.
- **Sound, in order → Alarm as drawn** (data or telemetry): sound, repeat, volume

The more specific setting wins, but the result is never unreadable: the floor at the bottom applies whatever the document says.

**Validation (on save).** These are refused:

- an unknown member, priority, state, blink, icon, sound or repeat;
- a colour that is not `#RGB` or `#RRGGBB`. Named, transparent and alpha colours are not accepted;
- a label longer than 8 characters;
- a resolved cell whose text colour equals its background;
- a blinking cell whose blink colour equals its text colour.

Text contrast below 4.5:1 is accepted, with a warning.

### 1.3 Built-in safety alarms

The product's own safety alarms are the plant emergency stop and the PLC fault alarms. Their class and priority is `Safety`, `CRITICAL`, and they cannot be made invisible:

- a document that gives that class and priority a text contrast below 3:1, in any state, is refused;
- a document that makes it steady (`blink: none`) while unacknowledged (`UNACK_ALARM`, `RTN_UNACK`) is refused, unless `safety_critical_steady_allowed` is `true`;
- when these alarms are drawn, the same floor applies again, even if the document was edited by hand.

### 1.4 API

| Route | Who | |
|---|---|---|
| `GET /api/alarms/classes` | any signed-in role | The effective classes: `doc`, the resolved `matrix` (class → priority → state → cell), `builtin_safety`, the allowed `blink_hz`, `sounds`, `repeats` and `icons`, the `warnings`, and `from_default` and `load_error`. The revision is in `_rev` and in the `ETag` header. |
| `PUT /api/alarms/classes` | Lead_Engineer, Administrator | Replaces the document. The body is the `doc` object; a `_rev` member is ignored. Send the revision you edited in `If-Match`. |

Answers to `PUT`:

- `409 {"status":"stale"}`: the document changed since you loaded it. Nothing was saved.
- `400 {"status":"invalid","problems":[...]}`: the document did not pass validation.
- `409` or `503`: on an HA cluster, the node is a standby or has no quorum.
- `200`: the document was saved. The answer is the same as `GET`, with the warnings.

Every save is written to the audit trail as `ALARM_CLASSES UPDATE` before it is made, with the old and new documents and the SHA-256 of each in the reason ("sha256 before …, after …"). When the record cannot be written the save is refused with `503` and the code `AUDIT_NOT_WRITTEN`, and the classes are unchanged. A checkpoint revert or a server backup restore that changes the classes is recorded the same way first (`ALARM_CLASSES CREATE`, `UPDATE` or `DELETE`, the reason naming the checkpoint or backup).

---

## 2. Alarm history

`GET /api/alarms/history` returns one page of the ISA-18.2 journal. `GET /api/alarms/history.csv` exports every row the same filters select.

| Parameter | Meaning |
|---|---|
| `from`, `to` | Inclusive bounds: an RFC 3339 time, Unix milliseconds (nanoseconds from 10¹⁵ up), or a duration back from now such as `-24h`. |
| `class` | Categories, as a comma-separated list, case-insensitive. Alias: `category`. |
| `priority` | `CRITICAL,HIGH,MEDIUM,LOW,INFO`. Alias: `severity`. |
| `state` | Events (`TRIP`, `ACK`, `RTN`, `SHELVE`, `UNSHELVE`) and/or the states they led to (`NORMAL`, `UNACK_ALARM`, `ACK_ALARM`, `RTN_UNACK`, `SHELVED`). Alias: `event`. |
| `tag` | A tag path pattern. With `*` or `?` it must match the whole path; otherwise it matches any part. Alias: `tag_path`. |
| `area` | A tag path prefix, matched by whole segments: `Plant/Line1` matches `Plant/Line1/...` but not `Plant/Line10`. |
| `user` | Who acknowledged, shelved or unshelved, case-insensitive. |
| `q` | Text in the message (name, description), alarm id, tag, reason or user. Alias: `search`. |
| `alarm_id` | One alarm. |
| `sort` | `time`, `alarm_id`, `name`, `tag`, `class`, `priority`, `event`, `state`, `previous_state`, `value`, `setpoint`, `user` or `reason`. Prefix with `-` (or add `:desc`) to sort descending. The default is `-time`. `priority` sorts by urgency: ascending puts CRITICAL first. |
| `limit` | 1 to 1000. The default is 100. |
| `cursor` | The `X-Next-Cursor` of the previous page. Pages stay stable while new events arrive. |
| `offset` | The number of rows to skip. Ignored when `cursor` is set. |
| `envelope=1` | Answer `{"rows","total","next_cursor","limit","sort"}` instead of an array. |

**The answer** is a JSON array of journal events. Each row also carries:

- `class`, the class the alarm is shown as;
- `display_state`;
- `user` and `reason`, the actor of the event.

These headers come with it:

- `X-Total-Count`: the rows that match, across all pages;
- `X-Next-Cursor`: the cursor of the next page; absent on the last page;
- `X-Limit`;
- `X-Sort`.

A bad parameter is answered `400` with the reason.

**CSV.** `columns=` chooses and orders the columns. The default is all of them: `time` (UTC, ns), `event_id`, `alarm_id`, `name`, `description`, `tag`, `class`, `priority`, `event`, `previous_state`, `state`, `value`, `setpoint`, `user` and `reason`.

The rows are streamed in the requested sort order. An export holds at most 100 000 rows; `max_rows` sets a lower cap. When more rows match, nothing is exported. The answer is `413 {"status":"too_many_rows","total":…,"max":…}`, asking you to narrow the time range or the filters.

A text cell that a spreadsheet would run as a formula (one starting with `=`, `+`, `-`, `@`, a tab or a carriage return) is prefixed with an apostrophe.

**Rows journaled by an earlier release** do not have a message in the columnar store. Those rows show the alarm's current name and description.

**Performance** was measured on a 1 000 000-event journal (2 000 alarms, 30 days) on a development workstation.

| Query | Columnar store (full build) | Journal file (standard build) |
|---|---|---|
| Newest 100 rows, all rows, role filter applied | 20–207 ms | 1.4 s |
| Last 24 h, priority and class filter | 35 ms | 0.6 s |
| Text search over 30 days | 98 ms | 0.6 s |
| Page 2 by cursor, sorted by tag, 1000 rows | 102 ms | |
| Offset 500 000, sorted by priority | 339 ms | |
| CSV stream of 66 000 rows | 370 ms | |

The columnar store needs no extra index. The journal is written in time order, so time ranges are pruned without one.

---

## 3. Alarm counts

`GET /api/alarms/counts` counts the standing alarms the caller sees, the same list as `GET /api/alarms/active`. Optional filters: `class`, `priority`, `area`.

Each alarm is counted under its priority as read in [Priority names](#priority-names), so `by_priority` and the cells hold only the five priorities: an alarm with `HIGHEST` or `URGENT` counts as `CRITICAL`, one with any other name as `HIGH`. The `priority` filter takes the five names (`priority=CRITICAL,HIGH`).

```json
{
  "counts": {
    "total": 6, "unacked": 4,
    "cells": [ { "class": "Safety", "priority": "CRITICAL", "state": "UNACK_ALARM", "count": 2 } ],
    "by_priority": { "CRITICAL": { "total": 3, "unacked": 2 } },
    "by_class": { "Safety": { "total": 3, "unacked": 2 } },
    "by_state": { "UNACK_ALARM": 3 }
  },
  "builtin_safety_active": 1,
  "classes_rev": "…"
}
```

An alarm counts as unacknowledged in `UNACK_ALARM` and `RTN_UNACK`, whether or not its evaluation is suspended.

The System Health tags `System/Health/<node>/Alarms/Active`, `Alarms/Unacked` and `Alarms/Shelved` use the same priority rule. They count the whole server, while `/api/alarms/counts` counts what its caller may see. See [System Health history](/docs/eaxscada/reference/metrics/#history).

---

## 4. Standing alarms with filters

`GET /api/alarms/active` answers the standing alarms the caller sees, as a JSON array. It takes the same filters as the dashboard's alarm list card, so the card gets only the rows it shows. Without a parameter it answers every standing alarm the caller sees, as before.

| Parameter | Alias | Keeps the alarms |
|---|---|---|
| `area` | `path` | whose tag path is the folder or under it, by whole path segments: `Boiler` matches `Boiler` and `Boiler/Drum/Level`, never `Boiler2/Level`. A trailing `*` or `/` is dropped. |
| `priority` | `severity` | of one of the priorities given: `CRITICAL`, `HIGH`, `MEDIUM`, `LOW`, `INFO`. The alarm's priority, and each value given, are read as in [Priority names](#priority-names): `HIGHEST` and `URGENT` are `CRITICAL`; any other name, empty or missing is `HIGH`. |
| `class` | `category` | of one of the classes given, case-insensitive. |
| `state` | | in one of the states given: `active` (standing, acknowledged or not), `unack` (unacknowledged, standing or returned), `shelved`, `returned` (returned to normal, not yet acknowledged), or a display state by name (`UNACK_ALARM`, `ACK_ALARM`, `RTN_UNACK`, `SHELVED`, `SUPPRESSED`, `NORMAL`). **An unknown state matches nothing**, never everything. |
| `text` | `q` | where every word given appears in the alarm's name, description, tag path, id or class, case-insensitive. |

- `priority`, `class` and `state` take a list: comma-separated (`priority=CRITICAL,HIGH`) or the parameter repeated. `ALL` and empty entries in a list are no filter.
- Several parameters: an alarm must match all of them.
- A parameter the route does not know is ignored, as before.
- **The filters run after the caller's read rights and the alarm visibility** (see [Visibility](#visibility)). They only take rows away: no filter ever returns an alarm the caller may not see.

```text
GET /api/alarms/active?area=Plant/Boiler&priority=CRITICAL,HIGH&state=unack&text=drum%20level
```

---

## Visibility

Every route here filters alarms by the same rule as the other alarm reads (`/api/alarms/active`, `/api/alarms/journal`, the WebSocket):

- the caller must have read rights on the alarm's tag;
- the alarm definition's `target_roles` must name one of the caller's roles. Administrators see every alarm.

The built-in safety alarms (the plant emergency stop and the PLC fault alarms) are shown to every signed-in role, whatever their `target_roles` and whatever the read rights on their tag. An operator who may not read a PLC's fault tag still sees that the PLC faulted. The alarm row carries its trip value; the tag itself stays unreadable (`/api/tags`, trends and the tag stream still refuse it).

The filter is applied before counting and paging. Neither the total, the pages nor the CSV export include a row the caller may not see. A row that is written while a query runs is shown only if it was checked against the caller's rights.

## Behaviour changes

- Projects that already had alarms get the `legacy` look, which keeps the former banner colours. Unacknowledged alarms now blink fast, and alarms that returned to normal but are not yet acknowledged blink slowly (decision D3).
- Built-in safety alarms are now visible to every signed-in role, even without read rights on their tag. This applies to every alarm read: `/api/alarms`, `/api/alarms/active`, `/api/alarms/journal`, `/api/alarms/history` and its CSV, `/api/alarms/counts`, and the WebSocket alarm list and events. Before, an operator without read rights on a PLC fault tag did not see that PLC's fault alarm.
- `/api/alarms/history` now accepts GET only (any other method gets 405). It still answers a JSON array, with new fields and paging headers.
- `GET /api/alarms/active` now applies `area`, `priority`, `class`, `state` and `text` (and their aliases) on the server, after the read rights. Before, it ignored every parameter. A client that sent one of these parameters and expected every standing alarm now gets fewer rows; a `state` value the server does not know now returns no rows.
- A priority that is not one of the five is now read one way everywhere ([Priority names](#priority-names)), never lower than before. `GET /api/alarms/counts` and the alarm class colours and sounds now count and show `HIGHEST` and `URGENT` as `CRITICAL` (they were `HIGH`). In the alarm list card and the `priority` filter of `GET /api/alarms/active`, an unknown or empty priority, `WARNING` and `WARN` are now `HIGH` (were `MEDIUM`), `MINOR` is `HIGH` (was `LOW`) and `NOTICE` is `HIGH` (was `INFO`). The alarm banner and summary objects no longer hide an alarm with an older or unknown priority from their priority filter. The classic dashboard alarm summary shows an unknown priority as `HIGH` (was `LOW`) and `INFO` as `INFO` (was `LOW`); the phone view shows an unknown or missing priority as `HIGH` (was `LOW`); the 3D and isometric views colour an object by such an alarm as `HIGH` (it ranked below `INFO`).
- **SAFETY:** the System Health alarm counts and the `eaxscada_alarms` metric now count every priority name, read by the same rule. Before, an alarm with a priority name other than the five was missing from them.

## See also

- [Alarms](/docs/eaxscada/explanation/alarms/): the ISA-18.2 lifecycle.
- [HTTP API reference](/docs/eaxscada/reference/generated/http-api/).
