Copy data with SELECT INTO and current time

Hello all,

i searched hard for the last few days for a solution to my problem. I have a time series which very seldom writes new entries to the db. But my application (grafana) expects a lot more often updated values. So i want to copy the latest values of my db to a new database with a script which runs periodically. This is working fine the only issue is, that also the timestamp is copied. But what i need is, that the timestamp is dropped and the current time is used. For this i want to use CLI. I am currently running this command:

SELECT time, floor, room, itemtype, item, value INTO "test_db"."autogen".:MEASUREMENT FROM "orig_db"."autogen"./.*/ GROUP BY * ORDER BY DESC LIMIT 1

Is there any possibility to enter the values and tags with passing the current time stamp and not the one of the orig_db?

Thx in advance,
Patrick

You might be able to simply write the point without using copy. When Influx encounters duplicate points, it does an override and replaces the timestamp. Would something like that work for you? I don’t know if this helps with your Grafana issue

Hey @katy,

sorry for the late reply, have been very busy with different things. It is in fact not the same duplicate point but i want to fill gaps between the last timepoint and now (so that grafana is able to display it properly). So i want to include the last measurement again with the current timepoint.

In the meantime i have decided to go with a python script which reads the data modifies the timestamp and writes them back into influxdb. This is run as a service periodically every minute. With this i was able to achieve a solution to my problem.

Thanks for replying back.

1 Like