I’m using API get request to pull raw data from server , then fetch needed information and i use influxDB python client library to push data to my InfluxDB bucket.
The problem is each time value changes of varibale , the record of DB changes (timestamp and value updates). I want to have a new point (with different tiemstamp and value from previous one) each time this happens.
Add a unique timestamp to create a new record instead of updating the existing one that way, InfluxDB will treat each point as a separate entry due to the different timestamps. Code changes you should try to make and test:
# Get current timestamp at microsecond precision if you prefer
current_time = int(datetime.utcnow().timestamp() * 1e9)
p = (
influxdb_client.Point(name_machine)
.tag(name_machine, name_machine)
.field("TCNZ1B3", TCNZ1B3)
.time(current_time)
)
write_api.write(bucket='twgdb', org=org, record=p)
Thanks for your answer. I will test this. If i need to write 4 different variables (fields) per timestamp , do i need to write each point seperatly ? is it possible to write all data points in 1 batch using python client library ?