diff --git a/plugins/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go index 2e6e0d9c6728a..d0c1257fd2773 100644 --- a/plugins/outputs/influxdb/influxdb.go +++ b/plugins/outputs/influxdb/influxdb.go @@ -45,6 +45,7 @@ type InfluxDB struct { HTTPHeaders map[string]string `toml:"http_headers"` ContentEncoding string `toml:"content_encoding"` SkipDatabaseCreation bool `toml:"skip_database_creation"` + InfluxUintSupport bool `toml:"influx_uint_support"` // Path to CA file SSLCA string `toml:"ssl_ca"` @@ -119,6 +120,12 @@ var sampleConfig = ` ## HTTP Content-Encoding for write request body, can be set to "gzip" to ## compress body or "identity" to apply no encoding. # content_encoding = "identity" + + ## When true, Telegraf will output unsigned integers as unsigned values, + ## i.e.: "42u". You will need a version of InfluxDB supporting unsigned + ## integer values. Enabling this option will result in field type errors if + ## existing data has been written. + # influx_uint_support = false ` func (i *InfluxDB) Connect() error { @@ -134,7 +141,13 @@ func (i *InfluxDB) Connect() error { urls = append(urls, defaultURL) } + var typeSupport influx.FieldTypeSupport + if i.InfluxUintSupport { + typeSupport = typeSupport + influx.UintSupport + } + i.serializer = influx.NewSerializer() + i.serializer.SetFieldTypeSupport(typeSupport) for _, u := range urls { u, err := url.Parse(u)