我的目标是从 kinesis 读取数据并在 s3 上上传 csv 文件,但在 csv 文件中箭头(=>)来自 json 数据,而不是冒号(:)
Logstash 配置文件
input {
kinesis {
application_name => "logstash"
kinesis_stream_name => "events"
type => "kinesis"
region => "us-east-1"
profile => "default"
metrics => "cloudwatch"
codec => "json"
}
}
filter {
grok {
match => { "[data][ti]" => "%{YEAR:event_year}-%{MONTHNUM2:event_month}-%{MONTHDAY:event_day}" }
}
}
output {
s3 {
bucket => "test-logstash"
region => "us-east-1"
prefix => "%{event_year}/%{event_month}/%{event_day}/%{[data][brandid]}/%{[data][event_name]}"
encoding => "none"
codec => csv {
separator => "␁"
}
size_file => 200000000
time_file => 60
}
}
将哈希写入 CSV 文件时,使用
as_json
将其转换为 JSON,或使用 to_json
将其转换为 JSON 字符串。