日志存储 CSV 输出插件



我正在使用 Logstash 解析包含单行 JSON 数据的文件并将其输出为 CSV 格式的文件。 它不是将数据输出为很好的分隔值,而是使用时间戳、主机和消息字段为我提供单行数据。我在官方 Logstash 论坛上找到了这个问题,但它没有回应。有没有其他人遇到过这个问题,知道如何解决它或有任何建议?提前谢谢。

输出

电流输出

2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}

期望的输出

timestamp, id, name
timestamp, id, name
timestamp, id, name

配置

input {
    file {
        path => "input path"
        sincedb_path => "C:Logstash.sincedb*"
        start_position => "beginning"
        codec => "json"
        type => "type"
    }
}
filter {
    mutate {
        add_field => {"eventName" => "%{[event][eventName]}"}
        add_field => {"uniqueDeviceID" => "%{[event][deviceSegment][uniqueDeviceID]}"}
    }
    prune {
        whitelist_names => ["eventName", "uniqueDeviceID", "@timestamp"]
    }
}
output {
    stdout {codec => rubydebug}
    csv {
        fields => ["uniqueDeviceID", "eventName", "@timestamp"]
        path => "output path"
    }
}
这是一个

已知的错误

使用 Logstash 将数据从 Elasticsearch 导出到 CSV

https://github.com/logstash-plugins/logstash-output-csv/issues/10

最新更新