Skip to content

Commit

Permalink
Support specifying influxdb retention policy
Browse files Browse the repository at this point in the history
closes #692
  • Loading branch information
sparrc committed Feb 29, 2016
1 parent 43b7ce4 commit 3568fb9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Release Notes

### Features
- [#692](https://github.com/influxdata/telegraf/pull/770): Support InfluxDB retention policies

### Bugfixes
- [#748](https://github.com/influxdata/telegraf/issues/748): Fix sensor plugin split on ":"
Expand Down
25 changes: 17 additions & 8 deletions etc/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,36 @@

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
# The full HTTP or UDP endpoint URL for your InfluxDB instance.
# Multiple urls can be specified but it is assumed that they are part of the same
# cluster, this means that only ONE of the urls will be written to each interval.
## The full HTTP or UDP endpoint URL for your InfluxDB instance.
## Multiple urls can be specified as part of the same cluster,
## 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
# Precision of writes, valid values are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# note: using second precision greatly helps InfluxDB compression
## 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"

## 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"
# username = "telegraf"
# password = "metricsmetricsmetricsmetrics"
# Set the user agent for HTTP POSTs (can be useful for log differentiation)
## Set the user agent for HTTP POSTs (can be useful for log differentiation)
# user_agent = "telegraf"
# Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
## Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
# udp_payload = 512

## Optional SSL Config
# ssl_ca = "/etc/telegraf/ca.pem"
# ssl_cert = "/etc/telegraf/cert.pem"
# ssl_key = "/etc/telegraf/key.pem"
## Use SSL but skip chain & host verification
# insecure_skip_verify = false


###############################################################################
# INPUTS #
Expand Down
30 changes: 17 additions & 13 deletions plugins/outputs/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3568fb9

Please sign in to comment.