1

In an InfluxDB measurement, how can the field values of points matching a query be updated? Is this still not easily doable as of v1.6?

As the example in that GitHub ticket suggested, what's the cleanest way of achieving something like this?

UPDATE access_log SET username='something' WHERE mac='xxx'

Anything better than driving it all from the client by updating individual points?

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
  • 1
    just out of curiosity: what could be the need to update the past? – Yuri G Jan 12 '18 at 01:28
  • @YuriG: [classifying/categorizing data](https://groups.google.com/forum/#!topic/influxdb/rL4lQRu5lv4), [updating outlier values (usually due to collection errors) that affect means](https://github.com/influxdata/influxdb/issues/3210), [delete unwanted field values](https://stackoverflow.com/questions/39685114/delete-points-with-unwanted-field-values-from-influxdb-measurement), [rename values to conform to a new naming scheme](https://stackoverflow.com/questions/41990346/change-tag-value-in-influxdb) etc. Basically with Influx, you need to have a perfect schema + data format from the start. – Dan Dascalescu Jan 13 '18 at 07:45

2 Answers2

7

Q: How can the field values of points matching a query be updated? Is this still not easily doable as of v1.4?

A: From the best of my knowledge, there isn't an easy way to accomplish update in version 1.4 yet.

Field value of a point can only be updated by overriding. That is, to overwrite its value you'll need to know the details of your points. These details include its timestamp and series information, which is the measurement it reside and its corresponding tags.

Note: This "update" strategy can only be used for changing the field value but not tag value. To update a tag value you'll need to first DELETE the point data first and rewrite the entire point data with the updated tag and value.

Q: Anything better than driving it all from the client by updating individual points?

A: Influxdb supports multi-point write. So if you can build a filter to pre-select a small dataset of points, modify their field values and then override them in bulk.

Samuel Toh
  • 18,006
  • 3
  • 24
  • 39
1

Update is possible and would take the format:

INSERT measurement,tag_name=tag_value_no_quotes value_key_1=value_value_1,value_key_2=value_value_2 time

for example where I want to update the line with tag my_box at time 1526988768877018669 on the box measurement:

INSERT box,box_name=my_box item_1='apple',item_2='melon' 1526988768877018669

NZHammer
  • 177
  • 1
  • 12
  • Isn't this [updating an individual point form the client](https://docs.influxdata.com/influxdb/v1.6/troubleshooting/frequently-asked-questions/#how-does-influxdb-handle-duplicate-points)? As I had specified in the question, I'm looking for updating multiple field values rather than individual points one by one. Anyway, I've updated the question to make that even clearer. – Dan Dascalescu Aug 06 '18 at 19:46