E! [outputs.influxdb] Failed to write metric (will be dropped: 400 Bad Request)

Hello,

I’m having an error on influxdb logs

E! [outputs.influxdb] Failed to write metric (will be dropped: 400 Bad Request): partial write: field type conflict: input field “valueFloat” on measurement “datahandsome” is type float, already exists as type string dropped=1

The error looks pretty clear, so I wanted to see what where the metrics with such a string value (in my context, there should not be string).

SELECT * FROM datahandsome where “valueFloat”::string != “”
And influx CLI gives me no result.

Would you have any tips to help understanding ?
thanks

The issue is pretty straightforward, but not nice to fix.

InflxDB has datatypes (int, float, string) that are enforced at shard level.
When the shard receives data, the first data point that comes in defines the datatype, the fact that you are receiving mixed data types is an issue/error in the gathering process. as the opposite will also happen (refusing strings because the filed is a float).

Your current situation means that the actual shard is storing that field as a string, any value you find within the shard time boundaries is a string, a simple SELECT valueFloat FROM ___ WHERE time > now() - __ will show you the values.

The problem is already obvious, but you can check it by running SHOW FIELD KEYS, it will also return the datatype. (Docs here, especially this note)
It should be possible to have a report “by shard” using influx_inspect but honestly I’ve forgot which command gives you the report by shard (I’d try the dump commands).

About the solution…

  • enforce data types
  • if you must fix the current data, you will actually need to export-delete-import them. Since you can’t delete “by field” it’s going to be a time consuming operation.
  • if you can “skip” those data, just wait for the next shard creation and ensure it has the correct data type
1 Like