Telegraf alt_baro datatype conversion #144
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The alt_baro readsb metric produces either a numeric value or the string "ground".
Prometheus doesn't support strings as metrics and will ignore strings. Therefore, there is no problem with Prometheus having a forced data type.
In the case of InfluxDB 2, the first value of the key submitted will define the data type of that field. When "ground" is the first value, Influx will only populate the field when the value is "ground" and fire an error that Influx couldn't convert float to string. This will cause no altitude metrics to be collected.
To keep InfluxDB metrics in line with Prometheus, the data type must be forced as a float.
This does not affect Prometheus since it's dumping strings anyway, and it brings Influx data on par with the Prometheus data.
Further work needs to be done to collect the "ground" value to retain the data, but this will fix the issue of starting a new bucket and not gathering altitude metrics.