使用 influxdb 记录高频时间序列数据
我想每 10 毫秒记录一次数据。下面是示例代码:
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()
但是,上面的记录并没有按要求的频率进行记录。另外,在这种情况下如何处理批处理也让我感到困惑。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.