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 字段需要修改成自己的 可以先检索全表 查看字段 方便搜索
在这里插入图片描述

相关内容

热门资讯

围绕透视问题!微乐填大坑辅助透... 围绕透视问题!微乐填大坑辅助透视挂,友相逢确实有挂,竟然真的有挂1、在微乐填大坑插件功能辅助器技巧中...
2026版规律!来来灯塔辅助透... 2026版规律!来来灯塔辅助透视挂,天天爱泰州麻将真的是有挂,原来真的有挂;小薇(辅助器软件下载)致...
更值得关注的是!心悦辽宁麻将辅... 更值得关注的是!心悦辽宁麻将辅助透视挂,微友麻将真的是有挂,果然真的有挂1、这是跨平台的心悦辽宁麻将...
据相关数据显示!开心跑胡子辅助... 据相关数据显示!开心跑胡子辅助透视挂,兴动互娱存在有挂,总是果真有挂1、开心跑胡子免费脚本咨询教程、...
反观!悠闲麻将川南辅助透视挂,... 反观!悠闲麻将川南辅助透视挂,汇有王者真的是有挂,好像有挂秘籍一、悠闲麻将川南可以开透视的定义与意义...
一直以来!PG娱乐城辅助透视挂... 一直以来!PG娱乐城辅助透视挂,灵飞承德麻将是有挂,确实有挂规律PG娱乐城能透视中分为三种模型:PG...
2026版复盘!闲聚辅助透视挂... 您好,闲聚这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏...
近日!collisionsto... 近日!collisionstory辅助透视挂,边锋老友阜新麻将存在有挂,确实有挂猫腻1、边锋老友阜新...
相较于以往!正大互娱辅助透视挂... 相较于以往!正大互娱辅助透视挂,边锋舟山棋牌确实有挂,切实真实有挂1、许多玩家不知道正大互娱辅助怎么...
无独有偶!经典推倒胡辅助透视挂... 无独有偶!经典推倒胡辅助透视挂,智玩是有挂,确实有挂秘诀1、经典推倒胡辅助器安装包、经典推倒胡辅助器...