Outputs.elasticsearch: Error sending bulk request to Elasticsearch: json: unsupported value: NaN

getting error while sending data to elastic search
telegarf version 1.20.4
elastic version 7.17.5
please help me if you are experience similar issue

2022-09-15T03:46:30Z E! [agent] Error writing to outputs.elasticsearch: Error sending bulk request to Elasticsearch: json: unsupported value: NaN
2022-09-15T03:46:35Z E! [agent] Error writing to outputs.elasticsearch: Error sending bulk request to Elasticsearch: json: unsupported value: NaN
2022-09-15T03:46:45Z E! [agent] Error writing to outputs.elasticsearch: Error sending bulk request to Elasticsearch: json: unsupported value: NaN
2022-09-15T03:46:55Z E! [agent] Error writing to outputs.elasticsearch: Error sending bulk request to Elasticsearch: json: unsupported value: NaN

Hi,

I don’t believe JSON supports the “NaN” “inf” and/or “-inf” values. Depending on how you are getting these values, that would need to be replaced with “null” or something similar.

The elasticsearch output has a “float_handling” option that defaults to none. When set to “replace” it will use some pre-defined value to replace those types of values. When set to “drop” it will remove them.

You could possibly do this with a regex or starlark processors.