Support specifying influxdb retention policy

closes #692
This commit is contained in:
Cameron Sparr
2016-02-29 16:13:00 +00:00
parent 43b7ce4f6d
commit 3568fb9f93
3 changed files with 35 additions and 21 deletions

View File

@@ -18,15 +18,16 @@ 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
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
Timeout internal.Duration
UDPPayload int `toml:"udp_payload"`
// Path to CA file
SSLCA string `toml:"ssl_ca"`
@@ -46,10 +47,12 @@ var sampleConfig = `
## this means that only ONE of the urls will be written to each interval.
# urls = ["udp://localhost:8089"] # UDP endpoint example
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
## 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
## note: using "s" precision greatly improves InfluxDB compression.
precision = "s"
## Write timeout (for the InfluxDB client), formatted as a string.
@@ -164,8 +167,9 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
}
}
bp, err := client.NewBatchPoints(client.BatchPointsConfig{
Database: i.Database,
Precision: i.Precision,
Database: i.Database,
Precision: i.Precision,
RetentionPolicy: i.RetentionPolicy,
})
if err != nil {
return err