I’m using InfluxDB OSS 2.7 and using the influxdb_client Python library to write data. Right now I am attempting to write a lot of data taken in close intervals to the database, but a lot of the points end up not being written.
import os
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
from datetime import datetime
import random
import time
DELAY = 0.1
org = "ORG"
client = InfluxDBClient(url="URL", token="TOKEN", org=org)
writeAPI = client.write_api(write_options=SYNCHRONOUS)
points = []
for i in range(21):
nums = [random.random(),random.random(),random.random()]
current_time = datetime.now()
for num, field in zip(nums,["Field1","Field2","Field3"]):
points.append(Point("MEASUREMENT").tag("DeviceName","DEVICE").field(field,num).time(current_time.astimezone()))
time.sleep(DELAY)
writeAPI.write("BUCKET",org,points)
The code above simulates my use case, I am collecting data in groups of 3 where each group is very close to one another. When I have a very small delay between groups, not all of the points get written. I am confused about this for two main reasons.
- All the points get written when I use a large delay, even though I am writing the entire list at the same time regardless of the delay.
- When most of the points don’t get written, there are always one or two groups of 3 that get written. There is never a partial group.
Any ideas for how I can fix this? Is there something I’m missing regarding how InfluxDB handles writes?