Slack connector and action
editSlack connector and action
editThe Slack connector uses incoming webhooks or an API method to send Slack messages.
Create connectors in Kibana
editYou can create connectors in Stack Management > Connectors or as needed when you’re creating a rule. You can choose to use a webhook URL that’s specific to a single channel. For example:
Alternatively, you can create a connector that supports multiple channels. For example:
If you use the latter method, you choose your channel when you create a rule action. Thus a connector can be used in multiple rules and actions to communicate with different channels.
For Slack setup details, go to Configure a Slack account.
Create preconfigured connectors
editIf you are running Kibana on-prem, you can define connectors by
adding xpack.actions.preconfigured
settings to your kibana.yml
file.
Example Slack connector with webhook.
xpack.actions.preconfigured: my-slack: name: preconfigured-slack-webhook-connector-type actionTypeId: .slack secrets: webhookUrl: 'https://hooks.slack.com/services/xxxx/xxxx/xxxx'
To obtain this value, go to Configure a Slack account for incoming webhooks. |
Example Slack connector with web API.
xpack.actions.preconfigured: my-slack: name: preconfigured-slack-api-connector-type actionTypeId: .slack_api secrets: token: 'xoxb-xxxx-xxxx-xxxx'
To obtain this value, go to Configure a Slack account for Web API. |
Test connectors
editYou can test connectors with the run connector API or as you’re creating or editing the connector in Kibana. For example:
Slack actions have the following properties:
- Channels
- One or more channels that your Slack app has access to. This option is available only in the web API type of connector.
- Message
- The Slack message text, which cannot contain Markdown, images, or other advanced formatting.
Connector networking configuration
editUse the Action configuration settings to customize connector networking configurations, such as proxies, certificates, or TLS settings.
You can set configurations that apply to all your connectors or use xpack.actions.customHostSettings
to set per-host configurations.
Configure a Slack account
editBefore you can create a Slack connector, you must configure your account and obtain the necessary URL or token.
Configure a Slack account for incoming webhooks
edit- Log in to slack.com as a team administrator.
- Create a Slack app, enable incoming webhooks, then create an incoming webhook. Refer to https://api.slack.com/messaging/webhooks.
- Copy the generated webhook URL so you can paste it into your Slack connector form.
-
If you are using the
xpack.actions.allowedHosts
setting, make sure the hostname from the URL is added to the allowed hosts.
Configure a Slack account for Web API
edit- Create a Slack app. Refer to https://api.slack.com/authentication/basics#creating.
-
Add scope:
channels:read
,groups:read
,chat:write
andchat:write.public
. Refer to https://api.slack.com/authentication/basics#scopes. - Install the app to a workspace. Refer to https://api.slack.com/authentication/basics#installing.
-
Copy the
Bot User OAuth Token
so you can paste it into your Slack connector form. -
If you need to send messages to a private channel, you need to write
/invite @App_name
in it. Putting "@" triggers Slack to start auto-suggesting, which is why it then becomes easy to find your app name in the list.