0

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.

torayeff
  • 9,296
  • 19
  • 69
  • 103

1 Answers1

0

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.

alespour
  • 397
  • 1
  • 5