2018-05-29T06:25:02.589432+00:00 ovthick_121 bpradhcp: {"msg": "200 GET /api/v1/sessions?fields=id%2Cchildren HTTP/1.1 reqid=UBRGU4FRB7FDXBB6U4EYGE763UE", "namespace": "rasdk.rest.logger", "http_query": "fields=id%2Cchildren", "msg_id": "e912b173eb9d4520b39c2bde2dd7e906", "http_method": "GET", "duration": 0.0007190704345703125, "src_ip": "172.16.0.51", "http_path": "/api/v1/sessions", "http_status": "200", "priority": 6, "pid": 1, "tid": 140331636516608, "code_file": "/usr/local/lib/python2.7/dist-packages/rasdk/rest/logger.py", "code_line": 80, "code_func": "_log_request", "timestamp": "2018-05-29T06:25:02.589005Z", "app": "bpradhcp", "app_instance": "0", "host": "ovthick_121", "container": "660389ac29b9"}
Tried to parse the above log using grok, json and mutate.
input {
stdin {
}
}
filter {
grok {
match => {"message" => '%{TIMESTAMP_ISO8601:timestamp} %{HOSTNAME:hostname} "%{WORD:container_name}\: %{GREEDYDATA:unparsedjson}"'}
}
json {
source => "unparsedjson"
target => "parsedjson"
#remove_field => ["unparsedjson"]
}
mutate {
add_field => {
"log_message" => "%{[parsedjson][msg]}"
"http_status_code" => "%{[parsedjson][http_status]}"
}
}
}
output {
stdout {
codec => rubydebug
}
}
But it's giving me an error.
{
"host" => "HAM-VIAGGARW-02",
"tags" => [
[0] "_grokparsefailure"
],
"@timestamp" => 2018-05-29T16:24:56.049Z,
"message" => "2018-05-29T06:25:02.589432+00:00 ovthick_121 bpradhcp: {\"msg\": \"200 GET /api/v1/sessions?fields=id%2Cchildren HTTP/1.1 reqid=UBRGU4FRB7FDXBB6U4EYGE763UE\", \"namespace\": \"rasdk.rest.logger\", \"http_query\": \"fields=id%2Cchildren\", \"msg_id\": \"e912b173eb9d4520b39c2bde2dd7e906\", \"http_method\": \"GET\", \"duration\": 0.0007190704345703125, \"src_ip\": \"172.16.0.51\", \"http_path\": \"/api/v1/sessions\", \"http_status\": \"200\", \"priority\": 6, \"pid\": 1, \"tid\": 140331636516608, \"code_file\": \"/usr/local/lib/python2.7/dist-packages/rasdk/rest/logger.py\", \"code_line\": 80, \"code_func\": \"_log_request\", \"timestamp\": \"2018-05-29T06:25:02.589005Z\", \"app\": \"bpradhcp\", \"app_instance\": \"0\", \"host\": \"ovthick_121\", \"container\": \"660389ac29b9\"}",
"log_message" => "%{[parsedjson][msg]}",
"http_status_code" => "%{[parsedjson][http_status]}",
"@version" => "1"
}
{
"host" => "HAM-VIAGGARW-02",
"tags" => [
[0] "_grokparsefailure"
],
"@timestamp" => 2018-05-29T16:24:56.048Z,
"message" => "",
"log_message" => "%{[parsedjson][msg]}",
"http_status_code" => "%{[parsedjson][http_status]}",
"@version" => "1"
}
Can anyone please help me to understand what I am doing wrong here?