Home > front end >  How to transform JSON to send it to elasticsearch?
How to transform JSON to send it to elasticsearch?

Time:05-24

I have the following data and I want to ingest it into elasticsearch. I have stored this data in a JSON file and using filebeat I am shipping it to elasticsearch BUT when I view this data in elasticsearch it is read line by line instead of JSON. Can anyone tell how can I parse it in JSON format to elasticsearch. I am new to this, I don't know how to write pipelines in elasticsearch.

{
    "student": "jacob",
    "Data": {
        "Grade": "1",
        "RegNo": "X1"
    },
    "sorting": 2,
    "data": [
        {
            "ID": "101",
            "Num": 31
        },
        {
            "ID": "102",
            "Num": 73
        },  

    ]
}

CodePudding user response:

Filebeat documentation refers to a parser specifically for JSON files, named ndjson, which can be referred below.

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html#_ndjson

Also, your application that logs/creates the JSON data, can be made to send JSON objects in single line for every event, filebeat will parse it automatically. Check link below for an example.

https://www.elastic.co/blog/structured-logging-filebeat

  • Related