---
title: "Creating alarm definitions and rules"
description: "How NetSense alarms work, what you can monitor, and how to build precise alarm rules with match and filter conditions, custom variables, messages and notification relays."
---

> Documentation Index
> Fetch the complete documentation index at: https://netsense-nms.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating alarm definitions and rules

NetSense continuously collects health and performance data from every device it monitors:
OLTs, switches, BNGs, servers, wireless devices, generic network devices, switch and BNG
fans, and IP SLA probes. An **alarm** is how the system tells you that something in that
data needs your attention: a link went down, an optical level drifted out of range, a device
stopped responding, CPU is running hot.

You decide what "needs attention" means by creating an **alarm definition**: a saved rule
that NetSense checks against incoming data. Whenever the rule is true, NetSense raises an
alarm; when the condition clears, the alarm closes automatically. Each alarm can also be
delivered to your team over Slack, Telegram, Alerta or a webhook.

![The NetSense alarm list showing active alarms with severity, duration, hostname, entity, description and live message columns](https://netsense-nms.com/docs/_nimbus/md/c1tnsl/alerting-dashboard.webp)

:::note[In one sentence]
An alarm definition = a condition you care about + how important it is + the message you'll
see + optional timing and notification settings.
:::

## Key terms

| Term | What it means |
| --- | --- |
| Alarm definition | The saved rule you create. It stays in place and is checked against every new reading. |
| Report type | The kind of thing the alarm watches (an OLT, an OLT port, a switch, a server, a fan). It decides which readings are available and cannot be changed after creation. |
| Rule | The condition that decides when the alarm fires, e.g. "temperature is at or above 60°C". |
| Severity | Critical, Major, Minor or Warning. Used for color-coding, sorting and routing. |
| Reading / field | A single measured value from a device or port, such as CPU load, Rx power, or port status. |
| Custom variable | A value you calculate from an existing reading and use in a rule or message. |
| Relay | A notification channel (Slack, Telegram, Alerta, webhook) an alarm can be sent to. |
| Alert delay | A grace period before a newly-triggered alarm becomes active. |
| Keep alive | A minimum time an alarm stays open, counted from the first matching reading. |

## What you can monitor

The readings available depend on the **report type** you choose: OLT, OLT Port, Switch,
Switch Port, BNG, BNG Port, Server, Server Port, Wireless, Wireless Port, Generic Device,
SLA Probe or Fan. Device-level alarms watch the device as a whole; port-level alarms are
evaluated separately for every port.

- **Device health** (OLT, Switch, BNG, Wireless): device status, SNMP status, ping packet
  loss and latency, previous ping loss, CPU load, memory load, temperature, uptime. OLTs,
  switches and BNGs also report power supply status.
- **Server-specific**: the same device health readings except power supplies, plus disk
  utilization and free space, disk read/write rates, physical, virtual, swap and available
  memory, per-core CPU utilization, OS and architecture.
- **Generic devices** are ping-only: device status, previous status, and the ping readings
  (loss, latency, previous loss).
- **Ports and interfaces** (OLT, Switch, BNG, Server and Wireless ports): port status and
  flap counts, traffic in/out and utilization, errors and discards, unicast/multicast/
  broadcast packet rates, speed, media type and description. Ports with a transceiver (OLT,
  Switch and BNG ports, not Server ports) add optical readings: Rx/Tx power, temperature,
  voltage, bias current, plus the vendor's own low/high thresholds.
- **PON / ONU readings** (OLT ports): active/registered/max ONUs, baseline ONUs, down ONUs
  (total, optical loss, not powered off), port fill, active ONU deviation from baseline, and
  the number of ONUs that went down in the last 10 or 30 minutes.
- **Coherent optics** (Switch ports): laser frequency, OSNR, uncorrected FEC, laser age.
- **Fans** (Fan, for switches and BNGs): fan status, speed, slot and name. Each fan raises
  its own alarm. See [device health](https://netsense-nms.com/docs/guides/device-health/).
- **SLA probes** (SLA Probe): the results of the IP SLA definition you bind the alarm to.
  See [IP SLA monitoring](https://netsense-nms.com/docs/guides/ip-sla-monitoring/).
- **Hardware profile** (most device and port types): manufacturer, model, hardware version
  and firmware version, e.g. to scope an alarm to one firmware.

:::tip
You never have to memorize field names. The rule builder shows a drop-down of exactly the
readings available for the report type you picked, complete with units and valid ranges.
:::

## Creating an alarm, step by step

Open **Alarms → Alarm Definitions** and click **Add a definition**. You can also
**duplicate** an existing definition (the copy icon on its row) and tweak it, often the
fastest way to start.

1. **General**: name (e.g. "OLT CPU High"), severity, report type (locked once created, so
   choose carefully), optional **Alert delay** and **Keep alive**, description, and the
   message shown when the alarm fires. Names cannot contain a hyphen (-); use spaces.
   Messages are limited to 1,024 characters. For an SLA Probe alarm you also pick the SLA
   definition it watches.
2. **Custom variables** (optional): calculated values to use in the rule or message.
3. **Rules**: build the condition with the visual rule builder.

When you save, NetSense validates the rule and checks that every reading you referenced
exists for the chosen report type. From that moment the alarm is live.

Relays are attached after the first save. Open the saved definition and pick them in its
**Relays** section, or attach definitions from the relay's own page under **Alarms → Alarm
Relays**.

## Building the rule

A rule is one or more conditions combined with AND / OR logic. Each condition compares a
reading to a value, or to another reading.

```txt
Temperature  >=  60      ->  fires when temperature reaches 60°C
Port status  =   Down    ->  fires when the port is down
CPU load     >   85      ->  fires when CPU is above 85%
```

- **AND**: every condition in the group must be true (narrower, fewer alarms).
- **OR**: any one condition is enough (broader, more alarms).
- Groups can be nested for precise logic, e.g. "status is Down AND recent ping loss was high".

A sustained packet-loss example that ignores both brief blips and total outages:

```txt
ALL of the following (AND):
    ping loss           > 20
    ping loss           < 90
    previous ping loss  > 20
    previous ping loss  < 90
```

### Comparing one reading to another

Instead of a fixed number you can compare a reading to another reading. This is ideal for
optics, where devices report their own thresholds:

```txt
Rx power  <  Rx low warning threshold
```

The alarm fires when the received light drops below the vendor's own warning level, no
hard-coded number needed, and it adapts per port.

### Match conditions vs filter conditions

The real power of the rule builder is combining **match** conditions (what to alarm on) with
**filter** conditions (what to ignore). A refined Switch Port DOWN alarm that only fires for
real physical ports:

```txt
ALL of the following (AND):
    status  ==            Down       (the port is down)
    type    ==            Ethernet   (only real, physical ports)
    name    not_contains  tunnel     (ignore tunnel interfaces)
    name    not_contains  docker     (ignore Docker virtual bridges)
    name    not_contains  br-        (ignore Linux bridges)
    name    not_contains  virb       (ignore libvirt virtual bridges)
```

The first two lines select what you care about; the `not_contains` lines drop virtual and
logical interfaces that are "down" by design and would otherwise flood you with noise. Add
one `not_contains` line per naming pattern you want to exclude. Dot1q sub-interfaces on
switches and BNGs have their own port type, **SubInterface**, so `type == Ethernet` leaves
them out too.

:::note[Interfaces NetSense already ignores]
On switches and BNGs, port alarms skip ports whose name contains `vlanif`, `loopback`,
`mgmt_eth` or `meth`, and ports whose description contains `testing`, `ip interface` or
`raw power monitoring`, before any rule runs. Adding "testing" to a port description
therefore silences all its port alarms.
:::

### Filtering by hostname or description

`hostname` (the device a port belongs to) and `description` (the interface description
configured on the device) are the two most useful filter fields. Text fields support full
matching (`==`, `!=`) and partial matching (`contains`, `not_contains`, case-insensitive).
`==` and `!=` are exact and case-sensitive.

```txt
One specific device:            hostname     ==            core-sw-01
Every device in a site:         hostname     contains      sof-
Only customer-facing ports:     description  contains      customer
Exclude uplink/transit ports:   description  not_contains  uplink
Ports with no description:      description  ==            (empty value)
```

Putting it together, a precise alarm for high inbound utilization on customer aggregation
ports at one site:

```txt
ALL of the following (AND):
    hostname        contains      sof-agg    (site + role)
    type            ==            Ethernet   (physical ports only)
    description     contains      customer   (only customer ports)
    description     not_contains  test       (exclude test ports)
    utilization_in  >             90         (over 90% inbound)
```

:::note[Missing readings never cause false alarms]
If a device doesn't report a particular reading (for example a port with no optical module),
conditions on that reading are simply treated as "not triggered". You don't have to guard
against blank values yourself. This applies to `!=` conditions too: a condition on a
reading the port lacks is never true.
:::

## Custom variables

When the value you care about isn't reported directly, build it. A custom variable is one
numeric reading combined with a constant using `+`, `-`, `×` or `/`. You can then use it in
rules and messages like any other reading.

```txt
custom variable:  bits_in_mbps = bits_in / 1000000
rule:             bits_in_mbps > 900
message:          "Inbound traffic {{.custom.bits_in_mbps}} Mbps"
```

Names use letters, digits and underscores, start with a letter or underscore, are up to 50
characters long, and cannot be the name of an existing reading. A custom variable can use
device readings but not other custom variables.

## Alarm messages

The message is the text you see when the alarm fires and what is sent to your notification
channels. Insert live readings so every alarm tells you exactly what happened, on which
device:

```txt
OLT {{Hostname}} ({{IPAddress}}) is DOWN
Port {{Name}} Rx power: {{RxPower}} dBm
```

renders as:

```txt
OLT edge-olt-07 (10.20.1.4) is DOWN
Port GPON0/3 Rx power: -27.4 dBm
```

Placeholder names are case-sensitive and differ from the reading names in the rule builder:
`{{Hostname}}`, `{{IPAddress}}`, `{{Name}}`, `{{RxPower}}`, `{{CPULoad}}`. Custom
variables are written as `{{.custom.<name>}}`. Use the field picker in the Message editor:
it inserts the exact names for the report type you picked. Numbers are shown with up to two
decimals, and a reading the device does not report prints as `<nil>`.

:::tip
Put the key numbers right in the message (the value and, where relevant, the threshold).
Your team can often triage from the notification alone.
:::

## Revision history

Every saved change to a definition creates a new revision. The **Revision history** table at
the bottom of a definition's page lists each version with its changes, date and author. The
eye icon opens an old version, and **Compare with latest** there shows how it differs from
the current one. The compare icon on a row shows what changed since the version before it;
to compare any two versions, tick both and click **Compare**. Relay changes are not
versioned.

## Notifications (relays)

A relay is a channel that delivers alarms to your team. NetSense supports Slack, Telegram,
Alerta and generic webhooks. Relays are configured once under **Alarms → Alarm Relays**,
then attached to any alarm definitions that should use them. An alarm can notify several
channels at once, and the selector shows whether each relay is currently running.

Each relay chooses which events it sends: **OPENED** when the alarm is raised, **CLOSED**
when it clears (only for alarms that were announced), and **REMINDER** every 2 hours while
an alarm stays open and nobody has acknowledged it. Alarms still inside their alert delay
are never sent. See [Delivering alarms to Slack and Telegram](https://netsense-nms.com/docs/guides/alarm-relays/).

## Next steps

Alarm **delay** and **keep-alive** decide when an alarm opens and how long it stays open.
Getting them right is the difference between a quiet, trustworthy alarm list and a noisy
one; see [Alarm timing and lifecycle](https://netsense-nms.com/docs/guides/alarm-timing/).

Source: https://netsense-nms.com/docs/guides/alarm-definitions/index.mdx
