'Recording high frequency time-series data with influxdb

I want to record data every 10 milliseconds. Here is the sample code:

with InfluxDBClient(url=url, token=token, org=org, enable_gzip=True) as client:
    with client.write_api(
        write_options=WriteOptions(
            batch_size=100, flush_interval=500, jitter_interval=0
        )
    ) as write_client:

        while True:
            time.sleep(0.01)
            val = np.random.randint(10)
            print(val)
            write_client.write(
                bucket,
                org,
                {
                    "measurement": "my_measurement",
                    "fields": {"my_value": int(val)},
                },
            )
            write_client.flush()

However, the above does not record with a required frequency. Also, it is confusing for me how the batching will be handled in this case.



Solution 1:[1]

You need to specify time for the data point, otherwise it will be assigned server time when it is received by the server. Batching won't affect it even more then.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alespour