Hello I'm trying to parse a log file where different log types coexist. Hope someone can help This are all log types:
[2022-05-18 11:09:41] dev.INFO: Inserting new User...
[2022-05-18 11:09:41] dev.INFO: Insert successful for user {"idmember":0000,"idcard":"000","name":"FRANCISCO","surname_1":"GARCIA","surname_2":"SUAREZ","email":"hello@gmail.com","phone_1":"6666666","phone_2":"99999999","birthdate":"1992-02-26","gender_category_id":3,"idcard_category_id":4,"club_id":4,"status":1,"connector":"0000000a-b"}
[2022-05-18 11:09:41] dev.INFO: Insert successful for user {"idmember":0000,"idcard":"000","name":"FRANCISCO","surname_1":"GARCIA","surname_2":"SUAREZ","email":"hello@gmail.com","phone_1":"6666666","phone_2":"99999999","birthdate":"1992-02-26","gender_category_id":3,"idcard_category_id":4,"club_id":4,"status":1,"connector":"0000000a-b"} Response Status:201
[2022-05-18 11:09:41] dev.INFO: Starting new import... IdMember: '000000' Connector: 'Big Test'
This is my logstash.conf:
input {
beats {
port => 5044
}
}
##filter data filtering operation
filter {
grok {
match => {
"message" => "\[%{TIMESTAMP_ISO8601:timestamp}\] %{DATA:env}\.%{DATA:severity}: (?<log>[^{]+)?%{GREEDYDATA:raw-json}"
}
}
json {
source => "raw-json"
target => "json"
}
mutate {
rename => { "message" => "raw-message" }
rename => { "json" => "raw-json" }
}
}
output {
if "log1" in [tags] { #Write iislog log to es
elasticsearch{
hosts => ["http://elasticsearch:9200"]
index => "log1-%{+YYYY.MM.dd}"
}
stdout {}
}
if "log2" in [tags] { #Write iislog log to es
elasticsearch{
hosts => ["http://elasticsearch:9200"]
index => "log2-%{+YYYY.MM.dd}"
}
stdout {}
}
}
With wich I'm only able to parse this log:
[2022-05-18 11:09:41] dev.INFO: Insert successful for user {"idmember":0000,"idcard":"000","name":"FRANCISCO","surname_1":"GARCIA","surname_2":"SUAREZ","email":"hello@gmail.com","phone_1":"6666666","phone_2":"99999999","birthdate":"1992-02-26","gender_category_id":3,"idcard_category_id":4,"club_id":4,"status":1,"connector":"0000000a-b"}
I only need to parse the json when appearing and get the rest of the message as separate fields. Any suggestion?
Thanks!