updated monitor notify docs to address PR feedback

pull/1977/head
Scott Anderson 2020-12-11 15:09:36 -07:00
parent aae77497f8
commit a1d02f6175
1 changed files with 40 additions and 1 deletions

View File

@ -50,10 +50,13 @@ The data record must contain the following fields:
The InfluxDB monitoring and alerting system uses `monitor.notify()` to store
information about sent notifications and automatically assigns these values.
If writing a custom notification [task](/influxdb/v2.0/process-data/),
use **unique arbitrary values**.
use **unique arbitrary values** for data record fields.
## Examples
- [Send a notification to Slack](#send-a-notification-to-slack)
- [Send a notification to PagerDuty](#send-a-notification-to-pagerduty)
### Send a notification to Slack
```js
import "influxdata/influxdb/monitor"
@ -82,3 +85,39 @@ from(bucket: "system")
data: notification_data
)
```
### Send a notification to PagerDuty
```js
import "influxdata/influxdb/monitor"
import "influxdata/influxdb/secrets"
import "pagerduty"
routingKey = secrets.get(key: "PAGERDUTY_ROUTING_KEY")
endpoint = pagerduty.endpoint()(mapFn: (r) => ({
routingKey: routingKey,
client: "ExampleClient",
clientURL: "http://examplepagerdutyclient.com",
dedupkey: "ExampleDedupKey",
class: "cpu usage",
group: "app-stack",
severity: "ok",
eventAction: "trigger",
source: "monitoringtool:vendor:region",
timestamp: r._source_timestamp
}))()
notification_data = {
_notification_rule_id: "0000000000000001",
_notification_rule_name: "example-rule-name",
_notification_endpoint_id: "0000000000000002",
_notification_endpoint_name: "example-endpoint-name",
}
from(bucket: "system")
|> range(start: -5m)
|> monitor.notify(
endpoint: endpoint,
data: notification_data
)
```