Amazon SNS アプリケーションのログとメトリクスの収集
Amazon SNS のメトリクスの収集
- Hosted Collector を設定します。
- Amazon CloudWatch メトリクス Source を設定します。
- Name (名前): 新しい Source に表示する名前を入力します。
- Description (説明): 説明 (省略可能) を入力します。
- Regions (リージョン)。SNS の Amazon リージョンを選択します。
- Namespaces (名前空間)。[AWS/SNS] を選択します。
- Source Category: Source Category を入力します。例: AWS/Metric/SNS
- Access Key and Secret Key (アクセス キーとシークレット キー)。Amazon のアクセス キーとシークレット キーを入力します。
- Scan Interval (スキャン間隔)。Sumo Logic が CloudWatch Source をスキャンして新しいデータがないか確認する間隔として、デフォルトの 5 分を使用するか、または別の間隔を入力します。
- [Save (保存)] をクリックします。
CloudTrail を使用した Amazon SNS イベントの収集
- Hosted Collector に AWS CloudTrail Source を追加します。
- Name (名前): 新しい Source に表示する名前を入力します。
- Description (説明): 説明 (省略可能) を入力します。
- S3 Region (S3 リージョン)。SNS S3 バケットの Amazon リージョンを選択します。
- Bucket Name (バケット名)。SNS S3 バケットの名前を正確に入力します。
- Path Expression (パス式)。収集する S3 オブジェクトに一致する文字列を入力します。この文字列では、ワイルドカードを 1 つ使用できます。(先頭にスラッシュを付けないでください。「Amazon のパス式」参照。)
- Source Category: Source Category を入力します。例: SNS_event
- Access Key and Secret Key (アクセス キーとシークレット キー)。Amazon のアクセス キーとシークレット キーを入力します。
- Scan Interval (スキャン間隔): デフォルトの 5 分を使用します。または、Sumo Logic が S3 バケットをスキャンして新しいデータがないか確認する間隔を入力します。
- Enable Timestamp Parsing (タイムスタンプ parse の有効化)。チェックボックスをオンにします。
- Time Zone (タイム ゾーン): [Ignore time zone from log file and instead use (ログ ファイルのタイムゾーンを無視して、次を使用します)] を選択して、[UTC] を選択します。
- Timestamp Format (タイムスタンプ形式)。[Automatically detect the format (自動的に形式を検出)] を選択します。
- Enable Multiline Processing (複数行の処理の有効化)。チェックボックスをオンにして [Infer Boundaries (境界を推測する)] を選択します。
- [Save (保存)] をクリックします。
ログ メッセージのサンプル
{ "eventVersion":"1.05", "userIdentity":{ "type":"IAMUser", "principalId":"AIDAI1234567890YGJ2G6", "arn":"arn:aws:iam::123456789029:user/bsmith", "accountId":"123456789029", "accessKeyId":"ASI1234567890IHSAOIQ", "userName":"jjones", "sessionContext":{ "attributes":{ "mfaAuthenticated":"true", "creationDate":"2017-11-28T19:40:36Z" } }, "invokedBy":"signin.amazonaws.com" }, "eventTime":"2017-11-28T20:00:12Z", "eventSource":"sns.amazonaws.com", "eventName":"ListSubscriptions", "awsRegion":"us-west-2", "sourceIPAddress":"19.174.45.8", "userAgent":"signin.amazonaws.com", "requestParameters":{ "nextToken":"AAEzJd64uRw2jIyzrdc8CoZOzZf/BBe8pUtH40pvaIDLtw==" }, "responseElements":null, "requestID":"6b897eb7-d07c-5f07-8702-2c2012f086b1", "eventID":"dd0ea39f-c0c9-442d-b6b9-84c4f73ca038", "eventType":"AwsApiCall", "recipientAccountId":"123456789029" }
クエリのサンプル
上位 10 人のユーザ
_sourceCategory=*cloudtrail* "\"eventsource\":\"sns.amazonaws.com\""
| json "eventSource" nodrop
| json "eventName" nodrop
| json "awsRegion" nodrop
| json "sourceIPAddress" nodrop
| json "userIdentity.type" as type nodrop
| json "userIdentity.arn" as arn nodrop
| json "userIdentity.accountId" as accountId nodrop
| json "userIdentity.userName" as userName nodrop
| json "errorCode" nodrop
| where eventSource="sns.amazonaws.com"
| if (isEmpty(errorCode), "Success", "Failure") as eventStatus
| parse field=arn ":assumed-role/*" as user nodrop
| if (isEmpty(userName), user, userName) as user
| count as eventCount by user
| top 10 user by eventCount