4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Azure Logic App で Azure メトリックアラートを Slack に投稿する

Posted at

Logic App は HTTP 要求の受信 → Slack メッセージ投稿 という2ステップで構成し、メトリックアラートの設定で「アクションの実行」にこの App を指定する。

トリガーの設定

「HTTP要求の受信時」から作成する。

trigger.png

各ステップの最低限の設定

HTTP要求の受信時

要求本文のJSONスキーマに次の内容を設定する。

httpreq.png

{
    "properties": {
        "context": {
            "properties": {
                "condition": {
                    "properties": {
                        "metricName": {
                            "type": "string"
                        },
                        "metricUnit": {
                            "type": "string"
                        },
                        "metricValue": {
                            "type": "string"
                        },
                        "operator": {
                            "type": "string"
                        },
                        "threshold": {
                            "type": "string"
                        },
                        "timeAggregation": {
                            "type": "string"
                        },
                        "windowSize": {
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                "conditionType": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "portalLink": {
                    "type": "string"
                },
                "resourceGroupName": {
                    "type": "string"
                },
                "resourceId": {
                    "type": "string"
                },
                "resourceName": {
                    "type": "string"
                },
                "resourceRegion": {
                    "type": "string"
                },
                "resourceType": {
                    "type": "string"
                },
                "subscriptionId": {
                    "type": "string"
                },
                "timestamp": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "properties": {
            "properties": {
                "$type": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "status": {
            "type": "string"
        }
    },
    "type": "object"
}

アクションの追加

「Slack投稿メッセージ」を追加し、サインインを済ませる。

addslack.png

Slackメッセージの投稿

チャネル名をプルダウンメニューから選択し、メッセージテキストに次の内容を設定する。
ロジックアプリを保存する。

slack.png

@{triggerBody()?['context']?['description']}
@{triggerBody()?['context']?['condition']?['metricName']} was @{triggerBody()?['context']?['condition']?['metricValue']} @{triggerBody()?['context']?['condition']?['operator']} @{triggerBody()?['context']?['condition']?['threshold']} (@{triggerBody()?['context']?['condition']?['metricUnit']})
@{triggerBody()?['context']?['portalLink']}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?