I have this code:
client = InfluxDBClient(
':' + influxdb_config['DATABASE_PROPERTIES']['PORT'],
token=influxdb_config['DATABASE_PROPERTIES']['TOKEN'], retries=retries, enable_gzip=True)
write_api = client.write_api(write_options=WriteOptions(
write_api.write(bucket, org, data, write_precision=WritePrecision.US)
This uses batch writing. How can I know if errors have occurred?
Welcome to the community.
Please provide more information.
What is the error message exactly?
Which InfluxDB database version (1.x.x or 2.x.x) are you writing to?
Please show us some more coherent real code. The code shown can’t work at all as
client is declared later?
Sorry, I edited the code. This is the real code and it works. I can try to write bad data and then I can put a breakpoint inside the package in this function:
def _on_next(response: _BatchResponse):
logger.error("The batch item wasn't processed successfully because: %s", response.exception)
logger.debug("The batch item: %s was processed successfully.", response)
And here I can see that the error is:
Reason: Bad Request
But how can I be aware of that error in my code?