1. Home
  2. Integrations
  3. Slack Integration Guide – VictorOps

Slack Integration Guide – VictorOps

Requirements

Versions Supported: Slack 2.x

VictorOps Version Required: Standard (Basic config), Enterprise (Multi-Channel config)

What you need to know The basic configuration links your VictorOps timeline, bidirectionally, to a single Slack channel. The advanced configuration provides links, and routing to multiple Slack channels with some limitations (must complete basic setup first)

Basic Configuration

Enable the Integration

(You must be an admin user in VictorOps)
1. From the VictorOps Timeline select “Settings” >> “Alert Behavior” >> “Integrations”.

settings-alert-behavior-integrations

2. Scroll down and select the “Slack” integration button (alphabetical order).  If the integration has not been enabled, click “Enable Integration”.

3. Copy the Outgoing Webhook URL that is generated by enabling the integration, and keep this page open as you will return to paste in the webhook URL generated by Slack in subsequent steps.

slack-webhook-url

Webhooks: VictorOps to Slack

 

4. From your Slack account navigate to the channel you wish to link and select the settings icon.  Choose Add an app or integration.
slack4

5. In the search function, type “webhooks” and select Incoming WebHooks
slack5

6. Click on Add Configuration
slack6

7. Select the channel you want to link to your VictorOps timeline.
slack7

8. Copy the Webhooks URL to your clipboard.
slack8

9.Scroll to the bottom and click Save Settings.
slack9

10. Paste the URL (from step 3) into the Incoming Webhook URL section. (It saves automatically, nothing more to click)
slack10


Webhooks: Slack to VictorOps

11. Return to the Slack integrations search function, and type “webhooks”.  Select Outgoing WebHooks.
slack11

12. Click on Add Configuration.
slack12

13. Click Add Outgoing WebHooks Integration.
slack13

14. Scroll down to the Integration Settings section .  Select the channel you are linking with VictorOps and then paste the URL you copied from the Outgoing Webhooks URL section in VictorOps (Step3 above) into the URL(s) section in Slack.
slack14

15. Scroll to the bottom and select Save Changes.

slack15

Configure and Test

16. Return to the Slack integration settings in VictorOps and read through the Slack Options section to fine tune the integration.
slack16

