Two field with the same name causing errors

I have some JSON data that I’m pouring into an influxdb. A lot of different IoT devices are generating this, so I have no control over what this is. So numbers are generally floats, and string are generally strings. Once in a while, a new device sends a string where other devices have hitherto only sent numbers, causing an error, and I have to delete all data and start over, this time with that variable as a string and not a float.

However, now something else entirely has happened: I now have two fields with the same name(!)

The command “show field keys” gives me

id float
id string

What to do now?

It sounds like you need to take a look at how your schema is being created. If you’re using a JSON plugin, there could be an issue with how it’s assigning the data.

This should be caused by data type discrepancy between shards, meaning that shard has the filed “id” as float, meanwhile, another shard has it as a string. (see the docs).

If you are using telegraf to send the data you might solve the data type issue with the “converter” plugin in the processor section, which allow you to change/force datatype.

Sadly I don’t know how you can fix the current discrepancy.

1 Like