0

链接:https ://github.com/influxdata/influxdb-python/blob/master/examples/tutorial_server_data.py

  • 这可能是一个初学者的问题。

我试图复制该示例,但是当我在终端中运行时,我收到了以下消息:

终端:

python3 tutorial_server_data.py 

python3 tutorial_server_data.py --host 'localhost' --port 8086 --nb_day 15

...

Create database: tutorial
Create a retention policy
Write points #: 4320
Traceback (most recent call last):
  File "tutorial_server_data.py", line 93, in <module>
    main(host=args.host, port=args.port, nb_day=args.nb_day)
  File "tutorial_server_data.py", line 63, in main
    client.write_points(series, retention_policy=retention_policy)
  File "/home/joaoguilherme/.local/lib/python3.5/site-packages/influxdb/client.py", line 530, in write_points
    consistency=consistency)
  File "/home/joaoguilherme/.local/lib/python3.5/site-packages/influxdb/client.py", line 598, in _write_points
    protocol=protocol
  File "/home/joaoguilherme/.local/lib/python3.5/site-packages/influxdb/client.py", line 343, in write
    headers=headers
  File "/home/joaoguilherme/.local/lib/python3.5/site-packages/influxdb/client.py", line 302, in request
    raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"partial write: points beyond retention policy dropped=4320"}
4

1 回答 1

0

信不信由你,但这实际上是按预期运行的(或者也按编码运行)。

如果你看第 60 行

client.create_retention_policy(retention_policy, '3d', 3, default=True)

创建了 3 天的保留策略,因此超过 3 天的所有数据都会被自动删除

你给了它一个 15d 的标志,所以你丢弃了 12 天的数据。

查看脚本,它实际上写错了,我不会使用它。即,它允许您指定 nb_day 值,但硬编码为 15(第 20 行)。

于 2020-01-20T16:57:30.867 回答