Changing a measurement in a working db

I have just got some of my environmental data loading into Influxdb and onto Grafana when playing with the visualisations I realised that I had coded one I didn’t want.
The setup is sensors>python>Influxdb>Grafana.
My question is, how can I edit one of the database’s measurement details so that I can keep the database name, I am not worried about loosing the data collected so far, if that makes it easier.
I have altered my python code but the ‘new’ measurement name is not being presented in Grafana so I guess it is embedded in the structure.
I plan to add more sensors and so this is something I will probably have do several times as I build the project.

Hello @peterb,
So the official way is to

  1. Find all tags in your measurement using SHOW TAG KEYS FROM MyMeasurement . Let’s assume your tags were tag1 and tag2
  2. Copy all data into a new measurement using SELECT * INTO MyMeasurementCopy from MyMeasurement GROUP BY tag1,tag2
  3. Once you are 100% sure all data is copied, you can drop the old data using DROP MEASUREMENT MyMeasurement
    But you also might be interested in which was contributed to by community.
1 Like

Thanks Anaisdg,
I found that having changed my python code to record the correct sensor by over-writing the code for the incorrect one, the wrong one stopped being recorded but the correct one begun. Sort of what I wanted.
Now I can use your drop measurement My Measurement line, to delete the unwanted data, thanks for that !
All plotting nicely now in Grafana!

1 Like

@peterb, yay! I’m happy to hear I could help.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.