diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f669de0e..2dfa674eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#137](https://github.com/influxdb/telegraf/issues/137): Memcached: fix when a value contains a space - [#138](https://github.com/influxdb/telegraf/issues/138): MySQL server address tag. - [#142](https://github.com/influxdb/telegraf/pull/142): Add Description and SampleConfig funcs to output interface +- Indent the toml config file for readability ### Bugfixes - [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing. diff --git a/config.go b/config.go index 5eb22ffe6..516fee1e5 100644 --- a/config.go +++ b/config.go @@ -387,11 +387,11 @@ func PrintSampleConfig() { creator := outputs.Outputs[oname] output := creator() - fmt.Printf("\n# %s\n[outputs.%s]\n", output.Description(), oname) + fmt.Printf("\n# %s\n[outputs.%s]", output.Description(), oname) config := output.SampleConfig() if config == "" { - fmt.Printf(" # no configuration\n\n") + fmt.Printf("\n # no configuration\n") } else { fmt.Printf(config) } @@ -411,17 +411,13 @@ func PrintSampleConfig() { creator := plugins.Plugins[pname] plugin := creator() - fmt.Printf("# %s\n[%s]\n", plugin.Description(), pname) + fmt.Printf("\n# %s\n[%s]", plugin.Description(), pname) config := plugin.SampleConfig() if config == "" { - fmt.Printf(" # no configuration\n\n") + fmt.Printf("\n # no configuration\n") } else { - lines := strings.Split(config, "\n") - for _, line := range lines { - fmt.Printf("%s\n", line) - } - fmt.Printf("\n") + fmt.Printf(config) } } } diff --git a/plugins/disque/disque.go b/plugins/disque/disque.go index 292e1b363..4e4e3b47f 100644 --- a/plugins/disque/disque.go +++ b/plugins/disque/disque.go @@ -21,12 +21,13 @@ type Disque struct { } var sampleConfig = ` -# An array of URI to gather stats about. Specify an ip or hostname -# with optional port and password. ie disque://localhost, disque://10.10.3.33:18832, -# 10.0.0.1:10000, etc. -# -# If no servers are specified, then localhost is used as the host. -servers = ["localhost"]` + # An array of URI to gather stats about. Specify an ip or hostname + # with optional port and password. ie disque://localhost, disque://10.10.3.33:18832, + # 10.0.0.1:10000, etc. + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] +` func (r *Disque) SampleConfig() string { return sampleConfig diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index 5607532e6..2127e93b7 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -28,12 +28,12 @@ type node struct { } const sampleConfig = ` -# specify a list of one or more Elasticsearch servers -servers = ["http://localhost:9200"] + # specify a list of one or more Elasticsearch servers + servers = ["http://localhost:9200"] -# set local to false when you want to read the indices stats from all nodes -# within the cluster -local = true + # set local to false when you want to read the indices stats from all nodes + # within the cluster + local = true ` // Elasticsearch is a plugin to read stats from one or many Elasticsearch diff --git a/plugins/exec/exec.go b/plugins/exec/exec.go index 8ab68e518..6c340db6f 100644 --- a/plugins/exec/exec.go +++ b/plugins/exec/exec.go @@ -11,13 +11,13 @@ import ( ) const sampleConfig = ` -# specify commands via an array of tables -[[exec.commands]] -# the command to run -command = "/usr/bin/mycollector --foo=bar" + # specify commands via an array of tables + [[exec.commands]] + # the command to run + command = "/usr/bin/mycollector --foo=bar" -# name of the command (used as a prefix for measurements) -name = "mycollector" + # name of the command (used as a prefix for measurements) + name = "mycollector" ` type Command struct { diff --git a/plugins/haproxy/haproxy.go b/plugins/haproxy/haproxy.go index e09bfe5be..df03ecced 100644 --- a/plugins/haproxy/haproxy.go +++ b/plugins/haproxy/haproxy.go @@ -84,13 +84,13 @@ type haproxy struct { } var sampleConfig = ` -# An array of address to gather stats about. Specify an ip on hostname -# with optional port. ie localhost, 10.10.3.33:1936, etc. -# -# If no servers are specified, then default to 127.0.0.1:1936 -servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"] -# Or you can also use local socket(not work yet) -# servers = ["socket:/run/haproxy/admin.sock"] + # An array of address to gather stats about. Specify an ip on hostname + # with optional port. ie localhost, 10.10.3.33:1936, etc. + # + # If no servers are specified, then default to 127.0.0.1:1936 + servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"] + # Or you can also use local socket(not work yet) + # servers = ["socket:/run/haproxy/admin.sock"] ` func (r *haproxy) SampleConfig() string { diff --git a/plugins/httpjson/httpjson.go b/plugins/httpjson/httpjson.go index 16b232f89..665622d46 100644 --- a/plugins/httpjson/httpjson.go +++ b/plugins/httpjson/httpjson.go @@ -46,25 +46,25 @@ func (c RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { } var sampleConfig = ` -# Specify services via an array of tables -[[httpjson.services]] + # Specify services via an array of tables + [[httpjson.services]] - # a name for the service being polled - name = "webserver_stats" + # a name for the service being polled + name = "webserver_stats" - # URL of each server in the service's cluster - servers = [ - "http://localhost:9999/stats/", - "http://localhost:9998/stats/", - ] + # URL of each server in the service's cluster + servers = [ + "http://localhost:9999/stats/", + "http://localhost:9998/stats/", + ] - # HTTP method to use (case-sensitive) - method = "GET" + # HTTP method to use (case-sensitive) + method = "GET" - # HTTP parameters (all values must be strings) - [httpjson.services.parameters] - event_type = "cpu_spike" - threshold = "0.75" + # HTTP parameters (all values must be strings) + [httpjson.services.parameters] + event_type = "cpu_spike" + threshold = "0.75" ` func (h *HttpJson) SampleConfig() string { diff --git a/plugins/kafka_consumer/kafka_consumer.go b/plugins/kafka_consumer/kafka_consumer.go index b2836e1d8..53fc8d110 100644 --- a/plugins/kafka_consumer/kafka_consumer.go +++ b/plugins/kafka_consumer/kafka_consumer.go @@ -20,17 +20,18 @@ type Kafka struct { } var sampleConfig = ` -# topic to consume -topic = "topic_with_metrics" + # topic to consume + topic = "topic_with_metrics" -# the name of the consumer group -consumerGroupName = "telegraf_metrics_consumers" + # the name of the consumer group + consumerGroupName = "telegraf_metrics_consumers" -# an array of Zookeeper connection strings -zookeeperPeers = ["localhost:2181"] + # an array of Zookeeper connection strings + zookeeperPeers = ["localhost:2181"] -# Batch size of points sent to InfluxDB -batchSize = 1000` + # Batch size of points sent to InfluxDB + batchSize = 1000 +` func (k *Kafka) SampleConfig() string { return sampleConfig diff --git a/plugins/leofs/leofs.go b/plugins/leofs/leofs.go index da08c3d72..ce6bd37ac 100644 --- a/plugins/leofs/leofs.go +++ b/plugins/leofs/leofs.go @@ -131,11 +131,11 @@ var serverTypeMapping = map[string]ServerType{ } var sampleConfig = ` -# An array of URI to gather stats about LeoFS. -# Specify an ip or hostname with port. ie 127.0.0.1:4020 -# -# If no servers are specified, then 127.0.0.1 is used as the host and 4020 as the port. -servers = ["127.0.0.1:4021"] + # An array of URI to gather stats about LeoFS. + # Specify an ip or hostname with port. ie 127.0.0.1:4020 + # + # If no servers are specified, then 127.0.0.1 is used as the host and 4020 as the port. + servers = ["127.0.0.1:4021"] ` func (l *LeoFS) SampleConfig() string { diff --git a/plugins/lustre2/lustre2.go b/plugins/lustre2/lustre2.go index 95b6bdbf7..549e0fc3f 100644 --- a/plugins/lustre2/lustre2.go +++ b/plugins/lustre2/lustre2.go @@ -25,11 +25,12 @@ type Lustre2 struct { } var sampleConfig = ` -# An array of /proc globs to search for Lustre stats -# If not specified, the default will work on Lustre 2.5.x -# -# ost_procfiles = ["/proc/fs/lustre/obdfilter/*/stats", "/proc/fs/lustre/osd-ldiskfs/*/stats"] -# mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"]` + # An array of /proc globs to search for Lustre stats + # If not specified, the default will work on Lustre 2.5.x + # + # ost_procfiles = ["/proc/fs/lustre/obdfilter/*/stats", "/proc/fs/lustre/osd-ldiskfs/*/stats"] + # mds_procfiles = ["/proc/fs/lustre/mdt/*/md_stats"] +` /* The wanted fields would be a []string if not for the lines that start with read_bytes/write_bytes and contain diff --git a/plugins/memcached/memcached.go b/plugins/memcached/memcached.go index 2cf555c87..cbab91e85 100644 --- a/plugins/memcached/memcached.go +++ b/plugins/memcached/memcached.go @@ -17,11 +17,12 @@ type Memcached struct { } var sampleConfig = ` -# An array of address to gather stats about. Specify an ip on hostname -# with optional port. ie localhost, 10.0.0.1:11211, etc. -# -# If no servers are specified, then localhost is used as the host. -servers = ["localhost"]` + # An array of address to gather stats about. Specify an ip on hostname + # with optional port. ie localhost, 10.0.0.1:11211, etc. + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] +` var defaultTimeout = 5 * time.Second diff --git a/plugins/mongodb/mongodb.go b/plugins/mongodb/mongodb.go index 28bbe3af0..b26da7a4e 100644 --- a/plugins/mongodb/mongodb.go +++ b/plugins/mongodb/mongodb.go @@ -25,12 +25,13 @@ type Ssl struct { } var sampleConfig = ` -# An array of URI to gather stats about. Specify an ip or hostname -# with optional port add password. ie mongodb://user:auth_key@10.10.3.30:27017, -# mongodb://10.10.3.33:18832, 10.0.0.1:10000, etc. -# -# If no servers are specified, then 127.0.0.1 is used as the host and 27107 as the port. -servers = ["127.0.0.1:27017"]` + # An array of URI to gather stats about. Specify an ip or hostname + # with optional port add password. ie mongodb://user:auth_key@10.10.3.30:27017, + # mongodb://10.10.3.33:18832, 10.0.0.1:10000, etc. + # + # If no servers are specified, then 127.0.0.1 is used as the host and 27107 as the port. + servers = ["127.0.0.1:27017"] +` func (m *MongoDB) SampleConfig() string { return sampleConfig diff --git a/plugins/mysql/mysql.go b/plugins/mysql/mysql.go index 425f3ea98..1bc72ff2a 100644 --- a/plugins/mysql/mysql.go +++ b/plugins/mysql/mysql.go @@ -14,14 +14,15 @@ type Mysql struct { } var sampleConfig = ` -# specify servers via a url matching: -# [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]] -# e.g. -# root:root@http://10.0.0.18/?tls=false -# root:passwd@tcp(127.0.0.1:3036)/ -# -# If no servers are specified, then localhost is used as the host. -servers = ["localhost"]` + # specify servers via a url matching: + # [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]] + # e.g. + # root:root@http://10.0.0.18/?tls=false + # root:passwd@tcp(127.0.0.1:3036)/ + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] +` func (m *Mysql) SampleConfig() string { return sampleConfig diff --git a/plugins/nginx/nginx.go b/plugins/nginx/nginx.go index 00a7a174c..97f273b63 100644 --- a/plugins/nginx/nginx.go +++ b/plugins/nginx/nginx.go @@ -19,8 +19,9 @@ type Nginx struct { } var sampleConfig = ` -# An array of Nginx stub_status URI to gather stats. -urls = ["http://localhost/status"]` + # An array of Nginx stub_status URI to gather stats. + urls = ["http://localhost/status"] +` func (n *Nginx) SampleConfig() string { return sampleConfig diff --git a/plugins/postgresql/postgresql.go b/plugins/postgresql/postgresql.go index 9312c4aa4..1a467fee9 100644 --- a/plugins/postgresql/postgresql.go +++ b/plugins/postgresql/postgresql.go @@ -18,28 +18,28 @@ type Postgresql struct { } var sampleConfig = ` -# specify servers via an array of tables -[[postgresql.servers]] + # specify servers via an array of tables + [[postgresql.servers]] -# specify address via a url matching: -# postgres://[pqgotest[:password]]@localhost?sslmode=[disable|verify-ca|verify-full] -# or a simple string: -# host=localhost user=pqotest password=... sslmode=... -# -# All connection parameters are optional. By default, the host is localhost -# and the user is the currently running user. For localhost, we default -# to sslmode=disable as well. -# + # specify address via a url matching: + # postgres://[pqgotest[:password]]@localhost?sslmode=[disable|verify-ca|verify-full] + # or a simple string: + # host=localhost user=pqotest password=... sslmode=... + # + # All connection parameters are optional. By default, the host is localhost + # and the user is the currently running user. For localhost, we default + # to sslmode=disable as well. + # -address = "sslmode=disable" + address = "sslmode=disable" -# A list of databases to pull metrics about. If not specified, metrics for all -# databases are gathered. + # A list of databases to pull metrics about. If not specified, metrics for all + # databases are gathered. -# databases = ["app_production", "blah_testing"] + # databases = ["app_production", "blah_testing"] -# [[postgresql.servers]] -# address = "influx@remoteserver" + # [[postgresql.servers]] + # address = "influx@remoteserver" ` func (p *Postgresql) SampleConfig() string { diff --git a/plugins/prometheus/prometheus.go b/plugins/prometheus/prometheus.go index 4029e9932..9e8b964e7 100644 --- a/plugins/prometheus/prometheus.go +++ b/plugins/prometheus/prometheus.go @@ -17,8 +17,9 @@ type Prometheus struct { } var sampleConfig = ` -# An array of urls to scrape metrics from. -urls = ["http://localhost:9100/metrics"]` + # An array of urls to scrape metrics from. + urls = ["http://localhost:9100/metrics"] +` func (r *Prometheus) SampleConfig() string { return sampleConfig diff --git a/plugins/rabbitmq/rabbitmq.go b/plugins/rabbitmq/rabbitmq.go index cd5ec6dc2..55b4b0a95 100644 --- a/plugins/rabbitmq/rabbitmq.go +++ b/plugins/rabbitmq/rabbitmq.go @@ -68,15 +68,15 @@ type Node struct { } var sampleConfig = ` -# Specify servers via an array of tables -[[rabbitmq.servers]] -# url = "http://localhost:15672" -# username = "guest" -# password = "guest" + # Specify servers via an array of tables + [[rabbitmq.servers]] + # url = "http://localhost:15672" + # username = "guest" + # password = "guest" -# A list of nodes to pull metrics about. If not specified, metrics for -# all nodes are gathered. -# nodes = ["rabbit@node1", "rabbit@node2"] + # A list of nodes to pull metrics about. If not specified, metrics for + # all nodes are gathered. + # nodes = ["rabbit@node1", "rabbit@node2"] ` func (r *RabbitMQ) SampleConfig() string { diff --git a/plugins/redis/redis.go b/plugins/redis/redis.go index d2f3dd374..013793f1b 100644 --- a/plugins/redis/redis.go +++ b/plugins/redis/redis.go @@ -21,12 +21,13 @@ type Redis struct { } var sampleConfig = ` -# An array of URI to gather stats about. Specify an ip or hostname -# with optional port add password. ie redis://localhost, redis://10.10.3.33:18832, -# 10.0.0.1:10000, etc. -# -# If no servers are specified, then localhost is used as the host. -servers = ["localhost"]` + # An array of URI to gather stats about. Specify an ip or hostname + # with optional port add password. ie redis://localhost, redis://10.10.3.33:18832, + # 10.0.0.1:10000, etc. + # + # If no servers are specified, then localhost is used as the host. + servers = ["localhost"] +` func (r *Redis) SampleConfig() string { return sampleConfig diff --git a/plugins/rethinkdb/rethinkdb.go b/plugins/rethinkdb/rethinkdb.go index 1c46a1f49..412145e1a 100644 --- a/plugins/rethinkdb/rethinkdb.go +++ b/plugins/rethinkdb/rethinkdb.go @@ -15,12 +15,13 @@ type RethinkDB struct { } var sampleConfig = ` -# An array of URI to gather stats about. Specify an ip or hostname -# with optional port add password. ie rethinkdb://user:auth_key@10.10.3.30:28105, -# rethinkdb://10.10.3.33:18832, 10.0.0.1:10000, etc. -# -# If no servers are specified, then 127.0.0.1 is used as the host and 28015 as the port. -servers = ["127.0.0.1:28015"]` + # An array of URI to gather stats about. Specify an ip or hostname + # with optional port add password. ie rethinkdb://user:auth_key@10.10.3.30:28105, + # rethinkdb://10.10.3.33:18832, 10.0.0.1:10000, etc. + # + # If no servers are specified, then 127.0.0.1 is used as the host and 28015 as the port. + servers = ["127.0.0.1:28015"] +` func (r *RethinkDB) SampleConfig() string { return sampleConfig diff --git a/plugins/system/cpu.go b/plugins/system/cpu.go index 1096b8517..ea34d2bbb 100644 --- a/plugins/system/cpu.go +++ b/plugins/system/cpu.go @@ -26,10 +26,11 @@ func (_ *CPUStats) Description() string { } var sampleConfig = ` -# Whether to report per-cpu stats or not -percpu = true -# Whether to report total system cpu stats or not -totalcpu = true` + # Whether to report per-cpu stats or not + percpu = true + # Whether to report total system cpu stats or not + totalcpu = true +` func (_ *CPUStats) SampleConfig() string { return sampleConfig diff --git a/plugins/system/net.go b/plugins/system/net.go index 014b01ea9..8a8847968 100644 --- a/plugins/system/net.go +++ b/plugins/system/net.go @@ -19,11 +19,11 @@ func (_ *NetIOStats) Description() string { } var netSampleConfig = ` -# By default, telegraf gathers stats from any up interface (excluding loopback) -# Setting interfaces will tell it to gather these explicit interfaces, -# regardless of status. -# -# interfaces = ["eth0", ... ] + # By default, telegraf gathers stats from any up interface (excluding loopback) + # Setting interfaces will tell it to gather these explicit interfaces, + # regardless of status. + # + # interfaces = ["eth0", ... ] ` func (_ *NetIOStats) SampleConfig() string {