Alert Policies
Overview
WEDA's monitoring workflow has two parts that work together:
- Alert Policy — evaluates incoming values from one or more DataStreams against trigger and reset conditions
- Notification Channel — defines how an alert message is delivered, such as by email, Teams, LINE, or webhook
An Alert Policy is an independent, Org-level resource — unlike the DataStream it monitors, it isn't owned by any single device. Attach it to one or more DataStreams (at any layer: a raw device stream or an Analyzer's output) via a dedicated attach/detach call. See Notification Channels to configure delivery endpoints first.
An Alert Policy monitors the value of every DataStream attached to it. WEDA evaluates the policy whenever new telemetry arrives on any attached DataStream.
Each policy has these evaluation parameters:
| Parameter | Description |
|---|---|
alertLevel | A comparison expression that defines when an alert is triggered, such as >=75 |
alertResetLevel | A comparison expression that defines when the value has returned to its normal range, such as <70 |
delay | Debounce window in seconds. A condition must hold for this long before it takes effect. Optional, defaults to 0 (no debounce) |
The delay applies to both directions. A trigger condition must hold for the delay before an alert
fires, and the reset condition must hold for the delay before the alert is resolved. With the
default 0, both take effect immediately.
Supported conditions
alertLevel and alertResetLevel are threshold expressions evaluated against the incoming
DataStream value. Both are required, and both carry the comparison operator inside the string
itself — for example alertLevel: ">=70" with alertResetLevel: "<65".
The API declares these two fields as free-form strings and documents them by example. It does not
publish the full grammar — which operators are accepted, and whether anything beyond a single
comparison works. Stay with the documented >=70 / <65 form unless RD confirms otherwise.
Operations
| Operation | API | Description |
|---|---|---|
| Create Alert Policy | POST /api/v1/orgs/{orgId}/alert-policies | Define a new policy |
| List Alert Policies | GET /api/v1/orgs/{orgId}/alert-policies | List policies in the Org (filter by dataStreamId to find policies attached to a specific DataStream) |
| Get Alert Policy | GET /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId} | Get one policy by ID |
| Update Alert Policy | PATCH /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId} | Update the policy or its notification settings |
| Delete Alert Policy | DELETE /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId} | Remove a policy (must be disabled first) |
| Enable / Disable | POST /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId}:{action} | Enable or disable a policy without deleting it |
| List Attached DataStreams | GET /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId}/data-streams | DataStreams currently attached |
| Set Attached DataStreams | PUT /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId}/data-streams | Replace the full attachment set |
| List Alert Events | GET /api/v1/orgs/{orgId}/alert-events | Query fired alert history |
Create Alert Policy
POST /api/v1/orgs/{orgId}/alert-policies
See Create Alert Policy for the full field reference. A policy is created disabled — call the enable action once it's ready to evaluate.
Notification message
The notification object is optional. If provided, specify the destination with channelIds and
recipients, then use one of the following methods to define the message:
- Provide
templateIdand, when required by the template,variables. - Provide both
subjectandcontentdirectly.
Do not combine templateId with subject or content in the same request.
Attach / Detach DataStreams
PUT /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId}/data-streams
This is a full-replacement call, not an incremental add/remove: the DataStreams you include become attached, and any previously attached DataStream left out of the request is detached. Sending an empty array detaches all DataStreams from the policy.
[
{ "deviceId": "cc827f50f406", "dataStreamId": "a1b2c3d4-..." }
]
Enable / Disable
POST /api/v1/orgs/{orgId}/alert-policies/{alertPolicyId}:{action}
action is enable or disable. Disabling a policy stops it from evaluating new telemetry
without deleting its configuration or attachment set.
Alert Events
GET /api/v1/orgs/{orgId}/alert-events
Every fired alert is recorded as an Alert Event you can query independently of the policy that
produced it — useful for building a history/audit view. Filter by status, alertPolicyId,
deviceId, or a start/end time range.
Each event snapshots the policy's policyName and alertLevel at fire time (not a live join to
the current policy), plus the dataStreamId and triggeredValue that caused it, and
firedTime/acknowledgedTime/acknowledgedBy/resolvedTime/resolvedBy.
Reading the nullable timestamp fields:
acknowledgedTimeandacknowledgedByarenulluntil the event is acknowledged.resolvedTimeisnulluntil the event is resolved.resolvedBybeingnullon a resolved event means it was resolved automatically by the reset condition, not that it is still open. CheckresolvedTimeorstatusto tell the difference.
An event's status can be Firing, Acknowledged, or Resolved, but WEDA v1.1.1 exposes only
the query endpoint above — there is no public API for acknowledging an event. Support for it is
planned for a future release. Until then, events reach Resolved automatically when the reset
condition holds for the policy's delay.
Scenario
A monitoring engineer sets up a temperature alert on a factory device. The temperature stream
(AI_0) should send an alert if its value reaches 75°C and does not return below 70°C during the
10-second delay:
Constraints
alertLevelandalertResetLevelmust be valid expressions compatible with the DataStream'sdataType, and must not be identicalchannelIdsmust reference existing notification channels- A policy must be disabled before it can be deleted
- The
PUT .../data-streamscall replaces the full attachment set — omitting a currently-attached DataStream detaches it - A DataStream can be attached to more than one Alert Policy, and an Alert Policy can attach to more than one DataStream — this is a many-to-many relationship, unlike the one-rule-per-stream limit of the previous release
Related
- Find the
dataStreamIdto attach a policy to: DataStreams - Set up notification channels: Notification Channels
- Apply a policy to a computed value: Analyzers