Add influx uint support as a runtime option (#3948)
This commit is contained in:
@@ -59,4 +59,10 @@ This InfluxDB output plugin writes metrics to the [InfluxDB](https://github.com/
|
||||
## 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
|
||||
```
|
||||
|
||||
@@ -102,7 +102,8 @@ type HTTPConfig struct {
|
||||
RetentionPolicy string
|
||||
Consistency string
|
||||
|
||||
Serializer *influx.Serializer
|
||||
InfluxUintSupport bool `toml:"influx_uint_support"`
|
||||
Serializer *influx.Serializer
|
||||
}
|
||||
|
||||
type httpClient struct {
|
||||
|
||||
@@ -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 {
|
||||
@@ -135,6 +142,9 @@ func (i *InfluxDB) Connect() error {
|
||||
}
|
||||
|
||||
i.serializer = influx.NewSerializer()
|
||||
if i.InfluxUintSupport {
|
||||
i.serializer.SetFieldTypeSupport(influx.UintSupport)
|
||||
}
|
||||
|
||||
for _, u := range urls {
|
||||
u, err := url.Parse(u)
|
||||
|
||||
Reference in New Issue
Block a user