AWS-WAF-Log S3存放,通过Athena查看
创始人
2025-01-11 07:08:09
0

1.创建好waf-cdn 并且设置好规则和log存储方式为s3

在这里插入图片描述

2. Amazon Athena 服务 使用 (注意s3桶位置相同得区域)

https://docs.aws.amazon.com/zh_cn/athena/latest/ug/waf-logs.html
官方文档参考,建一个分区查询表

不能直接使用 因为是cdn 资源需要修改相关字段

CREATE EXTERNAL TABLE `waf_logs`(   `timestamp` bigint,   `formatversion` int,   `webaclid` string,   `terminatingruleid` string,   `terminatingruletype` string,   `action` string,   `terminatingrulematchdetails` array <                                     struct <                                         conditiontype: string,                                         sensitivitylevel: string,                                         location: string,                                         matcheddata: array < string >                                           >                                      >,   `httpsourcename` string,   `httpsourceid` string,   `rulegrouplist` array <                       struct <                           rulegroupid: string,                           terminatingrule: struct <                                               ruleid: string,                                               action: string,                                               rulematchdetails: array <                                                                    struct <                                                                        conditiontype: string,                                                                        sensitivitylevel: string,                                                                        location: string,                                                                        matcheddata: array < string >                                                                           >                                                                     >                                                 >,                           nonterminatingmatchingrules: array <                                                               struct <                                                                   ruleid: string,                                                                   action: string,                                                                   overriddenaction: string,                                                                   rulematchdetails: array <                                                                                        struct <                                                                                            conditiontype: string,                                                                                            sensitivitylevel: string,                                                                                            location: string,                                                                                            matcheddata: array < string >                                                                                               >                                                                    >,                                                                   challengeresponse: struct <                                                                             responsecode: string,                                                                             solvetimestamp: string                                                                               >,                                                                   captcharesponse: struct <                                                                             responsecode: string,                                                                             solvetimestamp: string                                                                               >                                                                     >                                                              >,                           excludedrules: string                             >                        >, `ratebasedrulelist` array <                          struct <                              ratebasedruleid: string,                              limitkey: string,                              maxrateallowed: int                                >                           >,   `nonterminatingmatchingrules` array <                                     struct <                                         ruleid: string,                                         action: string,                                         rulematchdetails: array <                                                              struct <                                                                  conditiontype: string,                                                                  sensitivitylevel: string,                                                                  location: string,                                                                  matcheddata: array < string >                                                                     >                                                              >,                                         challengeresponse: struct <                                                             responsecode: string,                                                             solvetimestamp: string                                                              >,                                         captcharesponse: struct <                                                             responsecode: string,                                                             solvetimestamp: string                                                              >                                           >                                      >,   `requestheadersinserted` array <                                 struct <                                     name: string,                                     value: string                                       >                                  >,   `responsecodesent` string,   `httprequest` struct <                     clientip: string,                     country: string,                     headers: array <                                 struct <                                     name: string,                                     value: string                                       >                                  >,                     uri: string,                     args: string,                     httpversion: string,                     httpmethod: string,                     requestid: string                       >,   `labels` array <                struct <                    name: string                      >                 >,   `captcharesponse` struct <                         responsecode: string,                         solvetimestamp: string,                         failureReason: string                           >,   `challengeresponse` struct <                         responsecode: string,                         solvetimestamp: string,                         failureReason: string                         >,   `ja3Fingerprint` string,   `oversizefields` string,   `requestbodysize` int,   `requestbodysizeinspectedbywaf` int ) PARTITIONED BY (  `region` string,  `date` string)  ROW FORMAT SERDE    'org.openx.data.jsonserde.JsonSerDe'  STORED AS INPUTFORMAT    'org.apache.hadoop.mapred.TextInputFormat'  OUTPUTFORMAT    'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION   's3:///AWSLogs//WAFLogs/cloudfront/' TBLPROPERTIES(  'projection.enabled' = 'true',  'projection.region.type' = 'enum',  'projection.region.values' = 'cloudfront',  'projection.date.type' = 'date',  'projection.date.range' = '2024/07/08,NOW',  'projection.date.format' = 'yyyy/MM/dd',  'projection.date.interval' = '1',  'projection.date.interval.unit' = 'DAYS',  'storage.location.template' = 's3:///AWSLogs//WAFLogs/${region}//${date}/') 

修改< >中的字符为自己的资源

测试查询

SELECT    COUNT(httpRequest.country) as count,    httpRequest.country  FROM waf_logs WHERE    terminatingruletype='RATE_BASED'  GROUP BY httpRequest.country ORDER BY count LIMIT 100; 
SELECT    COUNT(*) AS count,   webaclid,   action,   httprequest.clientip,   httprequest.uri FROM waf_logs WHERE terminatingruleid='' GROUP BY webaclid, action, httprequest.clientip, httprequest.uri ORDER BY count DESC LIMIT 100; 

具体的sql 字段需要修改成自己的 可以先检索全表 查看字段 方便搜索
在这里插入图片描述

相关内容

热门资讯

详细透视!德州局透视脚本免费版... 详细透视!德州局透视脚本免费版下载手机版,pokemmo脚本手机版(透视)确实是有辅助攻略(哔哩哔哩...
透视法门!菠萝辅助器免费版的特... 透视法门!菠萝辅助器免费版的特点(透视)都是是有辅助平台(哔哩哔哩)在进入菠萝辅助器免费版的特点软件...
解谜透视!拱趴大菠萝万能辅助器... 您好,拱趴大菠萝万能辅助器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很...
透视教材!wepoker好友局... 透视教材!wepoker好友局透视(透视)竟然真的是有辅助神器(哔哩哔哩)在进入wepoker好友局...
专业透视!fishpoker透... 专业透视!fishpoker透视底牌,xpoker怎么作必弊(透视)一贯真的有辅助app(哔哩哔哩)...
透视积累!aapoker怎么选... 透视积累!aapoker怎么选牌(透视)切实是真的辅助安装(哔哩哔哩)aapoker怎么选牌透视方法...
详细透视!智星德州插件最新版本... 详细透视!智星德州插件最新版本更新内容详解,约局吧是否有挂(透视)本来是真的有辅助教程(哔哩哔哩)1...
透视要领!wejoker透视方... 透视要领!wejoker透视方法(透视)总是是有辅助app(哔哩哔哩)1、wejoker透视方法脚本...
关于透视!哈糖大菠萝开挂,德州... 关于透视!哈糖大菠萝开挂,德州透视插件(透视)本来真的有辅助教程(哔哩哔哩)1、许多玩家不知道哈糖大...
透视窍门!aapoker透视脚... 透视窍门!aapoker透视脚本(透视)一直真的是有辅助安装(哔哩哔哩)aapoker透视脚本脚本下...