resolve all merge issues, move Tags back to Config

This commit is contained in:
JP 2015-08-11 21:08:47 -05:00
parent c5c701d178
commit 75b6ec6469
7 changed files with 39 additions and 22 deletions

View File

@ -19,6 +19,7 @@
- [#85](https://github.com/influxdb/telegraf/pull/85): Fix GetLocalHost testutil function for mac users
- [#89](https://github.com/influxdb/telegraf/pull/89): go fmt fixes
- [#94](https://github.com/influxdb/telegraf/pull/94): Fix for issue #93, explicitly call sarama.v1 -> sarama
- [#101](https://github.com/influxdb/telegraf/issues/101): switch back from master branch if building locally
## v0.1.4 [2015-07-09]

View File

@ -3,7 +3,6 @@ package telegraf
import (
"fmt"
"log"
"net/url"
"os"
"sort"
"strings"
@ -79,6 +78,7 @@ func (a *Agent) Connect() error {
return nil
}
// LoadOutputs loads the agent's outputs
func (a *Agent) LoadOutputs() ([]string, error) {
var names []string
@ -188,7 +188,7 @@ func (a *Agent) crankParallel() error {
bp.Points = append(bp.Points, sub.Points...)
}
return a.flush(bp)
return a.flush(&bp)
}
func (a *Agent) crank() error {
@ -208,7 +208,7 @@ func (a *Agent) crank() error {
bp.Time = time.Now()
bp.Tags = a.Config.Tags
return a.flush(bp)
return a.flush(&bp)
}
func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) error {
@ -229,7 +229,7 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err
bp.Tags = a.Config.Tags
bp.Time = time.Now()
err = a.flush(acc)
err = a.flush(&bp)
if err != nil {
return err
}
@ -243,14 +243,14 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err
}
}
func (a *Agent) flush(bp BatchPoints) error {
func (a *Agent) flush(bp *BatchPoints) error {
var wg sync.WaitGroup
var outerr error
for _, o := range a.outputs {
wg.Add(1)
go func(output *runningOutput) {
go func(ro *runningOutput) {
defer wg.Done()
outerr = o.output.Write(bp.BatchPoints)
outerr = ro.output.Write(bp.BatchPoints)
}(o)
}

View File

@ -9,6 +9,7 @@ import (
"strings"
"github.com/influxdb/telegraf"
_ "github.com/influxdb/telegraf/outputs/all"
_ "github.com/influxdb/telegraf/plugins/all"
)
@ -21,16 +22,13 @@ var fPidfile = flag.String("pidfile", "", "file to write our pid to")
var fPLuginsFilter = flag.String("filter", "", "filter the plugins to enable, separator is :")
// Telegraf version
var Version = "unreleased"
// Telegraf commit
var Commit = ""
var Version = "0.1.5-dev"
func main() {
flag.Parse()
if *fVersion {
fmt.Printf("InfluxDB Telegraf agent - Version %s\n", Version)
fmt.Printf("Telegraf - Version %s\n", Version)
return
}
@ -62,6 +60,15 @@ func main() {
ag.Debug = true
}
outputs, err := ag.LoadOutputs()
if err != nil {
log.Fatal(err)
}
if len(outputs) == 0 {
log.Printf("Error: no outputs found, did you provide a config file?")
os.Exit(1)
}
plugins, err := ag.LoadPlugins(*fPLuginsFilter)
if err != nil {
log.Fatal(err)
@ -105,7 +112,7 @@ func main() {
close(shutdown)
}()
log.Print("Telegraf Agent running")
log.Printf("Starting Telegraf (version %s)\n", Version)
log.Printf("Loaded outputs: %s", strings.Join(outputs, " "))
log.Printf("Loaded plugins: %s", strings.Join(plugins, " "))
if ag.Debug {
@ -114,6 +121,8 @@ func main() {
ag.Interval, ag.Debug, ag.Hostname)
}
log.Printf("Tags enabled: %v", config.ListTags())
if *fPidfile != "" {
f, err := os.Create(*fPidfile)
if err != nil {

View File

@ -30,9 +30,8 @@ func (d *Duration) UnmarshalTOML(b []byte) error {
return nil
}
// Config specifies the URL/user/password for the database that telegraf
// will be logging to, as well as all the plugins that the user has
// specified
// Config specifies the outputs that telegraf will be logging to,
// as well as all the plugins that the user has specified
type Config struct {
Tags map[string]string
@ -51,6 +50,7 @@ func (c *Config) Outputs() map[string]*ast.Table {
return c.outputs
}
// The name of a tag, and the values on which to filter
type TagFilter struct {
Name string
Filter []string
@ -243,7 +243,7 @@ func (c *Config) OutputsDeclared() []string {
func declared(endpoints map[string]*ast.Table) []string {
var names []string
for name, _ := range endpoints {
for name := range endpoints {
names = append(names, name)
}

View File

@ -39,7 +39,8 @@ database = "telegraf" # required.
# Set the user agent for the POSTs (can be useful for log differentiation)
# user_agent = "telegraf"
# tags = { "dc" = "us-east-1" }
[tags]
dc = "us-east-1"
# Configuration for telegraf itself
# [agent]

View File

@ -1,9 +1,13 @@
package influxdb
import (
"fmt"
"log"
"net/url"
"strings"
"github.com/influxdb/influxdb/client"
t "github.com/influxdb/telegraf"
"github.com/influxdb/telegraf/outputs"
)
@ -13,7 +17,7 @@ type InfluxDB struct {
Password string
Database string
UserAgent string
Timeout Duration
Timeout t.Duration
conn *client.Client
}
@ -50,7 +54,6 @@ func (i *InfluxDB) Connect() error {
func (i *InfluxDB) Write(bp client.BatchPoints) error {
bp.Database = i.Database
bp.Tags = i.Tags
if _, err := i.conn.Write(bp); err != nil {
return err
}

View File

@ -3,12 +3,15 @@ interval = "5s"
http = ":11213"
debug = true
[influxdb]
[outputs]
[outputs.influxdb]
url = "http://localhost:8086"
username = "root"
password = "root"
database = "telegraf"
tags = { dc = "us-phx-1" }
[tags]
dc = "us-phx-1"
[redis]
address = ":6379"