17.  Navigate to your main timeline in VictorOps, and enter any text into one of the two chat bars and press ENTER/RETURN. (Notice that the chat bar located in the incident pane (far right) will append the incident # to the chat)  You should see the chat appear in your Slack channel.  Reply to the chat from within Slack and you should see the response in the VictorOps timeline.
slack17


Multi-Channel Configuration

This setup allows you to segregate VictorOps incidents into their own separate Slack channels based on the routing_key value in VictorOps.  Incident specific chats in VictorOps (chats entered into the incident-pane chat bar on the far right) can also be sent to a specific Slack channel based on the routing_key of the incident.  This setup also adds the name of the VictorOps user that ack’ed and resolved incidents, as well as links in Slack that take the user directly to the incident in VictorOps.


Important Considerations:

  • This setup requires the Enterprise version of VictorOps to make use of the Transmogrifier and Custom Outbound Webhooks features.
  • You must have configured routing keys in VictorOps for each of the teams you wish to associate with a Slack channel. (Settings >> Integrations >> Scroll to bottom)
  • You need to complete the basic setup above first.  Connect to the Slack channel that will serve as the main silo for all things VictorOps (i.e. the channel that will mirror all traffic from the VictorOps timeline).  Note: The names of the Slack channels will be declared directly in the payload of the webhooks to Slack, therefore you can use the same URL from step 8 of the basic setup.
  • In order to prevent duplicate events in your Slack channel, you may need to change your Slack integration settings in VictorOps.  (De-select the options that send incidents and/or chats into Slack)

slack18


Transmogrifier Rules

1. In VictorOps, click Settings >> Transmogrifier, then click the Add a Rule.  (In all cases you will leave the Stop after this rule has been applied UN-CHECKED)
slack19

2. The first rule will add the slugified version of your organization name (org slug) to all incidents.  When you are logged into the main VictorOps timeline, your org slug is located at the end of the URL.  (Ex. if the URL is https://portal.victorops.com/client/my-company, then the org slug in this case is “my-company”)  For the matching condition, alert field = * (star to catch all incidents).  For the Transform, alert field = org_slug AND new value = (your org slug here)  like so:
slack20

Click Save once complete.

3. Now you will create rules to associate your Slack channels to their appropriate routing_keys in VictorOps.  In this example, the routing key I want to use is “ops” and the name of the Slack channel I wish to link is “ops-dudes”.  Click Add a Rule.  For the matching condition, alert field = routing_key AND pattern = (Your routing_key here) .  For the Transform, alert field = slack_channel AND new value = (Slack channel name here) like the example below.  Do not include a # sign before the channel name.

slack21

You will need another rule like this for each of the VictorOps routing_keys you wish to link to a Slack channel.


Outbound Webhooks

You will need a total of 4 webhooks to complete this setup.  You can copy and paste the payloads below exactly as they are.  As long as you have set up the Transmogrifier rules, no editing of the payload should be necessary.

4. In VictorOps, navigate to Settings >> Webhooks and click on Add Webhook to create a new webhook.

slack22

5. Configure the following webhooks (you will have to click Add Webhook at the top each time, then scroll down to the new window)

Incident Chats to Slack:

  • Event: Incident-Chats
  • Method: POST
  • Content Type: application/json
  • To: (Your Slack URL from step 8 of the basic setup)
  • Payload:
1
2
3
4
5
6
7
8
9
10
{ 
    "channel": "#${{ALERT.slack_channel}}",
    "username": "VictorOps Chat (${{CHAT.USER_ID}})",
    "icon_url": "https://victorops.com/wp-content/uploads/2016/09/200x200-logo-leaf.png", 
    "attachments": [{ 
        "text": "${{CHAT.TEXT}} \n <https://portal.victorops.com/client/${{ALERT.org_slug}}#/incident/${{STATE.INCIDENT_NAME}}|*#${{STATE.INCIDENT_NAME}}*: ${{ALERT.monitoring_tool}}: ${{ALERT.entity_display_name}}>", 
        "color": "#4dc3ff",
        "mrkdwn_in": ["text"] 
        }]
}
  • Description:  Send incident chats to their appropriate Slack channel

Critical Incidents to Slack:

  • Event: Incident-Triggered
  • Method: POST
  • Content Type: application/json
  • To: (Your Slack URL from step 3 of the basic setup)
  • Payload:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
   "channel":"#${{ALERT.slack_channel}}",
    "username":"VictorOps",
    "icon_url":"https://victorops.com/wp-content/uploads/2016/09/200x200-logo-leaf.png",
   "attachments": [
        {
          "title":"CRITICAL INCIDENT TRIGGERED",
          "text": "<https://portal.victorops.com/client/${{ALERT.org_slug}}#/incident/${{STATE.INCIDENT_NAME}}|*#${{STATE.INCIDENT_NAME}}*: ${{ALERT.monitoring_tool}}: ${{ALERT.entity_display_name}}>",
          "color":"danger",
          "mrkdwn_in": ["text"]
        }
    ]
}
  • Description: Send triggered incidents to their appropriate Slack channel

Acknowledgements to Slack:

  • Event: Incident-Acknowledged
  • Method: POST
  • Content Type: application/json
  • To: (Your Slack URL from step 3 of the basic setup)
  • Payload:
1
2
3
4
5
6
7
8
9
10
11
{ 
    "channel":"#${{ALERT.slack_channel}}",
    "username":"VictorOps",
    "icon_url":"https://victorops.com/wp-content/uploads/2016/09/200x200-logo-leaf.png",
    "attachments": [ { 
        "title":"ACKNOWLEDGED by ${{STATE.ACK_USER}}",
        "text": "<https://portal.victorops.com/client/${{ALERT.org_slug}}#/incident/${{STATE.INCIDENT_NAME}}|*#${{STATE.INCIDENT_NAME}}*: ${{ALERT.monitoring_tool}}: ${{ALERT.entity_display_name}}>",
        "color":"warning",
        "mrkdwn_in": ["text"] 
        } ] 
}
  • Description: Send incident acknowledgements to their appropriate Slack channel

Recoveries to Slack:

  • Event: Incident-Resolved
  • Method: POST
  • Content Type: application/json
  • To: (Your Slack URL from step 3 of the basic setup)
  • Payload:
1
2
3
4
5
6
7
8
9
10
11
12
13
{
   "channel":"#${{ALERT.slack_channel}}",
    "username":"VictorOps",
    "icon_url":"https://victorops.com/wp-content/uploads/2016/09/200x200-logo-leaf.png",
   "attachments": [
        {
          "title":"RESOLVED by ${{STATE.ACK_USER}}",
          "text": "<https://portal.victorops.com/client/${{ALERT.org_slug}}#/incident/${{STATE.INCIDENT_NAME}}|*#${{STATE.INCIDENT_NAME}}*: ${{ALERT.monitoring_tool}}: ${{ALERT.entity_display_name}}>",
          "color":"good",
          "mrkdwn_in": ["text"]
        }
    ]
}
  • Description: Send incident recovery events to their appropriate Slack channel
Updated on June 2, 2017

Was this article helpful?

Related Articles