EventBridge -> Gloal Ruleset (Email)
Global Ruleset および Global Orchestration は Email Address を持っています。
- Rulesets: Are email integration filters/rules, or custom event transformers supported?
- Event Orchestration: Does Event Orchestration support email events?
導入
SNS Subscription では Email
または Email-JSON
で送信できるので、2パターン試します。
AWS SNS の Subscription に Global Ruleset の "Email Address" を Protocol "Email" または "Email-JSON" として指定します。
"AWS Notification - Subscription Confirmation" の件名でAlertが作成されるので、confirm を実施することで利用できるようになります。(ルールに合致しない状態ではインシデントは作成されません。)
この際、同一件名で Alert が Triggered (Suppressed)
の状態だとAlertも新規発行されず追加となります。
新規発行としたい場合はAlertもResolve(Resolve(Suppressed)
の状態)にしておく必要があります。
View Message
からイベント内の Confirm URL を確認できます。
- Email
- Email-JSON
ルール (conditions)
利用できるfieldは以下になります。
> - headers.from.0.address (the from address) >> * Note: .0.address refers to the 1st position in a list of emails. If you would like to generally search through a list of emails (either in the "to" field or the "from" field), please set to headers.from or headers.to > > - headers.subject (the subject line) > - body (the email body)
TopicArn の形式などで Email, Email-JSON の判別もできます。
- 例
# Email When all conditions are met `headers.subject` equals `AWS Notification Message` `body` contains `?SubscriptionArn=arn:aws:sns:ap-northeast-1:123456789012:example-aws-to-pd-eventbridge:` # Email-JSON When all conditions are met `headers.subject` equals `AWS Notification Message` `body` contains `"TopicArn" : "arn:aws:sns:ap-northeast-1:123456789012:example-aws-to-pd-eventbridge"`
インシデント
初期状態でのインシデントタイトルはメール件名で作成されます。
AWS Notification Message
詳細欄はメール本文です。 Email は Message の内容のみとなるので、 Email-JSON の方が若干情報量が多いです。
重複排除
Ruleの "Customize Event Fields" から変更します。
Customize Event Fields
Step 1.1: Customize Event Fields (Optional) を参考に出力内容を調整します。
Summary を固定値に変換、
また、都度インシデントを作成するため dedep_key に MessageId を設定します。
Message は JSON 文字列 となっているので正規表現で抜き出します。
- Define Custom Variable
Name | Regex | Source |
---|---|---|
message_id | ^.*"id":"([^"]*)".*$ |
body |
- Replace Event Field
Event Field (CEF) | Value |
---|---|
summary | Email: Tag Change on Resource |
dedup_key | {{message_id}} |
Email-JSON
- Define Custom Variable
Name | Regex | Source |
---|---|---|
message_id | ^.*"MessageId" : "([^"]*)".*$ |
body |
- Replace Event Field
Event Field (CEF) | Value |
---|---|
summary | Email-JSON: Tag Change on Resource |
dedup_key | {{message_id}} |
インシデント(変換後)
Summary が変換されたことを確認できます。
dedup_key を指定したことにより、インシデントがTriggeredの状態で残っている状態で再度同一イベントが発生した場合にも、インシデントが作成されます。
- Email
- Email-JSON