More Related Content Similar to インフラエンジニアのためのAWSサービスを利用したログ分析はじめの一歩 (20) インフラエンジニアのためのAWSサービスを利用したログ分析はじめの一歩2. ⾃⼰紹介 2
⻄澤 徹訓
• クラスメソッド株式会社
• AWS事業本部
• コンサルティング部⻑
• 2015年8⽉⼊社
• デリバリーチームリーダー
• “⼤盛無料"と聞くと喜びます
13. AWS CLIを使ったCloudWatchの統計情報取得(例) 13
$ aws cloudwatch get-metric-statistics
--namespace "AWS/ApplicationELB"
--dimensions Name=LoadBalancer,Value=app/my-alb-name/1234xxxx1234xxxx
--metric-name HTTPCode_ELB_5XX_Count
--statistics "Sum"
--start-time "2017-12-21T00:00:00Z"
--end-time "2018-01-01T00:00:00Z"
--period $((60 * 60 * 24))
--query "sort_by(Datapoints,&Timestamp)[][Timestamp,Sum]"
--output text
14. AWS CLIを使ったCloudWatchの情報取得結果(例) 14
2017-12-21T00:00:00Z 1133.0
2017-12-22T00:00:00Z 117.0
2017-12-23T00:00:00Z 29.0
2017-12-24T00:00:00Z 335.0
2017-12-25T00:00:00Z 610.0
2017-12-26T00:00:00Z 160.0
2017-12-27T00:00:00Z 63.0
2017-12-28T00:00:00Z 148.0
2017-12-29T00:00:00Z 195.0
2017-12-30T00:00:00Z 40.0
24. DDL⽂サンプル 24
CREATE EXTERNAL TABLE IF NOT EXISTS alb_logs (
type string,
time string,
elb string,
:::(省略)
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
WITH SERDEPROPERTIES (
'input.regex' = '([^ ]*) ([^ ]*) ([^ ]*) :::(省略)
LOCATION 's3://your-alb-logs-directory/AWSLogs/<ACCOUNT-
ID>/elasticloadbalancing/region';
29. VPC Flow Logsに対するクエリサンプル 29
SQL クエリ、関数、および演算⼦ - Amazon Athena
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/functions-operators-reference-section.html
SELECT sourceaddress, COUNT(*) as count
FROM vpc_flow_logs
WHERE ts
BETWEEN concat(cast(current_date AS VARCHAR),'T','06:00:00.000Z')
AND concat(cast(current_date AS VARCHAR),'T','12:00:00.000Z')
GROUP BY sourceaddress
ORDER BY count DESC