update config sample, marshal tags from toml
This commit is contained in:
parent
2601a09a83
commit
48c10f9454
|
@ -30,7 +30,7 @@ func (d *Duration) UnmarshalTOML(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config specifies the URL/user/password for the database that telegraf
|
// Config specifies the outputs that telegraf
|
||||||
// will be logging to, as well as all the plugins that the user has
|
// will be logging to, as well as all the plugins that the user has
|
||||||
// specified
|
// specified
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -200,6 +200,7 @@ func LoadConfig(path string) (*Config, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &Config{
|
c := &Config{
|
||||||
|
Tags: make(map[string]string),
|
||||||
plugins: make(map[string]*ast.Table),
|
plugins: make(map[string]*ast.Table),
|
||||||
outputs: make(map[string]*ast.Table),
|
outputs: make(map[string]*ast.Table),
|
||||||
}
|
}
|
||||||
|
@ -213,6 +214,10 @@ func LoadConfig(path string) (*Config, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case "agent":
|
case "agent":
|
||||||
c.agent = subtbl
|
c.agent = subtbl
|
||||||
|
case "tags":
|
||||||
|
if err := toml.UnmarshalTable(subtbl, c.Tags); err != nil {
|
||||||
|
return nil, errInvalidConfig
|
||||||
|
}
|
||||||
case "outputs":
|
case "outputs":
|
||||||
for outputName, outputVal := range subtbl.Fields {
|
for outputName, outputVal := range subtbl.Fields {
|
||||||
outputSubtbl, ok := outputVal.(*ast.Table)
|
outputSubtbl, ok := outputVal.(*ast.Table)
|
||||||
|
|
|
@ -22,8 +22,11 @@
|
||||||
# NOTE: The configuration has a few required parameters. They are marked
|
# NOTE: The configuration has a few required parameters. They are marked
|
||||||
# with 'required'. Be sure to edit those to make this configuration work.
|
# with 'required'. Be sure to edit those to make this configuration work.
|
||||||
|
|
||||||
|
# OUTPUTS
|
||||||
|
[outputs]
|
||||||
|
|
||||||
# Configuration for influxdb server to send metrics to
|
# Configuration for influxdb server to send metrics to
|
||||||
[influxdb]
|
[outputs.influxdb]
|
||||||
# The full HTTP endpoint URL for your InfluxDB instance
|
# The full HTTP endpoint URL for your InfluxDB instance
|
||||||
url = "http://localhost:8086" # required.
|
url = "http://localhost:8086" # required.
|
||||||
|
|
||||||
|
@ -35,11 +38,9 @@ database = "telegraf" # required.
|
||||||
|
|
||||||
# Set the user agent for the POSTs (can be useful for log differentiation)
|
# Set the user agent for the POSTs (can be useful for log differentiation)
|
||||||
# user_agent = "telegraf"
|
# user_agent = "telegraf"
|
||||||
# tags = { "dc": "us-east-1" }
|
|
||||||
|
|
||||||
# Tags can also be specified via a normal map, but only one form at a time:
|
# Tags can also be specified via a normal map, but only one form at a time:
|
||||||
|
# [tags]
|
||||||
# [influxdb.tags]
|
|
||||||
# dc = "us-east-1"
|
# dc = "us-east-1"
|
||||||
|
|
||||||
# Configuration for telegraf itself
|
# Configuration for telegraf itself
|
||||||
|
|
|
@ -3,12 +3,15 @@ interval = "5s"
|
||||||
http = ":11213"
|
http = ":11213"
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[influxdb]
|
[outputs]
|
||||||
|
[outputs.influxdb]
|
||||||
url = "http://localhost:8086"
|
url = "http://localhost:8086"
|
||||||
username = "root"
|
username = "root"
|
||||||
password = "root"
|
password = "root"
|
||||||
database = "telegraf"
|
database = "telegraf"
|
||||||
tags = { dc = "us-phx-1" }
|
|
||||||
|
[tags]
|
||||||
|
dc = "us-phx-1"
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
address = ":6379"
|
address = ":6379"
|
||||||
|
|
Loading…
Reference in New Issue