From ae8b4b48ab4bd35b759a6785a0ef348e0b1107c2 Mon Sep 17 00:00:00 2001 From: Kelly Date: Tue, 15 Sep 2020 11:20:18 -0700 Subject: [PATCH 01/12] upd error issue --- .../about_the_project/releasenotes-changelog.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md index df4c4a793..e2d431329 100644 --- a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md +++ b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md @@ -6,6 +6,19 @@ menu: parent: About the project --- +## v1.5.7 [2020-08-27] + +## Features + +- Add support for templating URLs in the [`httpPost` node](/kapacitor/v1.5/nodes/http_post_node/) and [`alert` node](/kapacitor/v1.5/nodes/alert_node/). To set up an template: + - For the `alert` node, see [alert templates](/kapacitor/v1.5/event_handlers/post/#alert-templates). + - For the `http post` node, see [row templates](/kapacitor/v1.5/event_handlers/post/#row-templates). +- Upgrade `github.com/gorhill/cronexpr`, thanks @wuguanyu! + +### Bug fixes + +- Add error check when the system fails to read the replay file, thanks @johncming! + ## v1.5.6 [2020-07-17] ## Features From 2382d88288a55d5ad1051e97408d638199a224cc Mon Sep 17 00:00:00 2001 From: Kelly Date: Wed, 16 Sep 2020 10:48:28 -0700 Subject: [PATCH 02/12] changes for kapacitor 1.5.7 --- .../releasenotes-changelog.md | 4 +- content/kapacitor/v1.5/event_handlers/post.md | 45 ++++++++++--- content/kapacitor/v1.5/nodes/alert_node.md | 65 ++----------------- 3 files changed, 42 insertions(+), 72 deletions(-) diff --git a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md index e2d431329..1c0f1487d 100644 --- a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md +++ b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md @@ -23,8 +23,8 @@ menu: ## Features -- Add [Microsoft Teams event handler](/kapacitor/1.5/event_handlers/microsoftteams/), thanks @mmindenhall! -- Add [Discord event handler](/kapacitor/1.5/event_handler/discord/), thanks @mattnotmitt! +- Add [Microsoft Teams event handler](/kapacitor/v1.5/event_handlers/microsoftteams/), thanks @mmindenhall! +- Add [Discord event handler](/kapacitor/v1.5/event_handler/discord/), thanks @mattnotmitt! - Add [support for TLS 1.3](/kapacitor/v1.5/administration/configuration/#transport-layer-security-tls-settings). ### Bug fixes diff --git a/content/kapacitor/v1.5/event_handlers/post.md b/content/kapacitor/v1.5/event_handlers/post.md index 019c1126e..d69a64569 100644 --- a/content/kapacitor/v1.5/event_handlers/post.md +++ b/content/kapacitor/v1.5/event_handlers/post.md @@ -12,11 +12,13 @@ menu: The post event handler posts JSON encoded data to an HTTP endpoint. ## Configuration + Configuration as well as default [option](#options) values for the post event handler are set in your `kapacitor.conf`. Below is an example configuration: ### Post Settings in kapacitor.conf + ```toml [[httppost]] endpoint = "example" @@ -30,40 +32,49 @@ Below is an example configuration: ``` #### `endpoint` + Name of a configured HTTP POST endpoint that acts as an identifier for `[[httppost]]` configurations when multiple are present. _Endpoints are identifiers only. They are not appended to HTTP POST URLs._ #### `url` + The URL to which the alert data will be posted. #### `headers` + Set of extra header values to set on the POST request. #### `basic-auth` + Set of authentication credentials to set on the POST request. #### `alert-template` + Alert template for constructing a custom HTTP body. Alert templates are only used with post [alert](/kapacitor/v1.5/nodes/alert_node/) handlers as they consume alert data. _Skip to [alert templating](#alert-templates)._ #### `alert-template-file` + Absolute path to an alert template file. _Skip to [alert templating](#alert-templates)._ #### `row-template` + Row template for constructing a custom HTTP body. Row templates are only used with the [httpPost node](/kapacitor/v1.5/nodes/http_post_node/) pipeline nodes as they consume a row at a time. _Skip to [row templating](#row-templates)._ #### `row-template-file` + Absolute path to a row template file. _Skip to [row templating](#row-templates)._ ### Defining configuration options with environment variables + The `endpoint`, `url`, and `headers` configuration options can be defined with environment variables: @@ -75,6 +86,7 @@ KAPACITOR_HTTPPOST_0_HEADERS_Example2 = "header2" ``` ### Configuring and using multiple HTTP POST endpoints + The `kapacitor.conf` supports multiple `[[httppost]]` sections. The [`endpoint`](#endpoint) configuration option of each acts as a unique identifier for that specific configuration. To use a specific `[[httppost]]` configuration with the Post alert handler, @@ -110,6 +122,7 @@ KAPACITOR_HTTPPOST_1_HEADERS_Example2 = "header2" ``` ## Options + The following post event handler options can be set in a [handler file](/kapacitor/v1.5/event_handlers/#create-a-topic-handler-with-a-handler-file) or when using `.post()` in a TICKscript. @@ -124,6 +137,7 @@ The following post event handler options can be set in a | skipSSLVerification | bool | Disables SSL verification for the POST request. | ### Example: Handler file - Using a pre-configured endpoint + ```yaml id: handler-id topic: topic-name @@ -134,6 +148,7 @@ options: ``` ### Example: Handler file - Defining post options "inline" + ```yaml id: handler-id topic: topic-name @@ -150,6 +165,7 @@ options: ``` ### Example: TICKscript - Using a pre-configured endpoint + ```js |alert() // ... @@ -159,6 +175,7 @@ options: ``` ### Example: TICKscript - Defining post options "inline" + ```js |alert() // ... @@ -172,6 +189,7 @@ options: ``` ## Using the Post event handler + The post event handler can be used in both TICKscripts and handler files to post alert and HTTP POST data to an HTTP endpoint. The examples below deal with alerts and use the same `[[httppost]]` configuration @@ -187,6 +205,7 @@ _**HTTP POST settings in kapacitor.conf**_ ``` ### Post alerts from a TICKscript + The following TICKscripts use the `.post()` event handler to post the message, "Hey, check your CPU", whenever idle CPU usage drops below 10%. @@ -221,8 +240,8 @@ stream .skipSSLVerification() ``` - ### Post alerts from a defined handler + The following setup sends an alert to the `cpu` topic with the message, "Hey, check your CPU". A post handler is added that subscribes to the `cpu` topic and posts all alert @@ -270,12 +289,13 @@ Add the handler: kapacitor define-topic-handler post_cpu_handler.yaml ``` - ## Post templating + The post event handler allows you to customize the content and structure of POSTs with alert and row templates. ### Alert templates + Alert templates are used to construct a custom HTTP body. They are only used with post [alert](/kapacitor/v1.5/nodes/alert_node/) handlers as they consume alert data. @@ -299,20 +319,22 @@ have access to the following fields: | .Recoverable | Indicates whether or not the alert is auto-recoverable. | #### Inline alert template + _**kapacitor.conf**_ ```toml [[httppost]] - endpoint = "example" - url = "http://example.com/path" + endpoint = "host" + url = "host={{index .ID \"host\"}}{{index . "time"}}{{end}}}" alert-template = "{{.Message}}:{{range .Data.Series}}{{.Tags}},{{range .Values}}{{.}}{{end}}{{end}}" ``` #### Alert template file + _**kapacitor.conf**_ ```toml [[httppost]] - endpoint = "example" - url = "http://example.com/path" + endpoint = "host" + url = "host={{index .ID \"host\"}}{{index . "time"}}{{end}}}" alert-template-file = "/etc/templates/alert.html" ``` @@ -322,6 +344,7 @@ _**/etc/templates/alert.html**_ ``` ### Row templates + Row templates are used to construct a custom HTTP body. They are only used with [httpPost](/kapacitor/v1.5/nodes/http_post_node/) handlers as they consume a row at a time. @@ -339,20 +362,22 @@ have access to the following fields: | .Values | A list of values; each a map containing a "time" key for the time of the point and keys for all other fields on the point. | #### Inline row template + _**kapacitor.conf**_ ```toml [[httppost]] - endpoint = "example" - url = "http://example.com/path" + endpoint = "host" + url = "host={{index .Tags \"host\"}}{{range .Values}} {{index . "time"}} {{index . "value"}}{{end}}" row-template = '{{.Name}} host={{index .Tags "host"}}{{range .Values}} {{index . "time"}} {{index . "value"}}{{end}}' ``` #### Row template file + _**kapacitor.conf**_ ```toml [[httppost]] - endpoint = "example" - url = "http://example.com/path" + endpoint = "host" + url = "host={{index .Tags \"host\"}}{{range .Values}} {{index . "time"}} {{index . "value"}}{{end}}" row-template-file = "/etc/templates/row.html" ``` diff --git a/content/kapacitor/v1.5/nodes/alert_node.md b/content/kapacitor/v1.5/nodes/alert_node.md index c835c4980..193a0bc9b 100644 --- a/content/kapacitor/v1.5/nodes/alert_node.md +++ b/content/kapacitor/v1.5/nodes/alert_node.md @@ -19,12 +19,11 @@ See [AlertNode.Info](/kapacitor/v1.5/nodes/alert_node/#info), [AlertNode.Warn](/kapacitor/v1.5/nodes/alert_node/#warn), and [AlertNode.Crit](/kapacitor/v1.5/nodes/alert_node/#crit) below. - ### Constructor | Chaining method | Description | |:---------|:---------| -| **alert ( )** | Create an alert node, which can trigger alerts. | +| **alert ( )** | Create an alert node, which can trigger alerts.

