是否有更好的解决方案工具将aws cloudtrail日志发送到kibana,这里我使用AWS的ElasticSearch服务
答案 0 :(得分:1)
下面是我使用1.4.2的logstash输入。它运行良好,但我怀疑它是嘈杂的(它需要很多S3 GET / HEAD / LIST请求)。
input {
s3 {
bucket => "bucketname"
delete => false
interval => 60 # seconds
prefix => "cloudtrail/"
type => "cloudtrail"
codec => "cloudtrail"
credentials => "/etc/logstash/s3_credentials.ini"
sincedb_path => "/opt/logstash_cloudtrail/sincedb"
}
}
filter {
if [type] == "cloudtrail" {
mutate {
gsub => [ "eventSource", "\.amazonaws\.com$", "" ]
add_field => {
"document_id" => "%{eventID}"
}
}
if ! [ingest_time] {
ruby {
code => "event['ingest_time'] = Time.now.utc.strftime '%FT%TZ'"
}
}
ruby {
code => "event.cancel if (Time.now.to_f - event['@timestamp'].to_f) > (60 * 60 * 24 * 1)"
}
ruby {
code => "event['ingest_delay_hours'] = (Time.now.to_f - event['@timestamp'].to_f) / 3600"
}
# drop events more than a day old, we're probably catching up very poorly
if [ingest_delay_hours] > 24 {
drop {}
}
# example of an event that is noisy and I don't care about
if [eventSource] == "elasticloadbalancing" and [eventName] == "describeInstanceHealth" and [userIdentity.userName] == "deploy-s3" {
drop {}
}
}
}
在s3 input page上解释了credentials.ini格式;它只是这个:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
我也有一个搜索结果会将结果发送到我们的#chatops,但我不会在此处发布。