当前位置: 首页 > news >正文

AWS 查询 ALB access log

AWS 查询 ALB access log

开启AWS访问日志

创建S3桶并进行policy授权

S3->Permissions

其中 iam id 分区域不同,具体参考。
Enable access logs for your Application Load Balancer - Elastic Load Balancing为 Application Load Balancer 启用访问日志 - Elastic Load Balancing

  • 中国(北京)– 638102146993

  • 中国(宁夏)– 037604701340

aws --region cn-northwest-1 s3api put-bucket-policy --bucket prod-alb-access-log --policy "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Sid\": \"Statement1\",\"Effect\": \"Allow\",\"Principal\": { \"AWS\": \"arn:aws-cn:iam::037604701340:root\" },\"Action\": \"s3:PutObject\",\"Resource\": \"arn:aws-cn:s3:::prod-alb-access-log/*\"}]
}"

ALB开启访问日志

  1. 打开 Amazon EC2 控制台,网址为https://console.aws.amazon.com/ec2/。

  2. 在导航窗格中,选择负载均衡器

  3. 选择您的负载均衡器的名称以打开其详细信息页面。

  4. 属性选项卡上,选择编辑

  5. 对于监控,打开访问日志

  6. 对于 S3 URI,输入日志文件的 S3 URI。您指定的 URI 取决于您是否使用前缀。

    • 带有前缀的 URI: s3://amzn-s3-demo-logging-bucket/logging-prefix

    • 不带前缀的 URI: s3://amzn-s3-demo-logging-bucket

  7. 选择保存更改

基于Athena查询S3中ALB log

  CREATE EXTERNAL TABLE IF NOT EXISTS pmt_alb_logs(type string,time string,elb string,client_ip string,client_port int,target_ip string,target_port int,request_processing_time double,target_processing_time double,response_processing_time double,elb_status_code int,target_status_code string,received_bytes bigint,sent_bytes bigint,request_verb string,request_url string,request_proto string,user_agent string,ssl_cipher string,ssl_protocol string,target_group_arn string,trace_id string,domain_name string,chosen_cert_arn string,matched_rule_priority string,request_creation_time string,actions_executed string,redirect_url string,lambda_error_reason string,target_port_list string,target_status_code_list string,classification string,classification_reason string,conn_trace_id string)PARTITIONED BY(day STRING)ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'WITH SERDEPROPERTIES('serialization.format' = '1','input.regex' = '([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*):([0-9]*) ([^ ]*)[:-]([0-9]*) ([-.0-9]*) ([-.0-9]*) ([-.0-9]*) (|[-0-9]*) (-|[-0-9]*) ([-0-9]*) ([-0-9]*) \"([^ ]*) (.*) (- |[^ ]*)\" \"([^\"]*)\" ([A-Z0-9-_]+) ([A-Za-z0-9.-]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\" \"([^\"]*)\" ([-.0-9]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\" \"([^ ]*)\" \"([^\s]+?)\" \"([^\s]+)\" \"([^ ]*)\" \"([^ ]*)\" ?([^ ]*)?( .*)?')LOCATION 's3://prod-alb-access-log/adtech_gcpmt_alb_logs/AWSLogs/871252328373/elasticloadbalancing/cn-northwest-1/'TBLPROPERTIES("projection.enabled" = "true","projection.day.type" = "date","projection.day.range" = "2022/01/01,NOW","projection.day.format" = "yyyy/MM/dd","projection.day.interval" = "1","projection.day.interval.unit" = "DAYS","storage.location.template" = "s3://prod-alb-access-log/adtech_gcpmt_alb_logs/AWSLogs/871252328373/elasticloadbalancing/cn-northwest-1/${day}")pmt_alb_logs SELECT * FROM "AwsDataCatalog"."adtech_pmt"."pmt_alb_logs" where domain_name = 'domain' and request_url like '%/ads/landing%' limit 10;


文章转载自:

http://r5RQu9c0.zxwqt.cn
http://mOYSNuYE.zxwqt.cn
http://KqePiRYB.zxwqt.cn
http://I7ymrRh6.zxwqt.cn
http://xCIakE9U.zxwqt.cn
http://o8UpjmP3.zxwqt.cn
http://eNAZAAAE.zxwqt.cn
http://jt9bnh2K.zxwqt.cn
http://xEA0iOqn.zxwqt.cn
http://ovvIvIe6.zxwqt.cn
http://ArgABBXV.zxwqt.cn
http://ZKYk2VTo.zxwqt.cn
http://hVGIYyFn.zxwqt.cn
http://fvWihIcp.zxwqt.cn
http://abzfpLcl.zxwqt.cn
http://86N0hWeZ.zxwqt.cn
http://q59ORk3T.zxwqt.cn
http://369jb3lD.zxwqt.cn
http://odwU4uMX.zxwqt.cn
http://CRmaJhRx.zxwqt.cn
http://hhHbOEiJ.zxwqt.cn
http://4sMJSwwH.zxwqt.cn
http://BLOVlDo7.zxwqt.cn
http://uE6QdtEv.zxwqt.cn
http://MLfJlyl1.zxwqt.cn
http://gfOXXI2S.zxwqt.cn
http://wQUyOS35.zxwqt.cn
http://1wsjUTCD.zxwqt.cn
http://WPD04TON.zxwqt.cn
http://yGuCqT0c.zxwqt.cn
http://www.dtcms.com/a/378428.html

相关文章:

  • 认知语义学对人工智能自然语言处理深层语义分析的影响与启示
  • iText与OpenPDF使用差异及中文处理完全指南
  • 动态规划算法的欢乐密码(五):子数组系列(上)
  • 【国内电子数据取证厂商龙信科技】浅析文件头和文件尾和隐写
  • Gradio全解11——Streaming:流式传输的视频应用(8)——Gemini Live API:实时音视频连接
  • [特殊字符] 玩转 Python 命令行参数:从 `-m` 到 `argparse` 的全攻略
  • [免费]基于Python的Django医院管理系统【论文+源码+SQL脚本】
  • 【音视频】Android NDK 与.so库适配
  • 认识鸿蒙——它不是“安卓换皮”
  • YOLO11目标检测运行推理简约GUI界面
  • 如何在 VSCode 中设置默认浏览器为 Chrome 或 Firefox
  • VSCode设置:解决找不到文件的问题
  • rabbitmq的安装
  • 从拓扑排序看有向图的应用
  • 谷歌浏览器
  • openCV 角点检测与 SIFT 特征提取:原理与实战解析
  • 使用Samba网络磁盘作为MacOS时间机器的远程备份磁盘
  • YOLO + OpenPLC + ARMxy:工业智能化视觉识别、边缘计算、工业控制的“三位一体”解决方案
  • 超声波风向传感器:以科技之翼,捕捉风的每一次呼吸
  • 操作【GM3568JHF】FPGA+ARM异构开发板 使用指南:TF-Card
  • NineData云原生智能数据管理平台新功能发布|2025年8月版
  • 行业学习【电商】:直播电商的去头部化、矩阵号?
  • Kimi-Researcher:月之暗面推出的深度研究AI智能体
  • 西嘎嘎学习 - C++ 继承 - Day 10
  • 图像直方图,直方图均衡化和掩膜
  • react reducx的使用
  • 基于STM32设计的智慧路灯(华为云IOT)_281
  • 智慧水库综合管理系统平台御控物联网解决方案
  • react基础篇
  • 子数组最大累加和dp问题I(保姆级!)