mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added ability to set a custom SQL query for alert rules. (#9094)
* Added support for AVG in rules * More updates * Final work to have advanced sql queries * Added missing use * Fix exception when invalid json is passed * Fixed api for alert rules * updated docs
This commit is contained in:
committed by
Tony Murray
parent
53a1730fc7
commit
466b5a35a8
@@ -84,7 +84,6 @@ Output:
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"message": "",
|
||||
"message": "Alert has been unmuted"
|
||||
}
|
||||
```
|
||||
@@ -243,8 +242,8 @@ Route: `/api/v0/rules`
|
||||
|
||||
Input (JSON):
|
||||
|
||||
- device_id: This is either the device id or -1 for a global rule
|
||||
- rule: The rule which should be in the format %entity $condition $value (i.e %devices.status != 0 for devices marked as down).
|
||||
- devices: This is either an array of device ids or -1 for a global rule
|
||||
- builder: The rule which should be in the format entity.condition value (i.e devices.status != 0 for devices marked as down). It must be json encoded in the format rules are currently stored.
|
||||
- severity: The severity level the alert will be raised against, Ok, Warning, Critical.
|
||||
- disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled
|
||||
- count: This is how many polling runs before an alert will trigger and the frequency.
|
||||
@@ -255,7 +254,7 @@ Input (JSON):
|
||||
|
||||
Example:
|
||||
```curl
|
||||
curl -X POST -d '{"device_id":"-1", "rule":"%devices.os != \"Cisco\"","severity": "critical","count":15,"delay":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
|
||||
curl -X POST -d '{"device_id":[1,2,3], "name": "testrule", builder":"{\"condition\":\"AND\",\"rules\":[{\"id\":\"devices.hostname\",\"field\":\"devices.hostname\",\"type\":\"string\",\"input\":\"text\",\"operator\":\"equal\",\"value\":\"localhost\"}],\"valid\":true}","severity": "critical","count":15,"delay":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
|
||||
```
|
||||
|
||||
Output:
|
||||
@@ -278,8 +277,8 @@ Route: `/api/v0/rules`
|
||||
Input (JSON):
|
||||
|
||||
- rule_id: You must specify the rule_id to edit an existing rule, if this is absent then a new rule will be created.
|
||||
- device_id: This is either the device id or -1 for a global rule
|
||||
- rule: The rule which should be in the format %entity $condition $value (i.e %devices.status != 0 for devices marked as down).
|
||||
- devices: This is either an array of device ids or -1 for a global rule
|
||||
- builder: The rule which should be in the format entity.condition value (i.e devices.status != 0 for devices marked as down). It must be json encoded in the format rules are currently stored.
|
||||
- severity: The severity level the alert will be raised against, Ok, Warning, Critical.
|
||||
- disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled
|
||||
- count: This is how many polling runs before an alert will trigger and the frequency.
|
||||
@@ -290,7 +289,7 @@ Input (JSON):
|
||||
|
||||
Example:
|
||||
```curl
|
||||
curl -X PUT -d '{"rule_id":1,"device_id":"-1", "rule":"%devices.os != \"Cisco\"","severity": "critical","count":15,"delay":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
|
||||
curl -X PUT -d '{"rule_id":1,"device_id":"-1", "name": "testrule", "builder":"{\"condition\":\"AND\",\"rules\":[{\"id\":\"devices.hostname\",\"field\":\"devices.hostname\",\"type\":\"string\",\"input\":\"text\",\"operator\":\"equal\",\"value\":\"localhost\"}],\"valid\":true}","severity": "critical","count":15,"delay":"5 m","mute":false}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/rules
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
Reference in New Issue
Block a user