To dynamically construct a custom HTTP body or URL, use an [**alert template**](/kapacitor/v1.5/event_handlers/post/#alert-templates). For example, `httpPost('localhost/?host={{ index .Tags "host"}}&cpu={{ index .Tags "cpu" }}')`.

| ### Property methods @@ -75,8 +74,6 @@ and [AlertNode.Crit](/kapacitor/v1.5/nodes/alert_node/#crit) below. | **[warn](#warn) ( `value` `ast.LambdaNode`)** | Filter expression for the WARNING alert level. An empty value indicates the level is invalid and is skipped. | | **[warnReset](#warnreset) ( `value` `ast.LambdaNode`)** | Filter expression for resetting the WARNING alert level to lower level. | - - ### Chaining methods [Alert](#alert), [Barrier](#barrier), @@ -130,7 +127,6 @@ and [AlertNode.Crit](/kapacitor/v1.5/nodes/alert_node/#crit) below. --- - #### Available event handlers Different event handlers can be configured for each [AlertNode.](/kapacitor/v1.5/nodes/alert_node/) @@ -161,7 +157,6 @@ option, `global`, that indicates that all alerts implicitly use the handler. | [Telegram](#telegram) | Post alert message to Telegram client. | | [VictorOps](#victorops) | Send alert to VictorOps. | - #### Alert event data Each event that gets sent to a handler contains the following alert data: @@ -201,7 +196,6 @@ stream .email('oncall@example.com') ``` - Each expression maintains its own state. The order of execution for the expressions is not considered to be deterministic. For each point an expression may or may not be evaluated. @@ -240,8 +234,6 @@ For example, given the following values, the corresponding alert states are: | 56 | INFO | | 47 | OK | - - **Available Statistics:** * `alerts_triggered`: Total number of alerts triggered @@ -252,14 +244,12 @@ For example, given the following values, the corresponding alert states are: - ## Properties Property methods modify state on the calling node. They do not add another node to the pipeline, and always return a reference to the calling node. Property methods are marked using the `.` operator. - ### Alerta Send the alert to Alerta. @@ -285,7 +275,6 @@ stream .event('Something went wrong') ``` - ### All Indicates an alert should trigger only if all points in a batch match the criteria. @@ -297,7 +286,6 @@ alert.all() - ### Category Category places this alert in a named category. @@ -310,7 +298,6 @@ alert.category(value string) - ### Crit Filter expression for the CRITICAL alert level. @@ -322,7 +309,6 @@ alert.crit(value ast.LambdaNode) - ### CritReset Filter expression for resetting the CRITICAL alert level to lower level. @@ -333,7 +319,6 @@ alert.critReset(value ast.LambdaNode) - ### Details Template for constructing a detailed HTML message for the alert. @@ -394,7 +379,6 @@ stream - ### DurationField Optional field key to add the alert duration to the data. @@ -406,7 +390,6 @@ alert.durationField(value string) - ### Email Email the alert data to specified "To" email addresses. @@ -444,7 +427,6 @@ Value: {{ index .Fields "value" }} - ### Exec Execute a command whenever an alert is triggered and pass the alert data over STDIN in JSON format. @@ -461,7 +443,6 @@ alert.exec('/usr/bin/python', 'myscript.py') - ### Flapping Perform flap detection on the alerts. @@ -488,7 +469,6 @@ alert.flapping(0.25, 0.5) - ### Kafka Send the alert to an Apache Kafka cluster. @@ -515,7 +495,6 @@ stream - ### History Number of previous states to remember when computing flapping levels and @@ -534,7 +513,6 @@ alert.history(21) - ### HipChat Send the alert to HipChat. @@ -561,7 +539,6 @@ stream - ### Id Template for constructing a unique ID for a given alert. @@ -625,7 +602,6 @@ Resulting ID: `kapacitor/authentication/auth001.example.com` - ### IdField Optional field key to add to the data, containing the alert ID as a string. @@ -640,7 +616,6 @@ alert.idField('id') - ### IdTag Optional tag key to use when tagging the data with the alert ID. @@ -655,7 +630,6 @@ alert.idTag('alertID') - ### Info Filter expression for the INFO alert level. @@ -671,7 +645,6 @@ alert.info(lambda: 'usage_idle' < 60) - ### InfoReset Filter expression for resetting the INFO alert level to lower level. @@ -686,7 +659,6 @@ alert.infoReset(lamda: 'usage_idle' > 60) - ### Inhibit Inhibit other alerts in a category. @@ -725,7 +697,6 @@ alert.inhibit(category string, equalTags ...string) - ### Kafka Send the alert to a Kafka topic. @@ -751,7 +722,6 @@ stream - ### LevelField Optional field key to add to the data, containing the alert level as a string. @@ -766,7 +736,6 @@ alert.levelField('INFO') - ### LevelTag Optional tag key to use when tagging the data with the alert level. @@ -781,7 +750,6 @@ alert.levelTag('level') - ### Log Log JSON alert data to file. @@ -798,7 +766,6 @@ stream - ### Message Template for constructing a meaningful message for the alert. @@ -836,7 +803,6 @@ Resulting Message: authentication/auth001.example.com is CRITICAL value:42 - ### MessageField Optional field key to add to the data containing the alert message. @@ -851,7 +817,6 @@ alert.messageField('message') - ### MQTT Send alert to an MQTT broker. @@ -880,7 +845,6 @@ stream - ### NoRecoveries Do not send recovery alerts. Sets `recoverable` alert data field to `false`. @@ -891,8 +855,8 @@ alert.noRecoveries() - ### OpsGenie v1 + Send alert to OpsGenie using OpsGenie's v1 API. Detailed configuration options and setup instructions are provided in the [OpsGenie v1 Event Handler](/kapacitor/v1.5/event_handlers/opsgenie/v1/) article. @@ -915,8 +879,8 @@ stream - ### OpsGenie v2 + Send alert to OpsGenie using OpsGenie's v2 API. Detailed configuration options and setup instructions are provided in the [OpsGenie v2 Event Handler](/kapacitor/v1.5/event_handlers/opsgenie/v2/) article. @@ -939,8 +903,8 @@ stream - ### PagerDuty v1 + Send the alert to PagerDuty using PagerDuty's v1 API. Detailed configuration options and setup instructions are provided in the [PagerDuty v1 Event Handler](/kapacitor/v1.5/event_handlers/pagerduty/v1/) article. @@ -962,8 +926,8 @@ stream - ### PagerDuty v2 + Send the alert to PagerDuty using PagerDuty's v2 API. Detailed configuration options and setup instructions are provided in the [PagerDuty v2 Event Handler](/kapacitor/v1.5/event_handlers/pagerduty/v2/) article. @@ -985,7 +949,6 @@ stream - ### Post HTTP POST JSON alert data to a specified URL. @@ -1003,7 +966,6 @@ stream - ### Pushover Send the alert to Pushover. @@ -1033,7 +995,6 @@ stream - ### Quiet Suppress all error logging events from this node. @@ -1044,7 +1005,6 @@ alert.quiet() - ### Sensu Send the alert to Sensu. @@ -1070,7 +1030,6 @@ stream - ### Slack Send the alert to Slack. @@ -1096,8 +1055,6 @@ stream - - ### SnmpTrap Send the alert using SNMP traps. @@ -1123,7 +1080,6 @@ stream - ### StateChangesOnly Only sends events where the state changed. @@ -1167,7 +1123,6 @@ stream - ### Talk Send the alert to Talk. @@ -1191,7 +1146,6 @@ stream - ### TCP Send JSON alert data to a specified address over TCP. @@ -1208,7 +1162,6 @@ alert.tcp('127.0.0.1:7777') - ### Telegram Send the alert to Telegram. @@ -1236,8 +1189,6 @@ stream - - ### Topic Topic specifies the name of an alert topic to which alerts will be published. @@ -1253,7 +1204,6 @@ alert.topic('cpu') - ### VictorOps Send alert to VictorOps. @@ -1278,8 +1228,6 @@ stream - - ### Warn Filter expression for the WARNING alert level. @@ -1295,7 +1243,6 @@ alert.warn(lambda: 'usage_idle' < 20) - ### WarnReset Filter expression for resetting the WARNING alert level to lower level. @@ -1310,14 +1257,12 @@ alert.warnReset(lambda: 'usage_idle' > 20) - ## Chaining Methods Chaining methods create a new node in the pipeline as a child of the calling node. They do not modify the calling node. Chaining methods are marked using the `|` operator. - ### Alert Create an alert node, which can trigger alerts. From c8be108fdd5a5294d1f37ec5c0387b860f510afd Mon Sep 17 00:00:00 2001 From: Kelly Date: Wed, 16 Sep 2020 10:54:12 -0700 Subject: [PATCH 03/12] update httpPost node --- content/kapacitor/v1.5/nodes/http_post_node.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/content/kapacitor/v1.5/nodes/http_post_node.md b/content/kapacitor/v1.5/nodes/http_post_node.md index 21f46f39e..9f3709ea8 100644 --- a/content/kapacitor/v1.5/nodes/http_post_node.md +++ b/content/kapacitor/v1.5/nodes/http_post_node.md @@ -18,7 +18,6 @@ method on httpPost. Multiple endpoint property methods may be specified. Example: - ```js stream |window() @@ -43,12 +42,11 @@ stream .endpoint('example') ``` - ### Constructor | Chaining Method | Description | |:---------|:---------| -| **httpPost ( `url` `...string`)** | Creates an HTTP Post node that POSTS received data to the provided HTTP endpoint. HttpPost expects 0 or 1 arguments. If 0 arguments are provided, you must specify an endpoint property method. | +| **httpPost ( `url` `...string`)** | Creates an HTTP Post node that POSTS received data to the provided HTTP endpoint. HttpPost expects 0 or 1 arguments. If 0 arguments are provided, you must specify an endpoint property method.

To dynamically construct a custom HTTP body or URL, use a [**row template**](/kapacitor/v1.5/event_handlers/post/#row-templates ). For example: `httpPost('localhost/?host={{ index .Tags "host"}}&cpu={{ index .Tags "cpu" }}')`. ### Property Methods From c10db52921b3cd9a99ea18c29cd5f77cb204ea4e Mon Sep 17 00:00:00 2001 From: Kelly Date: Mon, 26 Oct 2020 12:47:59 -0700 Subject: [PATCH 04/12] kapacitor 1.8.7 RN upds --- .../v1.5/about_the_project/releasenotes-changelog.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md index 1c0f1487d..0db89683b 100644 --- a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md +++ b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md @@ -6,18 +6,21 @@ menu: parent: About the project --- -## v1.5.7 [2020-08-27] +## v1.5.7 [2020-10-26] ## Features +- Add the `.RecoveryAction()` method to support overriding the OpsGenieV2 alert recovery action in a TICKscript, thanks @zabullet! - Add support for templating URLs in the [`httpPost` node](/kapacitor/v1.5/nodes/http_post_node/) and [`alert` node](/kapacitor/v1.5/nodes/alert_node/). To set up an template: - For the `alert` node, see [alert templates](/kapacitor/v1.5/event_handlers/post/#alert-templates). - For the `http post` node, see [row templates](/kapacitor/v1.5/event_handlers/post/#row-templates). - Upgrade `github.com/gorhill/cronexpr`, thanks @wuguanyu! +- Add the [ServiceNow event handler](/kapacitor/v1.5/event_handlers/servicenow/) to support ServiceNow integration and provide proxy support. ### Bug fixes - Add error check when the system fails to read the replay file, thanks @johncming! +- Add missing `.Details` to the alert template. ## v1.5.6 [2020-07-17] From 6671fa4fd7c9391d254ac40c96670ae1940dbd88 Mon Sep 17 00:00:00 2001 From: Kelly Date: Mon, 26 Oct 2020 12:48:57 -0700 Subject: [PATCH 05/12] update frontmatter weights --- .../v1.5/event_handlers/servicenow.md | 111 ++++++++++++++++++ .../kapacitor/v1.5/event_handlers/slack.md | 2 +- .../kapacitor/v1.5/event_handlers/snmptrap.md | 2 +- content/kapacitor/v1.5/event_handlers/talk.md | 2 +- content/kapacitor/v1.5/event_handlers/tcp.md | 2 +- .../kapacitor/v1.5/event_handlers/telegram.md | 2 +- .../v1.5/event_handlers/victorops.md | 2 +- 7 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 content/kapacitor/v1.5/event_handlers/servicenow.md diff --git a/content/kapacitor/v1.5/event_handlers/servicenow.md b/content/kapacitor/v1.5/event_handlers/servicenow.md new file mode 100644 index 000000000..46bf3d6d2 --- /dev/null +++ b/content/kapacitor/v1.5/event_handlers/servicenow.md @@ -0,0 +1,111 @@ +--- +title: ServiceNow event handler +description: > + The ServiceNow event handler lets you to send Kapacitor alerts to ServiceNow. This page includes configuration options and usage examples. +menu: + kapacitor_1_5_ref: + name: ServiceNow + weight: 1500 + parent: Event handlers +--- + +[ServiceNow](hhttps://www.servicenow.com/) provides service management software with a comprehensive managed workflow that supports +features such as real-time communication, collaboration, and resource sharing. +Configure Kapacitor to send alert messages to ServiceNow. + +## Configuration + +Configuration and default [option](#options) values for the ServiceNow event +handler are set in your `kapacitor.conf`. +The example below shows the default configuration: + +```toml +[servicenow] + # Configure ServiceNow. + enabled = false + # The ServiceNow URL for the target table (Alert or Event). Replace this instance with your hostname. + url = "https://instance.service-now.com/api/now/v1/table/em_alert" + # Default source identification. + source = "Kapacitor" + # Username for HTTP BASIC authentication + username = "" + # Password for HTTP BASIC authentication + password = "" +``` + +#### `enabled` + +Set to `true` to enable the ServiceNow event handler. + +#### `url` + +The ServiceNow instance address. + +#### `source` + +Default "Kapacitor" source. + +#### `username` + +Username to use for basic HTTP authentication. + +#### `password` + +Password to use for basic HTTP authentication. + +## Options + +The following ServiceNow event handler options can be set in a +[handler file](/kapacitor/v1.5/event_handlers/#create-a-topic-handler-with-a-handler-file) or when using +`.serviceNow()` in a TICKscript. These options set corresponding fields in the ServiceNow alert or event. For information about ServiceNow alerts, see [Manually create an alert](https://docs.servicenow.com/bundle/paris-it-operations-management/page/product/event-management/task/t_EMManuallyCreateAlert.html). + +| Name | Type | Description | +| ---- | ---- | ----------- | +| node | string | ServiceNow node to associate with the event. | +| type | string | ServiceNow type used to identify an event record from which alerts are created, for example, disk or CPU.| +| resource | | Adds key values pairs to the Sensu API request. | +| metricName | string | Unique name that describes metrics collected for which the alert has been created. | +| messageKey | string | Unique event identifier used to identify multiple events related to the same alert. If empty, this is generated from the source, node, type, resource, and metricName field values.| +| source | string | Source that generated the event. | +| message | string | Alert message. | +| alert ID | string | Unique ID used to identify the alert. | + +{{% note %}} +All the handler options above support templates with the following variables: `ID`, `Name`, `TaskName`, `Fields`, `Tags`, same as in the `AlertNode.message`. +{{% /note %}} + +By default, the handler maps the Kapacitor values below to the ServiceNow Alert or Event fields as follows: + +| Value | Field | +| ---- | ---- | +| source | Source | +| message | Description | +| alert ID | Message key | + +### TICKscript examples + +```js +stream + |from() + .measurement('cpu') + |alert() + .crit(lambda: "usage_user" > 90) + .stateChangesOnly() + .message('Hey, check your CPU') + .serviceNow() +``` + +```js +stream + |from() + .measurement('cpu') + |alert() + .crit(lambda: "usage_user" > 90) + .message('Hey, check your CPU') + .serviceNow() + .node('{{ index .Tags "host" }}') + .type('CPU') + .resource('CPU-Total') + .metricName('usage_user') + .messageKey('Alert: {{ .ID }}') +``` diff --git a/content/kapacitor/v1.5/event_handlers/slack.md b/content/kapacitor/v1.5/event_handlers/slack.md index dc4ea5e76..2c553ebfd 100644 --- a/content/kapacitor/v1.5/event_handlers/slack.md +++ b/content/kapacitor/v1.5/event_handlers/slack.md @@ -5,7 +5,7 @@ description: > menu: kapacitor_1_5_ref: name: Slack - weight: 1500 + weight: 1600 parent: Event handlers --- diff --git a/content/kapacitor/v1.5/event_handlers/snmptrap.md b/content/kapacitor/v1.5/event_handlers/snmptrap.md index 6897ac97a..832f34399 100644 --- a/content/kapacitor/v1.5/event_handlers/snmptrap.md +++ b/content/kapacitor/v1.5/event_handlers/snmptrap.md @@ -5,7 +5,7 @@ description: > menu: kapacitor_1_5_ref: name: SNMP Trap - weight: 1600 + weight: 1700 parent: Event handlers --- diff --git a/content/kapacitor/v1.5/event_handlers/talk.md b/content/kapacitor/v1.5/event_handlers/talk.md index c66f43282..a481e74a4 100644 --- a/content/kapacitor/v1.5/event_handlers/talk.md +++ b/content/kapacitor/v1.5/event_handlers/talk.md @@ -5,7 +5,7 @@ description: > menu: kapacitor_1_5_ref: name: Talk - weight: 1700 + weight: 1800 parent: Event handlers --- diff --git a/content/kapacitor/v1.5/event_handlers/tcp.md b/content/kapacitor/v1.5/event_handlers/tcp.md index c5dd15236..f8a0f939b 100644 --- a/content/kapacitor/v1.5/event_handlers/tcp.md +++ b/content/kapacitor/v1.5/event_handlers/tcp.md @@ -5,7 +5,7 @@ description: > menu: kapacitor_1_5_ref: name: TCP - weight: 1800 + weight: 1900 parent: Event handlers --- diff --git a/content/kapacitor/v1.5/event_handlers/telegram.md b/content/kapacitor/v1.5/event_handlers/telegram.md index 99cdd0d96..1a61e97a1 100644 --- a/content/kapacitor/v1.5/event_handlers/telegram.md +++ b/content/kapacitor/v1.5/event_handlers/telegram.md @@ -5,7 +5,7 @@ description: > menu: kapacitor_1_5_ref: name: Telegram - weight: 1900 + weight: 2000 parent: Event handlers --- diff --git a/content/kapacitor/v1.5/event_handlers/victorops.md b/content/kapacitor/v1.5/event_handlers/victorops.md index c4a5a4923..fa72fae3f 100644 --- a/content/kapacitor/v1.5/event_handlers/victorops.md +++ b/content/kapacitor/v1.5/event_handlers/victorops.md @@ -5,7 +5,7 @@ description: > menu: kapacitor_1_5_ref: name: VictorOps - weight: 2000 + weight: 2100 parent: Event handlers --- From fa35c1cfa65bc6c7dee28384522de73fe28360c5 Mon Sep 17 00:00:00 2001 From: Kelly Date: Mon, 26 Oct 2020 12:49:24 -0700 Subject: [PATCH 06/12] add new doc for ServiceNow event handler --- content/kapacitor/v1.5/event_handlers/_index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/event_handlers/_index.md b/content/kapacitor/v1.5/event_handlers/_index.md index 485f764b8..5e080ceea 100644 --- a/content/kapacitor/v1.5/event_handlers/_index.md +++ b/content/kapacitor/v1.5/event_handlers/_index.md @@ -34,7 +34,8 @@ syntax for officially supported Kapacitor event handlers. [Post](/kapacitor/v1.5/event_handlers/post/) [Publish](/kapacitor/v1.5/event_handlers/publish/) [Pushover](/kapacitor/v1.5/event_handlers/pushover/) -[Sensu](/kapacitor/v1.5/event_handlers/sensu/) +[Sensu](/kapacitor/v1.5/event_handlers/sensu/) +[ServiceNow]() [Slack](/kapacitor/v1.5/event_handlers/slack/) [Snmptrap](/kapacitor/v1.5/event_handlers/snmptrap/) [Talk](/kapacitor/v1.5/event_handlers/talk/) From 5dfad2c23e588272700b71c48bb5674c1da19dab Mon Sep 17 00:00:00 2001 From: Kelly Date: Mon, 26 Oct 2020 12:50:21 -0700 Subject: [PATCH 07/12] add custom option using new method --- content/kapacitor/v1.5/event_handlers/opsgenie/v2.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md b/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md index 25d4a041a..86a3d1688 100644 --- a/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md +++ b/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md @@ -51,10 +51,11 @@ Default OpsGenie recipients. _Can be overridden per alert._ The OpsGenie API URL. _**This should not need to be changed.**_ #### `recovery_action` -The Recovery Action specifies which action to take when alerts recover. +The recovery action specifies which action to take when alerts recover. Valid values include: * `notes` - Add a note to the alert. * `close` - Close the alert. + * custom - Use the `.RecoveryAction()` method to specify the `recovery_action` in a TICK script. #### `global` If `true`, all alerts are sent to OpsGenie without specifying `opsgenie2` in the TICKscript. From 440c73d8224b15c0e28506cec4776f6da097e059 Mon Sep 17 00:00:00 2001 From: Kelly Date: Mon, 26 Oct 2020 12:51:57 -0700 Subject: [PATCH 08/12] add ServiceNow liink in event handler overview --- content/kapacitor/v1.5/event_handlers/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/event_handlers/_index.md b/content/kapacitor/v1.5/event_handlers/_index.md index 5e080ceea..194411250 100644 --- a/content/kapacitor/v1.5/event_handlers/_index.md +++ b/content/kapacitor/v1.5/event_handlers/_index.md @@ -35,7 +35,7 @@ syntax for officially supported Kapacitor event handlers. [Publish](/kapacitor/v1.5/event_handlers/publish/) [Pushover](/kapacitor/v1.5/event_handlers/pushover/) [Sensu](/kapacitor/v1.5/event_handlers/sensu/) -[ServiceNow]() +[ServiceNow](/kapacitor/v1.5/event_handlers/servicenow/)) [Slack](/kapacitor/v1.5/event_handlers/slack/) [Snmptrap](/kapacitor/v1.5/event_handlers/snmptrap/) [Talk](/kapacitor/v1.5/event_handlers/talk/) From afe27b19a683907f0dc78b38ad7321332af4009d Mon Sep 17 00:00:00 2001 From: kelseiv <47797004+kelseiv@users.noreply.github.com> Date: Mon, 26 Oct 2020 12:54:55 -0700 Subject: [PATCH 09/12] remove extra parens --- content/kapacitor/v1.5/event_handlers/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/event_handlers/_index.md b/content/kapacitor/v1.5/event_handlers/_index.md index 194411250..814426696 100644 --- a/content/kapacitor/v1.5/event_handlers/_index.md +++ b/content/kapacitor/v1.5/event_handlers/_index.md @@ -35,7 +35,7 @@ syntax for officially supported Kapacitor event handlers. [Publish](/kapacitor/v1.5/event_handlers/publish/) [Pushover](/kapacitor/v1.5/event_handlers/pushover/) [Sensu](/kapacitor/v1.5/event_handlers/sensu/) -[ServiceNow](/kapacitor/v1.5/event_handlers/servicenow/)) +[ServiceNow](/kapacitor/v1.5/event_handlers/servicenow/) [Slack](/kapacitor/v1.5/event_handlers/slack/) [Snmptrap](/kapacitor/v1.5/event_handlers/snmptrap/) [Talk](/kapacitor/v1.5/event_handlers/talk/) From 4b35ecc79de1ad4306fd61ce72ac059ba2999e09 Mon Sep 17 00:00:00 2001 From: kelseiv <47797004+kelseiv@users.noreply.github.com> Date: Mon, 26 Oct 2020 12:57:03 -0700 Subject: [PATCH 10/12] fix typo --- content/kapacitor/v1.5/event_handlers/servicenow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/event_handlers/servicenow.md b/content/kapacitor/v1.5/event_handlers/servicenow.md index 46bf3d6d2..691544937 100644 --- a/content/kapacitor/v1.5/event_handlers/servicenow.md +++ b/content/kapacitor/v1.5/event_handlers/servicenow.md @@ -9,7 +9,7 @@ menu: parent: Event handlers --- -[ServiceNow](hhttps://www.servicenow.com/) provides service management software with a comprehensive managed workflow that supports +[ServiceNow](https://www.servicenow.com/) provides service management software with a comprehensive managed workflow that supports features such as real-time communication, collaboration, and resource sharing. Configure Kapacitor to send alert messages to ServiceNow. From ada1fdf027821c41daf8862218bfcd086f5cf268 Mon Sep 17 00:00:00 2001 From: kelseiv <47797004+kelseiv@users.noreply.github.com> Date: Tue, 27 Oct 2020 09:19:08 -0700 Subject: [PATCH 11/12] fix cap --- .../kapacitor/v1.5/about_the_project/releasenotes-changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md index 0db89683b..f48e0774d 100644 --- a/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md +++ b/content/kapacitor/v1.5/about_the_project/releasenotes-changelog.md @@ -10,7 +10,7 @@ menu: ## Features -- Add the `.RecoveryAction()` method to support overriding the OpsGenieV2 alert recovery action in a TICKscript, thanks @zabullet! +- Add the `.recoveryaction()` method to support overriding the OpsGenieV2 alert recovery action in a TICKscript, thanks @zabullet! - Add support for templating URLs in the [`httpPost` node](/kapacitor/v1.5/nodes/http_post_node/) and [`alert` node](/kapacitor/v1.5/nodes/alert_node/). To set up an template: - For the `alert` node, see [alert templates](/kapacitor/v1.5/event_handlers/post/#alert-templates). - For the `http post` node, see [row templates](/kapacitor/v1.5/event_handlers/post/#row-templates). From 6cc610d02ed7f898e95e7ba8bdad55794d66a6c0 Mon Sep 17 00:00:00 2001 From: Kelly Date: Tue, 27 Oct 2020 09:34:48 -0700 Subject: [PATCH 12/12] add example f Emrys to TICKscript --- content/kapacitor/v1.5/event_handlers/opsgenie/v2.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md b/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md index 86a3d1688..070cba047 100644 --- a/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md +++ b/content/kapacitor/v1.5/event_handlers/opsgenie/v2.md @@ -36,7 +36,7 @@ Below is an example configuration: ``` #### `enabled` -Set to `true` to enable the OpsGenie v2 event handler. +Set to `true` to enable the OpsGenie v2 event handler. #### `api-key` Your OpsGenie API Key. @@ -135,6 +135,8 @@ stream .message('Hey, check your CPU') .opsGenie2() .teams('engineering', 'support') + .recoveryAction('notes') + ``` ### Send alerts to OpsGenie from a defined handler