I’m fairly new to InfluxDB (have version 1.5.1). I use it with Grafana and Icinga2. I’m confused for managing the data, specifically deletion. I have entries “in the future” because my server time got offset and ended up writing data to the database during this period. So, after setting the time back to normal, I tried to execute the following command:
delete from grafana where time > now(), where grafana is the name of my database
The command runs without error, but when I query the HTTP API with the following command, I still see “future” entries:
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=grafana" --data-urlencode "q=SELECT \"value\" FROM \"SOMECHECK\" WHERE \"hostname\"='SOMEHOSTNAME'"
I tried to edit the delete statement to:
delete from grafana where time > '2018-04-10T14:27:00Z
delete from grafana where time < now() + 24h (saw this in some old thread)
delete from SOMECHECK where time > now()
… but none of the above seemed to do anything.
Perhaps I have the delete functionality completely incorrect? Anyone have some insight?
Thanks in advance!
P.S.
I contacted InfluxDB support and they told me that the worst case scenario was to drop the database and restart. Preferably I wouldn’t like to do this.
Also, I checked these threads (1st thread, 2nd thread) that seemed to have a similar issue to mine but they don’t seem to help too much.
I suspect (but have not tested) that you need to specify both a start time and an end time in your DELETE statement. For example,
DELETE FROM grafana WHERE time>'2017-04-10T14:27:00Z' AND time<'2019-01-01T00:00:00Z'
It’s also possible that you need to specify some tags in the DELETE for it to work properly.
Note that when I reported a similar problem the situation was slightly different. In my case the server time was correct, but the uploaded measurement data had future timestamps. If I read your query correctly, the server time was wrong, which would lead to timestamps on the database files (shards) being wrong also, but I don’t know if that would affect how InfluxDB manages its data.
@JeremySTX,
I tried your command and it didn’t seem to work. I also tried to specify tags like you say:
> delete from grafana where "hostname" = 'MYHOST' AND time > '2018-04-11T10:30:00Z'
which didn’t work. I realize that your problem was slightly different, but is in the scope of what I’m trying to do. Do you think I might have to delete the conflicting shard? I can see that these shards have weekly retention when I do show shards.
@flopp,
I tried restarting the influxdb service after trying the delete commands, but that didn’t work either.
By the way, I noticed that these “future” entries are not even showing up in my Grafana graphs. I guess I’m just worried about the trouble in having the future entries might make later on.