Note: the raw PHP larval log is consist of JSON object format text and non-JSON format text
Original PHP larval log:
[2019-01-28 02:28:22] prod.INFO: {"database":"test10","type":"form","id":"20821","comment":"passback:792","timestamp":"2019-01-28 02:28:22"}
log is collected by filebeat ,output to logstash and logstash output to local file
{
"info": "{\"database\":\"test10\",\"type\":\"form\",\"id\":\"19860\",\"comment\":\"passback:792\",\"timestamp\":\"2019-01-28 02:27:39\"}"
}
The output I wanted
{"info":{"database":"test10","type":"form","id":"19860","comment":"passback:792","timestamp":"2019-01-28 02:27:39"}}
logstash conf:
#logstash for pipeline filebeat
input {
beats {
port => 5058
}
}
filter {
if [service] =~ "datapurge-log" {
grok {
match => ["message", "%{UNUSED_TIME:unused_time} %{UNUSED_TYPE:unused_type}\: %{INFO:info}"]
}
mutate {
remove_field=> ["[beat][version]","[beat][hostname]","[host][name]","[input][type]","[prospector][type]","[offset]","[message]"],
gsub => ["info", "[\\]", ""]
}
}
}
output {
if "_grokparsefailure" not in [tags] {
file {
path => "/tmp/datapurge-log"
}
}