0
votes

Issue:

When I send the data using the below curl command to elastic search im getting the below error

Command : I created the below template using the curl command and it worked fine

curl -X PUT http://localhost:9200/_template/cn_health_monitoring -d '{"template":"cn_health_monitoring","settings":{"index.refresh_interval":"5s"},"mappings":{"default":{"_all":{"enabled":true},"properties":{"@timestamp":{"type":"string"},"appliance_id_string":{"type":"string","index":"not_analyzed"},"mother_board_serial_number":{"type":"string","index":"not_analyzed"},"mother_board_name":{"type":"string","index":"not_analyzed"}}}}}'

But

When I send the data using the below command I get the error 500 or 400

curl -XPOST http://localhost:9200/_bulk -d '{"index":{"_index":"cn_health_monitoring","_type":"ipfix"}} \n {"@timestamp":"2015-07-18 21:39:10","appliance_id_string":" 32444335-3732-4A31-5143-A0B3CC82A9B1""mother_board_serial_number":" 5CD2271JQC","mother_board_name":" HP Pavilion g6 Notebook PC"}'

Error:

{
    "error": "ActionRequestValidationException[Validation Failed: 1: no requests added;]",
    "status": 500
} 

and

{
    "took": 219,
    "errors": true,
    "items": [
        {
            "create": {
                "_index": "cn_health_monitoring",
                "_type": "ipfix",
                "_id": "ghfPSLv1Tayw03jTr0Zi6Q",
                "status": 400,
                "error": "MapperParsingException[failed to parse, document is empty]"
            }
        }
    ]
}
1

1 Answers

0
votes

First, You have missing comma before the mother_board_serial_number

Then, you can do this using file (maybe there are other ways, but this seems to work)

eran@eran-laptop:~$ cat r
{"index":{"_index":"cn_health_monitoring","_type":"ipfix"}}
{"@timestamp":"2015-07-18 21:39:10","appliance_id_string":" 32444335-3732-4A31-5143-A0B3CC82A9B1","mother_board_serial_number":" 5CD2271JQC","mother_board_name":" HP Pavilion g6 Notebook PC"}

eran@eran-laptop:~$ curl -XPOST localhost:9200/_bulk --data-binary @r 
{"took":2,"errors":false,"items":[{"create":{"_index":"cn_health_monitoring","_type":"ipfix","_id":"AU6lweKRmOtv0CHjm9cD","_version":1,"status":201}}]}