OpenSearch/watcher/docs/administering-watcher/configuring-slack.asciidoc

87 lines
4.1 KiB
Plaintext

[[configuring-slack]]
=== Configuring Watcher to Send Messages to Slack
You can configure Watcher to send messages to Slack channels and users.
[[slack-account]]
==== Configuring Slack Accounts
You configure the accounts Watcher can use to communicate with Slack in your `elasticsearch.yml`
configuration file. Each account configuration has a unique name and specifies an
https://api.slack.com/incoming-webhooks[Incoming Webhook
URL] for posting messages to Slack. You can also specify message defaults,
such the sender name and icon.
Before you can configure a Slack account, you need to set up an Incoming Webhook Integration
through the Slack console:
. Log in to http://slack.com[slack.com] as a team administrator.
. Go to https://my.slack.com/services/new/incoming-webhook/[
https://my.slack.com/services/new/incoming-webhook/].
. Select a default channel for the integration.
+
image::images/slack-add-webhook-integration.jpg[]
. Click *Add Incoming Webhook Integration*.
. Copy the generated webhook URL so you can paste it into your Slack account configuration in
`elasticsearch.yml`.
+
image::images/slack-copy-webhook-url.jpg[]
To configure a Slack account in Watcher, you set the `watcher.actions.slack.service` property in
`elasticsearch.yml`. You must set the `url` to your incoming webhook integration URL.
You can also specify defaults for the notification messages. For the complete list of attributes,
see <<slack-account-attributes, Slack Account Attributes>>.
For example, the following snippet configures an account called `notify-monitoring` and sets the
default sender name to `Watcher`.
[source,yaml]
--------------------------------------------------
watcher.actions.slack.service:
account:
monitoring:
url: https://hooks.slack.com/services/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
message_default:
from: Watcher
--------------------------------------------------
If you configure multiple Slack accounts, you either need to configure a default Slack account
or specify which account the notification should be sent with in the <<actions-slack, slack>>
action. You set `default_account` in `watcher.actions.slack.service` to specify a default account.
[source,yaml]
--------------------------------------------------
watcher.actions.slack.service:
default_account: team1
account:
team1:
url: https://hooks.slack.com/services/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
message_default:
from: watcher
team2:
url: https://hooks.slack.com/services/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
message_default:
from: watcher
--------------------------------------------------
[[slack-account-attributes]]
==== Slack Account Attributes
|======
| Name |Required | Description
| `url` | yes | The Incoming Webhook URL to use to post
messages to Slack.
| `message_defaults.from` | no | The sender name to display in the
Slack message. Defaults to the watch ID.
| `message_defaults.to ` | no | The default Slack channels or groups you
want to send messages to.
| `message_defaults.icon` | no | The icon to display in the Slack messages.
Overrides the incoming webhook's configured
icon. Accepts a public URL to an image.
| `message_defaults.text` | no | The default message content.
| `message_defaults.attachment` | no | Default message attachments. Slack message attachments
enable you to create more richly-formatted messages.
Specified as an array as defined in the
https://api.slack.com/docs/attachments[
Slack attachments documentation].
|======