Thanks Fabio-sama,
I have an array of json objects with the number of ticket solded every 3 hours.
I don't show you all beacuse are more of 10000.
This is an extract of my file "people.json":
[
{ "date": "2020-01-20 20:00:00",
"country": "US",
"men": 101,
"women": 26,
"childrens": 127,
},
{ "date": "2020-01-20 23:00:00",
"country": "US",
"men": 144,
"women": 20,
"childrens": 99,
},
{ "date": "2020-01-21 02:00:00",
"country": "US",
"men": 91,
"women": 123,
"childrens": 87,
}
]
I used logstash to push data into elasticsearch and visualize this data with kibana.
I used the most simple conf file because I have all I need into json so:
input {
file {
path => "/tmp/people.json"
start_position => "beginning"
sincedb_path => "/dev/null"
#codec => "json"
codec => multiline {
pattern => "^{"
negate => true
what => previous
}
}
}
filter {
#Remove "[" and "]"
if [message] == "]" or [message] == "[" { drop {} }
#Remove the "," at the end of object
mutate { gsub => [ "message", "},", "}" ] }
json { source => "message" }
date { match => [ "date", "YYYY-MM-dd HH:mm:ss" ] }
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "logstash-people-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
}
For each object I have a doc in elasticsearch like this:
{
"_index": "logstash-people-2020.01.22",
"_type": "_doc",
"_id": "I7xKznAB6obTCirlmSMC",
"_version": 1,
"_score": null,
"_source": {
"men": 111,
"@timestamp": "2020-01-22T12:00:00.000Z",
"path": "/tmp/people.json",
"@version": "1",
"tags": [
"multiline"
],
"country": "US",
"childrens": 127,
"host": "ubuntu",
"message": "{ \"date\": \"2020-01-22 13:00:00\",\n\"country\": \"US\",\n\"men\": 111,\n\"women\": 26,\n\"childrens\": 127\n}",
"women": 26,
"date": "2020-01-22 13:00:00"
},
"fields": {
"@timestamp": [
"2020-01-22T12:00:00.000Z"
]
},
"sort": [
1579694400000
]
}
Whit this structure it's impossible to create a visualize to show day by day a the trend line of field data value, for example if the number of men day by day increase or decrease.
I updated my conf file because it was wrong.