diff --git a/CHANGELOG.md b/CHANGELOG.md index fa1412dbc..68100b381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#71](https://github.com/influxdb/telegraf/pull/71): HAProxy plugin. Thanks @kureikain! - [#72](https://github.com/influxdb/telegraf/pull/72): Adding TokuDB metrics to MySQL. Thanks vadimtk! - [#73](https://github.com/influxdb/telegraf/pull/73): RabbitMQ plugin. Thanks @ianunruh! +- [#77](https://github.com/influxdb/telegraf/issues/77): Automatically create database. - [#79](https://github.com/influxdb/telegraf/pull/56): Nginx plugin. Thanks @codeb2cc! - [#86](https://github.com/influxdb/telegraf/pull/86): Lustre2 plugin. Thanks srfraser! - [#91](https://github.com/influxdb/telegraf/pull/91): Unit testing diff --git a/agent.go b/agent.go index a84dbdd3b..e9ea7e30a 100644 --- a/agent.go +++ b/agent.go @@ -3,8 +3,10 @@ package telegraf import ( "fmt" "log" + "net/url" "os" "sort" + "strings" "sync" "time" @@ -57,9 +59,16 @@ func NewAgent(config *Config) (*Agent, error) { agent.Hostname = hostname } + if config.Tags == nil { + config.Tags = map[string]string{} + } + + config.Tags["host"] = agent.Hostname + return agent, nil } +// Connect connects to the agent's config URL func (a *Agent) Connect() error { for _, o := range a.outputs { err := o.output.Connect(a.Hostname) @@ -194,7 +203,9 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err return err } + acc.Tags = a.Config.Tags acc.Time = time.Now() + acc.Database = a.Config.Database err = a.flush(&acc) if err != nil {