Slack のテンプレートの作成

Slack に HTTP リクエストアクションを送信するには、Splunk AppDynamics でテンプレートを作成する必要があります。Splunk AppDynamics がイベントに応答してアクションをトリガーすると、Slack チャネルでアクションの詳細を表示できます。

注: このドキュメントには、Slack のドキュメントへの参照が含まれています。Splunk AppDynamics はいかなる権利も所有しておらず、そのようなサードパーティのドキュメントの正確性または完全性について責任を負いません。

はじめる前に

Slack テンプレートを作成する前に、次の点について確認します。
  1. Slack API ウィザードを使用して、Slack でアプリケーションを作成します。https://api.slack.com/appsこのアプリケーションは、Slack に送信された HTTP リクエストを受け入れます。
  2. Slackアプリケーションによって生成されたウェブフック URL をコピーし、後で使用するために安全に保管します。Splunk AppDynamics は、この URL をターゲットとして使用してアラートを Slack に送信します。

Create a Template

To create a PagerDuty template:
  1. In the menu bar, click Alert & Respond.
  2. Click HTTP Request Templates.
  3. Enter a name for the template. For example, Send alerts to Slack .
  4. In the Request URL section:
    1. Select POST as Method.
    2. Enter the webhook URL of the Slack app in the Raw URL field.
    3. Select UTF-8 as URL Encoding.
  5. In the Authentication section, select NONE as Type.
  6. In the Payload section:
    1. Select application/json as MIME Type.
    2. Select UTF-8 as Payload Encoding.
    3. Enter the following payload in the text box:
      PYTHON
      #set( $sm = $!{latestEvent.summaryMessage.replace('"',"*")} )
      #set( $sm = $sm.replace("<b>", "*") )
      #set( $sm = $sm.replace("</b>", "*") )
      #set( $sm = $sm.replace("<br>", " ") )
      #set( $sm = $sm.replace("null"," ") )
         
      {
          "blocks": [
              {
                  "type": "section",
                  "text": {
                      #if( ${latestEvent.severity} == "ERROR" )
                          "type": "mrkdwn",
                          "text": ":red_circle: *New Alert from AppDynamics:* ${latestEvent.displayName}\n\n*Summary:*\n$sm"
                      #elseif( ${latestEvent.severity} == "WARN" )
                          "type": "mrkdwn",
                          "text": ":warning: *New Alert from AppDynamics:* ${latestEvent.displayName}\n\n*Summary:*\n$sm"
                      #else
                          "type": "mrkdwn",
                          "text": ":information_source: *New Alert from AppDynamics:* ${latestEvent.displayName}\n\n*Summary:*\n$sm"
                      #end
                  },
                      "accessory": {
                      "type": "image",
                      "image_url": "https://share-logos.s3-us-west-1.amazonaws.com/appd-s-logo.png",
                      "alt_text": "logo"
                  },
              },
              {
                  "type": "section",
                  "fields": [
                      {
                          "type": "mrkdwn",
                          "text": "*Application:*\n${latestEvent.application.name}"
                      },
                      {
                          "type": "mrkdwn",
                          "text": "*When:*\n${latestEvent.eventTime}"
                      },
                      {
                          "type": "mrkdwn",
                          "text": "*Tier:*\n${latestEvent.tier.name}"
                      },
                      {
                          "type": "mrkdwn",
                          "text": "*Severity:*\n${latestEvent.severity}"
                      },
                      {
                          "type": "mrkdwn",
                          "text": "*Node:*\n${latestEvent.node.name}"
                      },
                      {
                          "type": "mrkdwn",
                          "text": "*Triggered by:*\n${policy.name}"
                      },
                  ]
              },
              {
                  "type": "actions",
                  "elements": [
                      {
                          "type": "button",
                          "text": {
                              "type": "plain_text",
                              "emoji": true,
                              "text": "Go to Alert in AppDynamics"
                          },
                          #if( ${latestEvent.severity} == "ERROR" )
                              "style": "danger",
                          #elseif( ${latestEvent.severity} == "WARN" )
                              "style": "primary",
                          #end
                          "value": "click_me_123",
                          "url": "${latestEvent.deepLink}"
                      },
                      {
                          "type": "button",
                          "text": {
                              "type": "plain_text",
                              "emoji": true,
                              "text": "Start Webex Session"
                          },
                          "style": "primary",
                          "value": "click_me_123",
                          "url": "https://cisco.webex.com"
                      }
                  ]
              },
              {
                  "type": "divider"
              },
          ]
      }
  7. In the Settings section, select the One Request Per Event option.
  8. Click Save.