For some context, I am completeley new to logstash and am interested in filtering this data in three ways:
- remove ceratin fields such as "anonymousId" or "library" (which is nested within context)
- extract fields from a nest (e.g. move "plan" outside of its nest of "properties"
- rename fields
- attempt to make the object as 'flat' (un-nested) as possible.
Below is the RAW json that is being forwarded to logstash, via an HTTP POST, and I will go through what I have tried.
{
"anonymousId":null,
"channel":"server",
"context":{
"ip":"208.54.83.183",
"library":{
"name":"analytics-ruby",
"version":"2.0.12"},
"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36"},
"event":"Logged In",
"integrations":{},
"messageId":"a4c76305-1b02-46c9-8399-76a58fc8edb9",
"originalTimestamp":"2015-07-27T11:19:27.797+02:00",
"projectId":"Y0xNBc7l2I",
"properties":{"plan":"Admin"},
"receivedAt":"2015-07-27T09:19:29.374Z",
"sentAt":"2015-07-27T09:19:27.809Z",
"timestamp":"2015-07-27T09:19:29.362Z",
"type":"track",
"userId":"1",
"version":2,
"writeKey":"keqIuqD3O8iL1M5"
}
- Using grok's remove_field was partially successful but I was unable to remove "anoymousId" (my instinct tells me that this was due to it having a null value)
- I was able to remove "channel", "integrations" - but unable to remove "context" nor "library" (I attempted to use object-dot-notation)
- As odd as it may sound - all of the above was done without the "json" codec
- Now I am at the point of trying to achieve my goals with the "json" codec and using the json filter plugin, but to no avail - I am not able to remove, add or alter any fields currently, below is my config file
input {
http { port => 8090
codec => "json"
}
}
filter {
grok {
match => [ "message", "%{GREEDYDATA}"]
}
json {
source => "message"
remove_field => "channel"
}
}
output {
stdout { codec => rubydebug }
}
If anyone could point out my oversite or redirect my efforts, it would be greatly appreciate it.
Edit: I apologize for the RAW JSON not being very readable, I'm working on getting the post to display the json with proper formatting.