Error on inserting data to InfluxDB - insert

I am new to influxdb.
By learning from the official site of influx, I have entered the line
curl -i -XPOST "http://localhost:8086/write?db=mydb" --data-binary "cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000"
but I am getting error :
invalid character:"//" looking for beginning of value
any solution ?

Related

Unable to send bulk request to Elasticsearch cloud

I am trying to send bulk request to Elasticsearch cloud with following curl string -
curl -u myusername:mypassword -H "Content-Type: application/x-ndjson" -XPOST https://el.kb.us-east-2.aws.elastic-cloud.com/products/_bulk --data-binary "products-bulk.json"
I am getting the following error -
{"statusCode":404,"error":"Not Found","message":"Not Found"}
Can someone please help me with the issue ?
I think you're using the wrong URL, you're using the Kibana URL while you should be using the ES one
https://el.kb.us-east-2.aws.elastic-cloud.com
^^
||
Should be
https://el.es.us-east-2.aws.elastic-cloud.com
^^
||

What is causing the Elasticsearch bulk load to fail?

I can't figure out why I can't bulk load Elasticsearch with JSON. I've done this before but this time I am totally stumped.
I have processed a set of JSON documents into Elastic Bulk Load Format and am trying to bulk load the index I just created (verified created, can be queried, and is empty).
{"create": {"_id": "ef68e997-c616-4b0b-b08e-dfc09f8cb08f"}}
{"id": "ef68e997-c616-4b0b-b08e-dfc09f8cb08f", "title": "My document"}
... repeats for all records
The command I run uses a list of paths to the JSON bulk files and a loop to curl/POST them to Elastic using credentials:
while IFS= read -r "path" < "${DOC_LIST_PATH}"
do
echo "Submitting Elastic formatted docs at ${path} to Elastic index 'docs' ..."
curl \
-X POST \
-H "Content-Type: application/x-ndjson" \
"https://${ES_USER}:${ES_PASSWD}#${ES_HOSTNAME}:${ES_PORT}/docs/_bulk" \
--data-binary "#${path}"
done
I've done all this before and it should work but... it doesn't. I get this error instead:
Submitting Elastic formatted docs at data/docs.json/part-00000.json to Elastic index 'docs' ...
Warning: Couldn't read data from file
Warning: "data/docs.json/part-00000.json",
Warning: this makes an empty POST.
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}
... repeats for all files
I have found that the problem is with this bash code, not the data or the bulk load request:
--data-binary "#${path}"
If I replace that with this, it works:
--data-binary "#data/docs.json/part-00000.json"
Making the full working command for a single file:
curl -X POST -H "Content-Type: application/x-ndjson" "https://${ES_USER}:${ES_PASSWD}#${ES_HOSTNAME}:${ES_PORT}/docs/_bulk" --data-binary "#data/docs.json/part-00000.json"
But I need to script this, so this is still maddening. Please help!
This example is also in a gist here

How do i prevent elasticsearch's _analyze from interpretting yml

I'm trying to use the _analyze api with text that looks like this:
--- some -- text ---
This request works as expected:
curl localhost:9200/my_index/_analyze -d '--'
{"tokens":[]}
However, this one fails:
curl localhost:9200/medical_documents/_analyze -d '---'
---
error:
root_cause:
- type: "illegal_argument_exception"
reason: "Malforrmed content, must start with an object"
type: "illegal_argument_exception"
reason: "Malforrmed content, must start with an object"
status: 400
Considering the formatting of the response, i assume that elasticsearch tried to parse the request as yaml and failed.
If that is the case, how can i disable yml parsing, or _analyze a text that starts with --- ?
The problem is not the yaml parser. The problem is that you are trying to create a type.
The following is incorrect(will give you Malforrmed content, must start with an object error)
curl localhost:9200/my_index/medical_documents/_analyze -d '---'
This will give you no error, but is incorrect. Because it will tell elastic to create a new type.
curl localhost:9200/my_index/medical_documents/_analyze -d '{"analyzer" : "standard","text" : "this is a test"}'
Analyzers are created Index level. verify with:
curl -XGET 'localhost:9200/my_index/_settings'<br/>
So the proper way is:
curl -XGET 'localhost:9200/my_index/_analyze' -d '{"analyzer" : "your_analyzer_name","text" : "----"}'
Previously need to create the analyzer.

not able to index a document using elastic search

This is the first time I am trying to use Elastic Search. I am unable to feed data to it.
here is the command (Having issues with this command):
curl -XPUT localhost:9200/customer/external/1?pretty -d {"name":"John"}
But if I give the same command as below,its working:
curl -XPUT localhost:9200/customer/external/1?pretty -d {"name":true}
Any suggestions will be very helpful.

Why does this ElasticSearch scan and scroll returns IndexMissingException

I run the following:
curl -XGET 'http://my_address/my_index/_search?scroll=1m&size=10&search_type=scan' -d '{'query':{'match_all':{}}}'
It returns a scroll id (very long), and I then use in the first scroll request:
curl -XGET 'http://my_address/my_index/_search/scroll?scroll=1m' -d '<scroll_id>'
It returns an error: {"error":"IndexMissingException[[my_index] missing]","status":404}
I do not know why having this error. I follow the guideline in https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html step by step.
What is going on?
Because your second request (i.e. using the scroll_id) should not take any index and read like this instead:
curl -XGET 'http://my_address/_search/scroll?scroll=1m' -d '<scroll_id>'

Resources