diff --git a/CHANGELOG.md b/CHANGELOG.md index 762309ae5..538cb8a76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ to "stdout". - [#1233](https://github.com/influxdata/telegraf/pull/1233): Updated golint gopsutil dependency. - [#1238](https://github.com/influxdata/telegraf/pull/1238): chrony input plugin. Thanks @zbindenren! - [#479](https://github.com/influxdata/telegraf/issues/479): per-plugin execution time added to debug output. +- [#1249](https://github.com/influxdata/telegraf/issues/1249): influxdb output: added write_consistency argument. ### Bugfixes diff --git a/etc/telegraf.conf b/etc/telegraf.conf index 1618ef63c..a95b79baa 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -75,12 +75,15 @@ urls = ["http://localhost:8086"] # required ## The target database for metrics (telegraf will create it if not exists). database = "telegraf" # required - ## Retention policy to write to. - retention_policy = "default" ## Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h". ## note: using "s" precision greatly improves InfluxDB compression. precision = "s" + ## Retention policy to write to. + retention_policy = "default" + ## Write consistency (clusters only), can be: "any", "one", "quorom", "all" + write_consistency = "any" + ## Write timeout (for the InfluxDB client), formatted as a string. ## If not provided, will default to 5s. 0s means no timeout (not recommended). timeout = "5s" diff --git a/plugins/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go index 891c752bd..f359b8fab 100644 --- a/plugins/outputs/influxdb/influxdb.go +++ b/plugins/outputs/influxdb/influxdb.go @@ -18,16 +18,17 @@ import ( type InfluxDB struct { // URL is only for backwards compatability - URL string - URLs []string `toml:"urls"` - Username string - Password string - Database string - UserAgent string - Precision string - RetentionPolicy string - Timeout internal.Duration - UDPPayload int `toml:"udp_payload"` + URL string + URLs []string `toml:"urls"` + Username string + Password string + Database string + UserAgent string + Precision string + RetentionPolicy string + WriteConsistency string + Timeout internal.Duration + UDPPayload int `toml:"udp_payload"` // Path to CA file SSLCA string `toml:"ssl_ca"` @@ -49,12 +50,15 @@ var sampleConfig = ` urls = ["http://localhost:8086"] # required ## The target database for metrics (telegraf will create it if not exists). database = "telegraf" # required - ## Retention policy to write to. - retention_policy = "default" ## Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h". ## note: using "s" precision greatly improves InfluxDB compression. precision = "s" + ## Retention policy to write to. + retention_policy = "default" + ## Write consistency (clusters only), can be: "any", "one", "quorom", "all" + write_consistency = "any" + ## Write timeout (for the InfluxDB client), formatted as a string. ## If not provided, will default to 5s. 0s means no timeout (not recommended). timeout = "5s" @@ -179,9 +183,10 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error { } } bp, err := client.NewBatchPoints(client.BatchPointsConfig{ - Database: i.Database, - Precision: i.Precision, - RetentionPolicy: i.RetentionPolicy, + Database: i.Database, + Precision: i.Precision, + RetentionPolicy: i.RetentionPolicy, + WriteConsistency: i.WriteConsistency, }) if err != nil { return err