fangli / fluent-plugin-influxdb

A buffered output plugin for fluentd and InfluxDB
MIT License
111 stars 65 forks source link

accept integer for float field #92

Closed ash0080 closed 5 years ago

ash0080 commented 6 years ago

Now, insert an integer to a float field will throw an "already exists as type float" error

because there isn't precision float in Javascript, e.x: 1.0, 2.0... 10.0 all will be converted to integer automatically. And as described in the 3032, now all numbers in influxdb are float, so could this be fixed? Or could add an auto parse func from String?

repeatedly commented 6 years ago

How about using record_transformer filter to convert number type?

<filter test.**>
  @type record_transformer
  enable_ruby true
  <record>
    foo ${record["foo"].to_f}
  </record>
</filter>
ash0080 commented 6 years ago

Sure, that's what I did. but It's better to run it without any tricky operations. at least fitting the influxdb‘s protocol. so why not transform all number to float?

Coac commented 5 years ago

I am having the same issue as @ash0080 The record transformer solution is nice when you have one field with that problem, but when you have dozens, and when you want to add later another key, you need to edit the fluent conf... It's a good idea to make it float by default

Coac commented 5 years ago

I added a PR for that https://github.com/fangli/fluent-plugin-influxdb/pull/95

Coac commented 5 years ago

You can close the issue since it is fixed, the PR got merged :+1: