Open kunal-arora opened 5 years ago
This is because of protocole. if you change it to 'line', it will work. but I see that it does not store the timestamp correctly.
But everything works normal when I use my local setup to access the ec2 influx instance. Dont get why it is not working for requests from that specific instance of python code.
@kunal-arora can you try adding database=<your_database_name>
within the client.write_points()
API?
e.g.
client.write_points(jsonData, time_precision='ms', protocol='json', database='test')
@shantanoo-desai it doesn't make any difference, as you can see in the log the database is being passed in correctly and if I put in a wrong database it throughs me an influxdb error. So I do not think its something related to the syntax. The same syntax works If I hit the same db from a different host.
Any update on this ?
I just run into the same problem, that the data were not visible in the influx database. Even tough, client.write_points()
did return True
.
I noticed, that the time
was not correctly formatted in the json.
So I had to correct the time format to datetime.datetime.utcnow().isoformat()
which will be '2020-08-15T14:36:24.025388'
Below you will find the json_body, that is transmitted.
json_body = [ { "measurement" : "weather_station", "location": "Home", "tags" : { "host" : "Innoxel", "Region" : "Home" }, "time" : datetime.datetime.utcnow().isoformat(), "fields": { 'temperatureAir': 23.8, 'humidity': 68.0, } } ]
@jeromefischer: I run into the same problem, write_points() isn't inserting new measurements into Influxdb. I tried to update the time field as you said earlier but it didn't work.
How did you solve the issue ? Thanks
I have a very similar problem: when I run my python code on google cloud, the write_api of influxdb_client does not do anything nor raise an error, but running the same code locally the write_api works perfectly. I use the following methods:
client=influxdb_client.InfluxDBClient(url, token, debug=True, org=org)
query_api = client.query_api()
write_api = client.write_api()
p = influxdb_client.Point("my_measurment").field(field, val).time(now+tz.utcoffset(datetime.now()))
write_api.write(bucket=bucket, org=org, record=p)
Hi @lennartklfhs,
your question is related to v2 client - influxdb-client-python.
The default configuration of write_api
uses underlaying queue to insert batches into InfluxDB. You have to call write_api.close()
to flush data or you can use client.write_api(write_options=SYNCHRONOUS)
for direct writes into database.
Regards
Did anyone found the root cause of this problem?
client.write_points(jsonData, time_precision='ms', protocol='json')
I am using this to write into influxdb, it was working fine then I dropped the database and created a new one, since then it has not been writing on influxdb only when the request is made from the flask api thats hosted on the same EC2. If requested from a different server eg: localhost, it works fine. I believe its some cache issue and it has frustrated me to the core. I have rebooted, stopped and re-launched, uninstalled influx and reinstalled still no effect.
When I hit there's this log:
Oct 17 09:02:16 ip-172-31-11-234 influxd[2548]: [httpd] 127.0.0.1 - <username> [17/Oct/2019:09:02:16 +0000] "POST /write?db=buildings_data_staging_one&precision=ms HTTP/1.1" 204 0 "-" "python-requests/2.22.0" d12d0d15-f0bc-11e9-801a-02f6d7ec92de 89
Came here cos I couldn't think of anything.