Alarms
the default offset is 0, the default limit is 10 results. To get all results, use limit=0 as a parameter on the URL (ie, GET /events?limit=0).
|
GETs (reading data)
| Resource | Description |
|---|---|
/alarms |
Get a list of alarms. |
/alarms/count |
Get the number of alarms (returns plaintext, rather than XML or JSON). |
/alarms/{id} |
Get the alarms specified by the given ID. |
Note that you can also query by severity:
| Resource | Description |
|---|---|
/alarms?comparator=ge&severity=MINOR |
Get the alarms with a severity greater than or equal to |
PUTs (modifying data)
PUT requires form data using application/x-www-form-urlencoded as a Content-Type.
| Resource | Description |
|---|---|
/alarms/{id}?ack=''(true;false)'' |
Acknowledges (or unacknowledges) an alarm. |
/alarms?x=y&…&ack=''(true;false)'' |
Acknowledges (or unacknowledges) alarms matching the additional query parameters (for example, |
/alarms/{id}?clear=true |
Clears an alarm. |
/alarms/{id}?escalate=true |
Escalates an alarm (for example, NORMAL → MINOR, MAJOR → CRITICAL). |
/alarms?x=y&…&clear=true |
Clears alarms matching the additional query parameters. |
/alarms?x=y&…&escalate=true |
Escalates alarms matching the additional query parameters. |
Additionally, when acknowledging alarms (ack=true) you can specify an ackUser parameter.
You will only be allowed to ack as a different user if you are PUTting as an authenticated user who is in the admin role.
v2 API
Since Horizon 20.1.0, an alarms endpoint has been available in the v2 API that uses FIQL for querying.
Examples:
-
/api/v2/alarms?_s=alarm.reductionKey==uei.opennms.org/nodes/nodeDown::* -
/api/v2/alarms?_s=alarm.uei==uei.opennms.org/nodes/nodeDown -
/api/v2/alarms?_s=alarm.ipAddr==127.0.0.1 -
/api/v2/alarms?_s=node.label==localhost
| If your query string includes a FIQL reserved character like a comma (,) or a semicolon (;) you need to double percent-escape it. |
Suppose you have a service with a comma in the name, like COMMA,SERVICE and you want to retrieve all the alarms for its failure.
Your query would look like /api/v2/alarms?_s=alarm.reductionKey==uei.opennms.org/nodes/nodeLostService::*:COMMA%252CSERVICE.
Version 2 (/api/v2/alarms)
The v2 alarms endpoint is rooted at /api/v2/alarms and shares the common v2 DAO REST behavior (FIQL querying, paging, and properties introspection) in addition to alarm-specific write operations.
As with other v2 endpoints, the default offset is 0 and the default limit is 10 results.
Use limit=0 to return all results.
List queries return 204 No Content when no alarms match.
|
GETs (reading data)
| Resource | Description |
|---|---|
/api/v2/alarms |
Get a list of alarms. Supports FIQL querying via |
/api/v2/alarms/count |
Get the number of alarms matching the (optional) query (returns plaintext, rather than XML or JSON). |
/api/v2/alarms/properties |
Get the list of searchable/orderable properties supported by this endpoint. Accepts an optional |
/api/v2/alarms/properties/{propertyId} |
Get the distinct values for the given property. Accepts optional |
/api/v2/alarms/{id} |
Get the alarm specified by the given ID. Returns |
POSTs (creating data)
| Resource | Description |
|---|---|
/api/v2/alarms/{id}/ticket/create |
Create a trouble ticket for the given alarm. Returns |
/api/v2/alarms/{id}/ticket/update |
Update the trouble ticket associated with the given alarm. Returns |
/api/v2/alarms/{id}/ticket/close |
Close the trouble ticket associated with the given alarm. Returns |
Creating an alarm is not supported. POST /api/v2/alarms is inherited but not implemented and returns 501 Not Implemented.
|
PUTs (modifying data)
| Resource | Description |
|---|---|
/api/v2/alarms |
Bulk-update all alarms matching the supplied query (FIQL via |
/api/v2/alarms/{id} |
Update properties of the alarm using |
/api/v2/alarms/{id}/memo |
Set the sticky memo on the alarm. Requires |
/api/v2/alarms/{id}/journal |
Set the journal (reduction-key) memo on the alarm. Same form fields and response codes as |
The form fields supported by PUT /api/v2/alarms/{id} (and by the bulk PUT /api/v2/alarms) are:
| Field | Description |
|---|---|
ack |
|
ackUser |
The user to record for the acknowledgment. Defaults to the authenticated user. You may only acknowledge as a different user if you are authenticated as a user in the admin role. |
clear |
|
escalate |
|
ticketId |
Sets the trouble-ticket ID on the alarm. |
ticketState |
Sets the trouble-ticket state on the alarm (must be a valid |
When several of ack, escalate, and clear are supplied together, only one acknowledgment action is processed, evaluated in the order ack, then escalate, then clear. The ticketId/ticketState fields are applied independently of the acknowledgment action.
|
DELETEs (removing data)
| Resource | Description |
|---|---|
/api/v2/alarms/{id}/memo |
Remove the sticky memo from the alarm. Returns |
/api/v2/alarms/{id}/journal |
Remove the journal (reduction-key) memo from the alarm. Returns |
Deleting an alarm is not supported. DELETE /api/v2/alarms and DELETE /api/v2/alarms/{id} are inherited but not implemented and return 501 Not Implemented.
|
Examples using cURL
curl -u admin:admin -X PUT \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "ack=true" \
http://127.0.0.1:8980/opennms/api/v2/alarms/42
curl -u admin:admin -X PUT \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "body=Investigating this alarm" \
--data-urlencode "user=admin" \
http://127.0.0.1:8980/opennms/api/v2/alarms/42/memo
curl -u admin:admin -X POST \
http://127.0.0.1:8980/opennms/api/v2/alarms/42/ticket/create