Hello, I'm new to the elastic ecosystem.
I'm trying to use logstash to take a json file as input and then use a filter to split into different events but I'm drowned by all of the info there is online.
This is a short version of my code
{
"proximity": [
{
"network": "all_networks",
"date": "2020-05-12",
"connected": 335,
"visitors": 584,
"passerby": 7201,
"hour": 0
},
{
"network": "all_networks",
"date": "2020-05-12",
"connected": 330,
"visitors": 388,
"passerby": 5829,
"hour": 1
}],
"visitLength": [
{
"network": "all_networks",
"date": "2020-05-12",
"5-20m": 234,
"20-60m": 168,
"1-6h": 99,
"6+h": 83,
"hour": 0
},
{
"network": "all_networks",
"date": "2020-05-12",
"5-20m": 134,
"20-60m": 139,
"1-6h": 115,
"6+h": 0,
"hour": 1
}],
"loyaltyRecords": [
{
"network": "all_networks",
"date": "2020-05-12",
"first": 0,
"daily": 515,
"weekly": 69,
"occasional": 0,
"hour": 0
},
{
"network": "all_networks",
"date": "2020-05-12",
"first": 0,
"daily": 315,
"weekly": 73,
"occasional": 0,
"hour": 1
}]
}
Its actually 16k lines but I'm working with this to make faster tests.
I know I have to use an input which I have like this:
input {
file {
mode => "read"
path => "/home/user/Desktop/data.json"
start_position => "beginning"
codec => json
}
}
Filter is
filter {
json { source => "message"}
split { field => "proximity" }
}
and my output
output {
stdout { }
file { path => "/home/user/Desktop/myfile.txt" codec => json }
}
To make things easier I need each of these to be one entry/doc so then I can output to elastic search (for now I'm using the file to check)
{
"network": "all_networks",
"date": "2020-05-12",
"first": 0,
"daily": 315,
"weekly": 73,
"occasional": 0,
"hour": 1
}
As you may have noticed, I have 3 arrays and each contains the "documents" I want to index.
They could be all in the same index or different indices.
Could anyone help me to understand the order of how to do things? i understand there is also a "multiline" code which i don't know if i need or not.
Also im getting a json parse error so im not sure if my data is coded correctly or maybe i need to use the multiline codec for my input.
Thanks in advance