Migration between databases and lost tags values

Hello,

I need to transfer some data from one database (named “hosting” in my POC) to a new one (named “transfert” in my POC) on the same server.

Then I ran this command : SELECT * INTO transfert..cpu FROM hosting..cpu.

After that I requested for data with my hostname for key “host” and I had a response for each database (all is right) : select * from cpu where host = 'poc-ubu-2203' LIMIT 1.

But when I request a SHOW TAG VALUES FROM "cpu" WITH key = "host" I only have the tags on the source database (hosting).
It is like the tags were not replicated, even if we can filter with WHERE statement on tags in a SELECT command.

I faced this issue on InfluxDB version 1.8.1 and 1.8.10.
My dashboards on Grafana cannot work if I don’t have these tags.

Can someone help me to understaind what happens and how to solve it ?

Here you can find the full test output :

InfluxDB shell version: 1.8.10
> SELECT * INTO transfert..cpu FROM hosting..cpu
name: result
time written
---- -------
0    30942
> use hosting
Using database hosting
> select * from cpu where host = 'poc-ubu-2204' LIMIT 1
name: cpu
time                cpu       host         usage_guest usage_guest_nice usage_idle        usage_iowait usage_irq usage_nice usage_softirq     usage_steal usage_system       usage_user
----                ---       ----         ----------- ---------------- ----------        ------------ --------- ---------- -------------     ----------- ------------       ----------
1701101010000000000 cpu-total poc-ubu-2204 0           0                99.29328621908412 0            0         0          0.050479555779914 0           0.4543160020193963 0.20191822311976357
> SHOW TAG VALUES FROM "cpu" WITH key = "host"
name: cpu
key  value
---  -----
host poc-ubu-2204
>
>
>
> use transfert
Using database transfert
> select * from cpu where host = 'poc-ubu-2204' LIMIT 1
name: cpu
time                cpu  host         usage_guest usage_guest_nice usage_idle        usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system       usage_user
----                ---  ----         ----------- ---------------- ----------        ------------ --------- ---------- ------------- ----------- ------------       ----------
1701101010000000000 cpu1 poc-ubu-2204 0           0                99.69696969698144 0            0         0          0             0           0.2020202020200257 0.1010101010101564
> SHOW TAG VALUES FROM "cpu" WITH key = "host"
>
>

FYI. Last line requested on hosting and transfert databases is not the same because hosting database continues to recieve data from Telegaf.

Thank you for your help, best regards.

If writing data back to InfluxDB, you have to group by your tags to keep them as tags. Otherwise, they are written as fields. This behavior is described in the InfluxQL documentation.

SELECT * INTO transfert..cpu FROM hosting..cpu GROUP BY *

Hello,

Thank you for your answer :grinning:.
Indeed it’s written in the documentation :pensive: Sorry for my oversight.

Best regards,

No worries. Happy to help!