hey Guys,
kindly help me to solve this
-
There are two types of messages that i am trying to parse
1. {"Code":"BOSIIF902","Message":"Backup stopped. Error during the backup :: SOAP-ERROR: P","time":1583470627,"userId":"*****************","businessUserId":"************","cloudId":4,"domainId":"603","additionalInfo":null} [] [] 2. plain message without any fields eg : "hello how are you"
-
So this was my config before
input {
file {
path => "/home/ubuntu/*"
start_position => "beginning"
}
}
filter {
grok {
match => { "message" => "(?<jsonf>({.*}))"}
}
json {
source => "jsonf"
}
mutate {
remove_field => [ "message","jsonf" ]
}
}
output {
amazon_es {
hosts => ["*****************************"]
region => "us-east-1"
index => "test-%{+YYYY.MM.dd}"
#user => "elastic"
#password => "changeme"
}
}
-
so this was working fine for the 1st message and for the second message it was throwing as_grokparsefailure
-
So the next thing i tried was by putting IF conditions
input {
file {
type => "testlogs"
path => "/home/ubuntu/testlog.log"
start_position => "beginning"
}
}
filter {
# strating if
if [message] == "message" {
# filter
grok {
match => { "message" => "(?<jsonf>({.*}))"}
}
json {
source => "jsonf"
}
mutate {
remove_field => [ "message","jsonf" ]
}
}
}
# output logs to console and to elasticsearch
output {
if [message] =~ "message" {
amazon_es {
hosts => ["******************************"]
region => "us-east-1"
index => "test-%{+YYYY.MM.dd}"
}
}
}
- when i use this i dint get any errors but when i tried to push the logs there was no index created
- i would request anyone to help me out with this , im totally not sure whether im using the conditions in right place .