amazon-web-services - ELK Stack - AWS LoadBalancer 访问日志用户代理
问题描述
我最近集成了 ELK 堆栈,该堆栈具有来自 S3 存储的 AWS ELB(类型:应用程序)访问日志的输入数据。我的目标是对用户代理有一个直观的了解。但我有一个小问题;用户代理 (userAgent) 不包含有效值;它只包含“-”。
有什么想法/可能的解决方法吗?谢谢!
我有以下logstash配置
input {
s3 {
bucket => "xxxxxxxx-elb-logs"
prefix => "AWSLogs/xxxxxxxxxxxx/elasticloadbalancing/xx-west-x"
region => "xx-west-x"
type => "elblogs"
codec => plain
}
}
filter {
if [type] == "elblogs" {
grok {
match => ["message", "%{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:elb_name} %{IP:elb_client_ip}:%{INT:elb_client_port:int} (?:%{IP:elb_backend_ip}:%{NUMBER:elb_backend_port:int}|-) %{NUMBER:request_processing_time:float} %{NUMBER:backend_processing_time:float} %{NUMBER:response_processing_time:float} (?:%{INT:elb_status_code:int}|-) (?:%{INT:backend_status_code:int}|-) %{INT:elb_received_bytes:int} %{INT:elb_sent_bytes:int} \"(?:%{GREEDYDATA:elb_request}|-)\" \"(?:%{GREEDYDATA:userAgent}|-)\" %{NOTSPACE:elb_sslcipher} %{NOTSPACE:elb_sslprotocol}"]
match => ["message", "%{GREEDYDATA:event_name} for ELB: %{NOTSPACE:elb_name} at %{TIMESTAMP_ISO8601:timestamp}"]
}
if [elb_request] =~ /.+/ {
grok {
match => ["elb_request", "(?:%{WORD:http_method}) (?:%{DATA:http_path})? (?:% {DATA:http_type}/%{NUMBER:http_version:float})?|%{GREEDYDATA:rawrequest}"]
}
}
if [http_path] =~ /.+/ {
grok {
match => ["http_path", "(?:%{WORD:http_path_protocol}://)?(% . {NOTSPACE:http_path_site}:)?(?:%{NUMBER:http_path_port:int})?(?:%{GREEDYDATA:http_path_url})?"]
}
}
geoip {
source => "elb_client_ip"
}
}
date {
match => [ "timestamp", "ISO8601" ]
}
}
output {
stdout { codec => rubydebug }
elasticsearch {
hosts => ["xxx.xxx.xxx.xxx:9200"]
index => "logstash-xx-xxx-xxx-index"
}
}
用户代理值 - 来自 AWS ELB 访问日志:
解决方案
推荐阅读
- python - 熊猫数据框乘法/公式底行到顶行
- c# - 我想知道Physics Pang Game 在Ball Bounce 中使用什么
- sql - 相同的数据类型,不同的数据行为
- django - 如果 form.is_valid() 如何测试重定向
- swift - 有没有办法从 WatchOS 检查可更新订阅的状态?
- regex - 为什么我的正则表达式 (jobboardid=0#5) 在 Google Analytics 中没有产生任何数据?
- python - 从目录中读取文件
- google-sheets - 如果行中的两个单元格不包含相同的文本,如何突出显示一行
- mysql - 数据库中特定用户的连接 + 计数的 MySQL 查询
- jmeter - 如何在 JMeter 中运行 Robot Framework 测试用例?