Metric conditions
A metric condition is an alert rule for host metrics, for example "disk usage above 90 for 10 minutes". You add it to one host or to a project. When the condition holds for its duration, Spectate fires an alert with the condition's severity. A separate setting fires an alert when a host stops reporting.
How a condition works
A metric condition has these parts:
| Part | Values |
|---|---|
| Metric | A host metric, for example disk_usage or system.load.5. See metrics and units. |
| Condition | greater_than, less_than or equals |
| Threshold | A number, in the unit of the metric. For example, 90 for 90% disk usage. |
| For | How long the condition must hold before it fires: Immediately, 1 minute, 2 minutes, 5 minutes, 10 minutes, 15 minutes, 30 minutes or 1 hour. The default is Immediately. |
| Severity | Critical, High, Medium or Low. The default is Medium. |
Spectate checks the conditions each time the agent sends data, once a minute:
- If the metric has more than one series, one series is enough. For example, one full mountpoint fires a
disk_usagecondition. The alert title names the series, such asmountpoint=/data. - A breach that is shorter than For does not fire. If the host sends no data for 5 minutes, the count starts again.
equalsmatches values within 0.001 of the threshold.- Spectate does not check data that the agent sends late from its disk buffer, if the newest sample is more than 5 minutes old. This prevents alerts about old data.
The alert title has the metric, the threshold and the host, for example Disk usage above 90 on web-01 (mountpoint=/). When the value is back on the right side of the threshold, Spectate resolves the alert. Spectate fires one alert per condition and host at a time.
The alert goes to the host's escalation paths. Set them on the host under Settings & alerts → Alerting.
Add a condition to a host
Owners, managers and admins can add conditions.
- Open the host and go to Settings & alerts.
- Under Metric conditions, select Add condition.
- Select the Metric.
- Select the Condition.
- Type the Threshold.
- Under For, select how long the condition must hold.
- Select the Severity.
- Select Create condition.
You cannot edit a condition. To change it, delete it and add a new one. In the row of the condition, select the delete icon (Delete condition).
Add a condition to a project
A condition on a project applies to every host in that project, also to hosts that join later.
- Go to Projects and open the project.
- Under Metric conditions, select Add condition.
- Fill in the fields as for a host, then select Create condition.
The Metric conditions list on a host shows only the conditions of that host. The host also uses the conditions of its project. If a host has a condition and its project has the same condition, Spectate evaluates both.
Alert when a host stops reporting
The "Host stops reporting" alert fires when Spectate gets no data from the agent for a set time. For example, the server is down, the agent stopped, or the network is down.
| Setting | Value |
|---|---|
| Default | On, after 5 minutes |
| Range | 2 to 1,440 minutes |
| Severity | High. You cannot change it. |
To change it:
- Open the host and go to Settings & alerts.
- Under Alerting, find Host stops reporting.
- Turn the alert on or off.
- In Silent for, type the number of minutes.
- Select Save changes.
Spectate checks every minute. The alert title is No data received from followed by the host's label. The alert resolves as soon as the agent reports again.
The alert does not fire in these cases:
- The agent never reported. The host is still
pending. - Spectate paused the host, for example because the team is over its plan limit.
- An alert of this type is already open for the host.
If you turn the alert off or make the time longer, Spectate resolves a firing alert.
Use the API
The public API can list, create, get and delete metric conditions. It needs a team API token with hosts:read to read and hosts:write to create. Deleting needs hosts:delete.
Code
duration_minutes is 0 to 60. Use host_ids, project_ids or both. To change the "Host stops reporting" time, update the host with no_data_alert_minutes. Use null to turn the alert off.