Write data in UTC by default and use 's' precision
Closes #159 Closes #162
This commit is contained in:
parent
13061d1ec7
commit
5bfb6df0e0
|
@ -1,9 +1,14 @@
|
|||
## v0.1.8 [unreleased]
|
||||
|
||||
### Release Notes
|
||||
Telegraf will now write data in UTC at second precision by default
|
||||
|
||||
### Features
|
||||
- [#150](https://github.com/influxdb/telegraf/pull/150): Add Host Uptime metric to system plugin
|
||||
- [#158](https://github.com/influxdb/telegraf/pull/158): Apache Plugin. Thanks @KPACHbIuLLIAnO4
|
||||
- [#159](https://github.com/influxdb/telegraf/pull/159): Use second precision for InfluxDB writes
|
||||
- [#165](https://github.com/influxdb/telegraf/pull/165): Add additional metrics to mysql plugin. Thanks @nickscript0
|
||||
- [#162](https://github.com/influxdb/telegraf/pull/162): Write UTC by default, provide option
|
||||
- [#166](https://github.com/influxdb/telegraf/pull/166): Upload binaries to S3
|
||||
|
||||
### Bugfixes
|
||||
|
|
31
agent.go
31
agent.go
|
@ -31,7 +31,14 @@ type Agent struct {
|
|||
// Interval at which to gather information
|
||||
Interval Duration
|
||||
|
||||
// Run in debug mode?
|
||||
// Option for outputting data in UTC
|
||||
UTC bool `toml:"utc"`
|
||||
|
||||
// Precision to write data at
|
||||
// Valid values for Precision are n, u, ms, s, m, and h
|
||||
Precision string
|
||||
|
||||
// Option for running in debug mode
|
||||
Debug bool
|
||||
Hostname string
|
||||
|
||||
|
@ -43,8 +50,14 @@ type Agent struct {
|
|||
|
||||
// NewAgent returns an Agent struct based off the given Config
|
||||
func NewAgent(config *Config) (*Agent, error) {
|
||||
agent := &Agent{Config: config, Interval: Duration{10 * time.Second}}
|
||||
agent := &Agent{
|
||||
Config: config,
|
||||
Interval: Duration{10 * time.Second},
|
||||
UTC: true,
|
||||
Precision: "s",
|
||||
}
|
||||
|
||||
// Apply the toml table to the agent config, overriding defaults
|
||||
err := config.ApplyAgent(agent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -199,7 +212,11 @@ func (a *Agent) crankParallel() error {
|
|||
|
||||
var bp BatchPoints
|
||||
bp.Time = time.Now()
|
||||
if a.UTC {
|
||||
bp.Time = bp.Time.UTC()
|
||||
}
|
||||
bp.Tags = a.Config.Tags
|
||||
bp.Precision = a.Precision
|
||||
|
||||
for sub := range points {
|
||||
bp.Points = append(bp.Points, sub.Points...)
|
||||
|
@ -223,8 +240,12 @@ func (a *Agent) crank() error {
|
|||
}
|
||||
}
|
||||
|
||||
bp.Time = time.Now()
|
||||
bp.Tags = a.Config.Tags
|
||||
bp.Time = time.Now()
|
||||
if a.UTC {
|
||||
bp.Time = bp.Time.UTC()
|
||||
}
|
||||
bp.Precision = a.Precision
|
||||
|
||||
return a.flush(&bp)
|
||||
}
|
||||
|
@ -250,6 +271,10 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err
|
|||
|
||||
bp.Tags = a.Config.Tags
|
||||
bp.Time = time.Now()
|
||||
if a.UTC {
|
||||
bp.Time = bp.Time.UTC()
|
||||
}
|
||||
bp.Precision = a.Precision
|
||||
|
||||
if err := a.flush(&bp); err != nil {
|
||||
outerr = errors.New("Error encountered processing plugins & outputs")
|
||||
|
|
|
@ -126,8 +126,9 @@ func main() {
|
|||
log.Printf("Loaded plugins: %s", strings.Join(plugins, " "))
|
||||
if ag.Debug {
|
||||
log.Printf("Debug: enabled")
|
||||
log.Printf("Agent Config: Interval:%s, Debug:%#v, Hostname:%#v\n",
|
||||
ag.Interval, ag.Debug, ag.Hostname)
|
||||
log.Printf("Agent Config: Interval:%s, Debug:%#v, Hostname:%#v, "+
|
||||
"Precision:%#v, UTC: %#v\n",
|
||||
ag.Interval, ag.Debug, ag.Hostname, ag.Precision, ag.UTC)
|
||||
}
|
||||
log.Printf("Tags enabled: %s", config.ListTags())
|
||||
|
||||
|
|
27
config.go
27
config.go
|
@ -131,10 +131,11 @@ func (c *Config) ApplyOutput(name string, v interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ApplyAgent loads the toml config into the given interface
|
||||
func (c *Config) ApplyAgent(v interface{}) error {
|
||||
// ApplyAgent loads the toml config into the given Agent object, overriding
|
||||
// defaults (such as collection duration) with the values from the toml config.
|
||||
func (c *Config) ApplyAgent(a *Agent) error {
|
||||
if c.agent != nil {
|
||||
return toml.UnmarshalTable(c.agent, v)
|
||||
return toml.UnmarshalTable(c.agent, a)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -350,11 +351,23 @@ var header = `# Telegraf configuration
|
|||
[tags]
|
||||
# dc = "us-east-1"
|
||||
|
||||
# Configuration for telegraf itself
|
||||
# Configuration for telegraf agent
|
||||
[agent]
|
||||
# interval = "10s"
|
||||
# debug = false
|
||||
# hostname = "prod3241"
|
||||
# Default data collection interval for all plugins
|
||||
interval = "10s"
|
||||
|
||||
# If utc = false, uses local time (utc is highly recommended)
|
||||
utc = true
|
||||
|
||||
# Precision of writes, valid values are n, u, ms, s, m, and h
|
||||
# note: using second precision greatly helps InfluxDB compression
|
||||
precision = "s"
|
||||
|
||||
# run telegraf in debug mode
|
||||
debug = false
|
||||
|
||||
# Override default hostname, if empty use os.Hostname()
|
||||
hostname = ""
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
|
Loading…
Reference in New Issue