如何编写 logstash 输出配置以获取 ABC,AD_EF,123?
how to write the logstash output config to get ABC,AD_EF,123?
我的日志格式是:
XXX: 03-20 17:52:28: XXX. * 0 XXX [XXX] [X XX: X]:XXX\tABC:AD_EF:123\t0\tXXXXXXXXXXXXXXXX\tXXXXXXXXXXXXXXXXXXX
如何编写 logstash 输出配置以获取 ABC,AD_EF,123?
输出示例:
好,ABC,DEF,123
output {
file {
path => "/xxx/xxx/xxx/output.txt"
codec => plain {
format => "good,ABC,DEF,123" # how to write this regular expression????
}
flush_interval => 0
}
}
您的日志输出中似乎嵌入了标签,这些标签将您的数据括起来。这很好,因为这意味着 the csv
filter 可以为您完成。
filter {
csv {
separator => " "
columns => [ 'garbage1', 'good', 'garbage2', 'garbage3', 'garbage4' ]
source => "message"
}
}
注意,that is the actual tab character in there,这里很难表示。
然后您会将 good
字段的内容输出到您的文件中。
感谢大家的帮助,但也许我犯了一个错误。
最后,我得到了我的任务的答案:
filter {
grok {
match => {
"message" => "XXX\t(?<field1>\w+?):(?<field2>\w+?):(?<field3>\d+?)\t"
}
}}
我的日志格式是:
XXX: 03-20 17:52:28: XXX. * 0 XXX [XXX] [X XX: X]:XXX\tABC:AD_EF:123\t0\tXXXXXXXXXXXXXXXX\tXXXXXXXXXXXXXXXXXXX
如何编写 logstash 输出配置以获取 ABC,AD_EF,123?
输出示例: 好,ABC,DEF,123
output {
file {
path => "/xxx/xxx/xxx/output.txt"
codec => plain {
format => "good,ABC,DEF,123" # how to write this regular expression????
}
flush_interval => 0
}
}
您的日志输出中似乎嵌入了标签,这些标签将您的数据括起来。这很好,因为这意味着 the csv
filter 可以为您完成。
filter {
csv {
separator => " "
columns => [ 'garbage1', 'good', 'garbage2', 'garbage3', 'garbage4' ]
source => "message"
}
}
注意,that is the actual tab character in there,这里很难表示。
然后您会将 good
字段的内容输出到您的文件中。
感谢大家的帮助,但也许我犯了一个错误。 最后,我得到了我的任务的答案:
filter {
grok {
match => {
"message" => "XXX\t(?<field1>\w+?):(?<field2>\w+?):(?<field3>\d+?)\t"
}
}}