Hey,
logstash.conf
input {
file {
path => "/root/file.json"
start_position => "beginning"
codec => json
type => "state"
}
}
output {
if [type] == "state" {
elasticsearch {
hosts => ["localhost:9200"]
index => "state-%{+YYYY.MM.dd}"
}
}
}
I am saving the json file (input to logstash) by
curl -k --request GET --url https://xxx --header "x-auth-token: xxx" | jq '.' > file.json
json file looks like
{
"server": {
"status": "ok",
"code": "",
"message": "Operation done successfully."
},
"counts": {
"data_counts": 21,
"total_counts": 21
},
"data": {
"pprc": [
{
"sourcevolume": {
"id": "xxx",
"link": {
"rel": "self",
"href": "xxx"
}
},
"targetvolume": {
"id": "xxx",
"link": {}
},
"targetsystem": {
"id": "xxxx",
"link": {}
},
"type": "globalcopy",
"state": "copy_pending"
},
}
]
}
}
In the kibana dashboard, it looks like reading each line as seperate index
{
"_index": "state-2018.11.16",
"_type": "doc",
"_id": "aZxaHWcB1vLuNnA9uMrP",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2018-11-16T16:29:03.955Z",
"@version": "1",
"path": "/root/file.json",
"host": "xxxx",
"message": " "type": "globalcopy",",
"tags": [
"_jsonparsefailure"
],
"type": "state"
},
"fields": {
"@timestamp": [
"2018-11-16T16:29:03.955Z"
]
},
"sort": [
1542385743955
]
}
{
"_index": "state-2018.11.16",
"_type": "doc",
"_id": "epxaHWcB1vLuNnA9uMrP",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2018-11-16T16:29:03.955Z",
"@version": "1",
"path": "/root/file.json",
"host": "xxx",
"message": " "state": "copy_pending"",
"tags": [
"_jsonparsefailure"
],
"type": "state"
},
"fields": {
"@timestamp": [
"2018-11-16T16:29:03.955Z"
]
},
"sort": [
1542385743955
]
}
I added this to logstash filter, no data is sent to elasticsearch
codec => multiline
{
pattern => '^\{'
negate => true
what => previous
}
I even tried by removing jq filter but did not send data to elasticsearch
curl -k --request GET --url https://xxx --header "x-auth-token: xxx" > file.json
json file
{"server":{"status":"ok","code":"","message":"Operation done successfully."},"counts":{"data_counts":21,"total_counts":21},"data":{"pprc":[{"sourcevolume":{"id":"xxx","link":{"rel":"self","href":"https:xxxx"}},"targetvolume":{"id":"1403","link":{}},"targetsystem":{"id":"xxx","link":{}},"type":"globalcopy","state":"copy_pending"}}]}}
Can anyone help me?