Hello,
I have an issue with parsing my data.
Here is a sample of JSON:
{
"info": {
"generated_on": "2017-12-03 08:41:42.057563",
"slice": "0-999",
"version": "v1"
},
"playlists": [
{
"name": "Rock",
"collaborative": "false",
"pid": 0,
"modified_at": 1493424000,
"num_tracks": 22,
"num_albums": 27,
"num_followers": 1,
"tracks": [
{
"pos": 0,
"artist_name": "Michael Jackson",
"track_uri": "spotify:track:0UaMYEvWZi0ZqiDOoHU3YI",
"artist_uri": "spotify:d5F5d7go1WT98tk",
"track_name": "Song",
"album_uri": "spotify:album:6vV5Udzzf4Qo2I9K",
"duration_ms": 226863,
"album_name": "The Cookbook"
}],
"num_edits": 34,
"duration_ms": 9065801,
"num_artists": 37
},
{
"name": "Jazz",
"collaborative": "false",
"pid": 0,
"modified_at": 1493424000,
"num_tracks": 22,
"num_albums": 27,
"num_followers": 1,
"tracks": [
{
"pos": 0,
"artist_name": "Whatever",
"track_uri": "spotify:track:0UaMYEvWZi0ZqiDOoHU3YI",
"artist_uri": "spotify:d5F5d7go1WT98tk",
"track_name": "Song",
"album_uri": "spotify:album:6vV5Udzzf4Qo2I9K",
"duration_ms": 226863,
"album_name": "The Cookbook"
}],
"num_edits": 34,
"duration_ms": 9065801,
"num_artists": 37
}
]
}
It contains a set of playlist, and playlists contain tracks with several information.
My logstash filter:
input{
file{
path => "/home/data/sample.json"
sincedb_path => "/dev/null"
start_position => "beginning"
codec => multiline {
pattern => "^Spalanzani"
negate => true
what => previous
auto_flush_interval => 1}
}
}
filter {
json {
source => "message"
}
}
output{
elasticsearch{
hosts => "localhost:9200"
index => "music"
}
stdout { }
}
But it not leading me to anywhere.
What I want the output to be in Kibana is 1 hit for each track with all the above fields (artist name etc.) but ALSO a field that refers to the playlist the track si linked to (playlist.name and playlist.pid).
I also have no interested in the very first part of the file ("info")
I am having a terrible time doing the logstash filter for this.
Does anybody know what should I do?
Thank you