-
Notifications
You must be signed in to change notification settings - Fork 185
Python default write-api commands no longer writing to bucket #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @SeanMayer335174, thanks for using our client.
Your code looks fine. I've tested it and everything looks good. Try to enable debug logging on the client by: from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
import datetime
my_url = "http://localhost:8086"
my_bucket = "my-bucket"
my_org = "my-org"
my_token = "my-token"
point_name = "measurement"
field1 = {"frequency": 50}
field2 = {"amplitude": 3}
my_tag = {"to_test": "atest"}
with InfluxDBClient(url=my_url, token=my_token, org=my_org, debug=True) as client:
writer = client.write_api(write_options=SYNCHRONOUS)
my_point = Point(point_name)
my_point.tag(list(my_tag.keys())[0], my_tag[list(my_tag.keys())[0]])
my_point.field(list(field1.keys())[0], field1[list(field1.keys())[0]])
my_point.field(list(field2.keys())[0], field2[list(field2.keys())[0]])
my_point.time(datetime.datetime.utcnow(), WritePrecision.NS)
writer.write(my_bucket, my_org, my_point)
csv_lines = client.query_api().query_csv(f"from(bucket: \"{my_bucket}\") |> range(start: -10m) |> group()")
for csv_line in csv_lines:
print(csv_line) Regards |
I tried your debug recommendation. It did print out some details, although I'm struggling to troubleshoot them:
Unfortunately I don't know what to do with this information. The "No Content" reply seems to indicate the client is just ignoring the write request. Beyond that, the send appears to be correct, it is just not affecting the client. I checked to make sure the client was running actively, which I can confirm. Still can't figure out what the problem here is. |
The Did you try querying your written data by: from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
import datetime
my_url = "http://localhost:8086"
my_bucket = "my-bucket"
my_org = "my-org"
my_token = "my-token"
point_name = "measurement"
field1 = {"frequency": 50}
field2 = {"amplitude": 3}
my_tag = {"to_test": "atest"}
with InfluxDBClient(url=my_url, token=my_token, org=my_org, debug=True) as client:
writer = client.write_api(write_options=SYNCHRONOUS)
my_point = Point(point_name)
my_point.tag(list(my_tag.keys())[0], my_tag[list(my_tag.keys())[0]])
my_point.field(list(field1.keys())[0], field1[list(field1.keys())[0]])
my_point.field(list(field2.keys())[0], field2[list(field2.keys())[0]])
my_point.time(datetime.datetime.utcnow(), WritePrecision.NS)
writer.write(my_bucket, my_org, my_point)
csv_lines = client.query_api().query_csv(f"from(bucket: \"{my_bucket}\") |> range(start: -10m) |> group()")
for csv_line in csv_lines:
print(csv_line) ? |
This issue has been closed because it has not had recent activity. Please reopen if this issue is still important to you and you have additionally information. |
I have a similar issue as SeanMayer335174, no feedback if the write is succesfull or not. I tried the callback code from the examples but get no response. Setting debug=True in the client does help but it is more complex to capture this feedback as it is send to the std.out. Therefore I'm hoping to monitor the callback.succes output to check if the write was succesfull. Any idea what is wrong in my code, why don't I get a callback response?
|
Hi @SamReub, You are using Bes |
I've been trying to write to a localhost Influxdb 2.2 server I have running on a command terminal. Using the default python write_api commands I try to write to the system with the following code:
This code runs without exception every time I run it. I submitted it for approval after I confirmed the data would input to the bucket and remain there.
Then, without exception or change, the write function stopped changing the bucket. The program would execute just fine, we would even add print statements to examine my_point and make sure all of the information was correct, and complete with a confirmation message. Yet when inspecting the bucket no new changes would be found.
Things I've tried:
Inspected bucket retention policy: Using the python bucket_api system I was able to download the bucket's retention policy:
This would output:
[{'every_seconds': 0, 'shard_group_duration_seconds': 604800, 'type': 'expire'}]
Which, as far as I can tell, doesn't seem to conflict with anything I was doing.
Flushed writer memory:
I had heard adding the following code would flush the writer api, and eliminate some of the problems I was having:
No effect.
Tried adding http message processing system:
Frustrated I wasn't even getting exceptions, I went to the influxdb github and found the following to help detect http success and fail messages to help me troubleshoot:
Still didn't actually write to the bucket, still didn't provide any messages or exceptions when it failed.
Conclusion: I'm not sure where to go with this. The code was basically adapted from the default code influxdb supplied. I know it worked once, so the problem isn't how the code is constructed. There must be a problem with how the bucket is being managed? It's a simple bucket I didn't do anything with, this was a test solution, but it seems to have blown up in my face. Nothing seems to add data to the bucket anymore and I can't think of anything else I can do to solve it.
The text was updated successfully, but these errors were encountered: