从InfluxDB测量中删除带有多余字段值的点 [英] Delete points with unwanted field values from InfluxDB measurement

查看:648
本文介绍了从InfluxDB测量中删除带有多余字段值的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

InfluxDB允许您根据 删除点 WHERE tag ='value'条件,但不是按字段值。

InfluxDB lets you delete points based on WHERE tag='value' conditions, but not by field value.

例如,如果您不小心存储了值为在一系列正浮点数(例如CPU利用率)中为-1,从指标WHERE cpu = -1 中删除​​将返回此错误:

For example, if you have accidentally stored a measurement with a value of -1 in a series of positive floats (e.g. CPU utilization), DELETE FROM metrics WHERE cpu=-1 will return this error:


删除期间WHERE子句中不支持的字段

fields not supported in WHERE clause during deletion


推荐答案

在InfluxDB中这仍然是不可能的(2015年-2020年)-请参见机票3210

This is still (2015 - 2020) not possible in InfluxDB - see ticket 3210.

您可以通过在测量中插入具有相同时间戳和标记集

You could overwrite the point with some other values by inserting in the measurement a point with the same timestamp and tag set:


一个点由测量名称唯一标识,标签集和时间戳。如果提交的新点具有与现有点相同的度量,标记集和时间戳,则该字段集将成为旧字段集和新字段集的并集,其中任何联系都将移至新字段集。这是预期的行为。

A point is uniquely identified by the measurement name, tag set, and timestamp. If you submit a new point with the same measurement, tag set, and timestamp as an existing point, the field set becomes the union of the old field set and the new field set, where any ties go to the new field set. This is the intended behavior.

由于您不应该插入空值,您可能要重复上一个点的值。

Since you're not supposed to insert nulls, you'll probably want to repeat the values from the previous point(s).

您可能会考虑插入具有相同时间戳的点,并为其中一个标签设置唯一值,然后对该标签运行删除操作:

You might think about inserting a point with the same timestamp, and setting a unique value for one of the tags, then running a delete against that tag:

DELETE FROM measurement WHERE some_existing_tag='deleteme'

但是,这将无法正常工作。当您插入第二个 deleteme 点时,由于 deleteme 标记而设置了不同的标记,因此InfluxDB将创建一个新的观点。然后 DELETE 命令将删除 it ,但不会删除您要删除的原始点。

This won't work though. When you insert that second deleteme point, it has a different tag set due to the deleteme tag, so InfluxDB will create a new point for it. Then the DELETE command will delete it, but not the original point you wanted to delete.

这篇关于从InfluxDB测量中删除带有多余字段值的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