ok perfect many thanks...now it work
but there are two spaces after INFO
right,Now I have this
{"path":"C:\\Users\\Lock\\Desktop\\as.3","@timestamp":"2017-11-02T20:13:03.325Z","@version":"1","host":"Lock","message":"2017-06-08 12:10:12,906 | INFO | nager-plugin-out |
ok, now I would like to delete fields of my path, my timestamp, host..
Than i thinked to use "mutate filter" but....
when i use it for the host field and for the path field it work properly,
but if i use it also for @timestamp and @version fields , system give me an error
input{
file
{
path => "C:\Users\Lock\Desktop\as.3"
start_position => "beginning"
sincedb_path => "/dev/null"
ignore_older => 0
}
}
filter {
grok {
match => ["message", "(?<info>.*\| INFO \|.*)"]
break_on_match => true
add_field => {"type" => "log_info"}
}
if !( "" in [info]){drop{}}
mutate {remove_field => ["path","host"] }
#mutate {remove_field => ["path","@timestamp","@version","host"] }# if i use this row i have errors
}
output {
file { path => "C:\Users\Lock\Desktop\Output_as.log" }
elasticsearch {
index => "error-%{+YYYY.MM.dd}"
document_type => "log_info"
}
stdout {codec=> rubydebug}
}
What version are you running and what error message do you get?
In V6.0.0-rc1, which is what I am running, using remove_field to remove @version and @timestamp works just fine. It may be a limitation in an earlier release.
Not sure why you would not want a timestamp. If you want to set the timestamp to the time in the message you can do that using
I see. It worked for me because I am only using a stdout / rubydebug output. So the remove_field mutation worked just fine. The problem is the elasticsearch output requires every event to have a timestamp.
Firstly, boolean operators have to be lowercase. You should see a message like 'Expected one of #, and, or, xor, nand, ) at line 16, column 29 (byte 314) after filter ...'. So if you fold that AND down to and the configuration will at least compile,
Secondly, you want the condition to be or, not and.
Thirdly, you have an unescaped | in your regex, which is used for alternation (pattern1 or pattern2), and an extra .*.
Fourthly, you have used WORD, which in my locale does not allow the word to contain -. It is a sequence of \w, which for me is [A-Za-z0-9_]
Putting it all together, try this:
grok {
match => ["message", "(?<ts>[^|]*) \| %{WORD:level}%{SPACE} \| (?<msg>[^|]*)%{SPACE} \|.*"]
}
if ( "INFO" != [level] or "nager-plugin-out" != [msg] ) {drop{}}
I can extract a line where there is a WARM but I also want to extract and process the Json that is there after {"request":{"cks":31155,"terminal"........}
I'm trying with this conf.
filter {
grok {
match => ["message", "(?<check>).*\| WARN \|.*(?<check_json>){\"request\".*}"]
break_on_match => true
add_field => {"type" => "log_warn"}
}
if !( "" in [check]){drop{}}
mutate { remove_field => ["path","host","check"]
add_tag => [ "WARNING" ] }
if "_grokparsefailure" in [tags] {drop {}}
else {
json {
source => "check_json"
}}
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.