influxdb output: write consistency parameter

closes #1249
This commit is contained in:
Cameron Sparr 2016-05-24 10:08:34 +01:00
parent 52d5b19219
commit 204ebf6bf6
3 changed files with 26 additions and 17 deletions

View File

@ -18,6 +18,7 @@ to "stdout".
- [#1233](https://github.com/influxdata/telegraf/pull/1233): Updated golint gopsutil dependency. - [#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! - [#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. - [#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 ### Bugfixes

View File

@ -75,12 +75,15 @@
urls = ["http://localhost:8086"] # required urls = ["http://localhost:8086"] # required
## The target database for metrics (telegraf will create it if not exists). ## The target database for metrics (telegraf will create it if not exists).
database = "telegraf" # required 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". ## Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h".
## note: using "s" precision greatly improves InfluxDB compression. ## note: using "s" precision greatly improves InfluxDB compression.
precision = "s" 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. ## Write timeout (for the InfluxDB client), formatted as a string.
## If not provided, will default to 5s. 0s means no timeout (not recommended). ## If not provided, will default to 5s. 0s means no timeout (not recommended).
timeout = "5s" timeout = "5s"

View File

@ -18,16 +18,17 @@ import (
type InfluxDB struct { type InfluxDB struct {
// URL is only for backwards compatability // URL is only for backwards compatability
URL string URL string
URLs []string `toml:"urls"` URLs []string `toml:"urls"`
Username string Username string
Password string Password string
Database string Database string
UserAgent string UserAgent string
Precision string Precision string
RetentionPolicy string RetentionPolicy string
Timeout internal.Duration WriteConsistency string
UDPPayload int `toml:"udp_payload"` Timeout internal.Duration
UDPPayload int `toml:"udp_payload"`
// Path to CA file // Path to CA file
SSLCA string `toml:"ssl_ca"` SSLCA string `toml:"ssl_ca"`
@ -49,12 +50,15 @@ var sampleConfig = `
urls = ["http://localhost:8086"] # required urls = ["http://localhost:8086"] # required
## The target database for metrics (telegraf will create it if not exists). ## The target database for metrics (telegraf will create it if not exists).
database = "telegraf" # required 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". ## Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h".
## note: using "s" precision greatly improves InfluxDB compression. ## note: using "s" precision greatly improves InfluxDB compression.
precision = "s" 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. ## Write timeout (for the InfluxDB client), formatted as a string.
## If not provided, will default to 5s. 0s means no timeout (not recommended). ## If not provided, will default to 5s. 0s means no timeout (not recommended).
timeout = "5s" timeout = "5s"
@ -179,9 +183,10 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
} }
} }
bp, err := client.NewBatchPoints(client.BatchPointsConfig{ bp, err := client.NewBatchPoints(client.BatchPointsConfig{
Database: i.Database, Database: i.Database,
Precision: i.Precision, Precision: i.Precision,
RetentionPolicy: i.RetentionPolicy, RetentionPolicy: i.RetentionPolicy,
WriteConsistency: i.WriteConsistency,
}) })
if err != nil { if err != nil {
return err return err