diff --git a/plugins/inputs/activemq/README.md b/plugins/inputs/activemq/README.md index 90a8bfc2b..d02dc9453 100644 --- a/plugins/inputs/activemq/README.md +++ b/plugins/inputs/activemq/README.md @@ -5,7 +5,7 @@ This plugin gather queues, topics & subscribers metrics using ActiveMQ Console A ## Configuration ```toml -# Description +# Gather ActiveMQ metrics [[inputs.activemq]] ## ActiveMQ WebConsole URL url = "http://127.0.0.1:8161" diff --git a/plugins/inputs/activemq/activemq.go b/plugins/inputs/activemq/activemq.go index f614d1d64..f43976909 100644 --- a/plugins/inputs/activemq/activemq.go +++ b/plugins/inputs/activemq/activemq.go @@ -82,36 +82,6 @@ type Stats struct { DequeueCounter int `xml:"dequeueCounter,attr"` } -var sampleConfig = ` - ## ActiveMQ WebConsole URL - url = "http://127.0.0.1:8161" - - ## Credentials for basic HTTP authentication - # username = "admin" - # password = "admin" - - ## Required ActiveMQ webadmin root path - # webadmin = "admin" - - ## Maximum time to receive response. - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - ` - -func (a *ActiveMQ) Description() string { - return "Gather ActiveMQ metrics" -} - -func (a *ActiveMQ) SampleConfig() string { - return sampleConfig -} - func (a *ActiveMQ) createHTTPClient() (*http.Client, error) { tlsCfg, err := a.ClientConfig.TLSConfig() if err != nil { diff --git a/plugins/inputs/activemq/activemq_sample_config.go b/plugins/inputs/activemq/activemq_sample_config.go new file mode 100644 index 000000000..9170d43a9 --- /dev/null +++ b/plugins/inputs/activemq/activemq_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package activemq + +func (a *ActiveMQ) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/aerospike/aerospike.go b/plugins/inputs/aerospike/aerospike.go index 24358c435..c0e45b044 100644 --- a/plugins/inputs/aerospike/aerospike.go +++ b/plugins/inputs/aerospike/aerospike.go @@ -42,48 +42,6 @@ type Aerospike struct { NumberHistogramBuckets int `toml:"num_histogram_buckets"` } -var sampleConfig = ` - ## Aerospike servers to connect to (with port) - ## This plugin will query all namespaces the aerospike - ## server has configured and get stats for them. - servers = ["localhost:3000"] - - # username = "telegraf" - # password = "pa$$word" - - ## Optional TLS Config - # enable_tls = false - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - # tls_name = "tlsname" - ## If false, skip chain & host verification - # insecure_skip_verify = true - - # Feature Options - # Add namespace variable to limit the namespaces executed on - # Leave blank to do all - # disable_query_namespaces = true # default false - # namespaces = ["namespace1", "namespace2"] - - # Enable set level telemetry - # query_sets = true # default: false - # Add namespace set combinations to limit sets executed on - # Leave blank to do all sets - # sets = ["namespace1/set1", "namespace1/set2", "namespace3"] - - # Histograms - # enable_ttl_histogram = true # default: false - # enable_object_size_linear_histogram = true # default: false - - # by default, aerospike produces a 100 bucket histogram - # this is not great for most graphing tools, this will allow - # the ability to squash this to a smaller number of buckets - # To have a balanced histogram, the number of buckets chosen - # should divide evenly into 100. - # num_histogram_buckets = 100 # default: 10 -` - // On the random chance a hex value is all digits // these are fields that can contain hex and should always be strings var protectedHexFields = map[string]bool{ @@ -92,14 +50,6 @@ var protectedHexFields = map[string]bool{ "paxos_principal": true, } -func (a *Aerospike) SampleConfig() string { - return sampleConfig -} - -func (a *Aerospike) Description() string { - return "Read stats from aerospike server(s)" -} - func (a *Aerospike) Gather(acc telegraf.Accumulator) error { if !a.initialized { tlsConfig, err := a.ClientConfig.TLSConfig() diff --git a/plugins/inputs/aerospike/aerospike_sample_config.go b/plugins/inputs/aerospike/aerospike_sample_config.go new file mode 100644 index 000000000..1c42b63b4 --- /dev/null +++ b/plugins/inputs/aerospike/aerospike_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package aerospike + +func (a *Aerospike) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/aliyuncms/README.md b/plugins/inputs/aliyuncms/README.md index 0f6331d7d..03e6a2748 100644 --- a/plugins/inputs/aliyuncms/README.md +++ b/plugins/inputs/aliyuncms/README.md @@ -20,6 +20,8 @@ In the following order the plugin will attempt to authenticate. ## Configuration ```toml +# Pull Metric Statistics from Aliyun CMS +[[inputs.aliyuncms]] ## Aliyun Credentials ## Credentials are loaded in the following order ## 1) Ram RoleArn credential diff --git a/plugins/inputs/aliyuncms/aliyuncms.go b/plugins/inputs/aliyuncms/aliyuncms.go index 1dc20d718..dba1811b7 100644 --- a/plugins/inputs/aliyuncms/aliyuncms.go +++ b/plugins/inputs/aliyuncms/aliyuncms.go @@ -20,110 +20,6 @@ import ( "github.com/pkg/errors" ) -const ( - description = "Pull Metric Statistics from Aliyun CMS" - sampleConfig = ` - ## Aliyun Credentials - ## Credentials are loaded in the following order - ## 1) Ram RoleArn credential - ## 2) AccessKey STS token credential - ## 3) AccessKey credential - ## 4) Ecs Ram Role credential - ## 5) RSA keypair credential - ## 6) Environment variables credential - ## 7) Instance metadata credential - - # access_key_id = "" - # access_key_secret = "" - # access_key_sts_token = "" - # role_arn = "" - # role_session_name = "" - # private_key = "" - # public_key_id = "" - # role_name = "" - - ## Specify the ali cloud region list to be queried for metrics and objects discovery - ## If not set, all supported regions (see below) would be covered, it can provide a significant load on API, so the recommendation here - ## is to limit the list as much as possible. Allowed values: https://www.alibabacloud.com/help/zh/doc-detail/40654.htm - ## Default supported regions are: - ## 21 items: cn-qingdao,cn-beijing,cn-zhangjiakou,cn-huhehaote,cn-hangzhou,cn-shanghai,cn-shenzhen, - ## cn-heyuan,cn-chengdu,cn-hongkong,ap-southeast-1,ap-southeast-2,ap-southeast-3,ap-southeast-5, - ## ap-south-1,ap-northeast-1,us-west-1,us-east-1,eu-central-1,eu-west-1,me-east-1 - ## - ## From discovery perspective it set the scope for object discovery, the discovered info can be used to enrich - ## the metrics with objects attributes/tags. Discovery is supported not for all projects (if not supported, then - ## it will be reported on the start - for example for 'acs_cdn' project: - ## 'E! [inputs.aliyuncms] Discovery tool is not activated: no discovery support for project "acs_cdn"' ) - ## Currently, discovery supported for the following projects: - ## - acs_ecs_dashboard - ## - acs_rds_dashboard - ## - acs_slb_dashboard - ## - acs_vpc_eip - regions = ["cn-hongkong"] - - # The minimum period for AliyunCMS metrics is 1 minute (60s). However not all - # metrics are made available to the 1 minute period. Some are collected at - # 3 minute, 5 minute, or larger intervals. - # See: https://help.aliyun.com/document_detail/51936.html?spm=a2c4g.11186623.2.18.2bc1750eeOw1Pv - # Note that if a period is configured that is smaller than the minimum for a - # particular metric, that metric will not be returned by the Aliyun OpenAPI - # and will not be collected by Telegraf. - # - ## Requested AliyunCMS aggregation Period (required - must be a multiple of 60s) - period = "5m" - - ## Collection Delay (required - must account for metrics availability via AliyunCMS API) - delay = "1m" - - ## Recommended: use metric 'interval' that is a multiple of 'period' to avoid - ## gaps or overlap in pulled data - interval = "5m" - - ## Metric Statistic Project (required) - project = "acs_slb_dashboard" - - ## Maximum requests per second, default value is 200 - ratelimit = 200 - - ## How often the discovery API call executed (default 1m) - #discovery_interval = "1m" - - ## Metrics to Pull (Required) - [[inputs.aliyuncms.metrics]] - ## Metrics names to be requested, - ## described here (per project): https://help.aliyun.com/document_detail/28619.html?spm=a2c4g.11186623.6.690.1938ad41wg8QSq - names = ["InstanceActiveConnection", "InstanceNewConnection"] - - ## Dimension filters for Metric (these are optional). - ## This allows to get additional metric dimension. If dimension is not specified it can be returned or - ## the data can be aggregated - it depends on particular metric, you can find details here: https://help.aliyun.com/document_detail/28619.html?spm=a2c4g.11186623.6.690.1938ad41wg8QSq - ## - ## Note, that by default dimension filter includes the list of discovered objects in scope (if discovery is enabled) - ## Values specified here would be added into the list of discovered objects. - ## You can specify either single dimension: - #dimensions = '{"instanceId": "p-example"}' - - ## Or you can specify several dimensions at once: - #dimensions = '[{"instanceId": "p-example"},{"instanceId": "q-example"}]' - - ## Enrichment tags, can be added from discovery (if supported) - ## Notation is : - ## To figure out which fields are available, consult the Describe API per project. - ## For example, for SLB: https://api.aliyun.com/#/?product=Slb&version=2014-05-15&api=DescribeLoadBalancers¶ms={}&tab=MOCK&lang=GO - #tag_query_path = [ - # "address:Address", - # "name:LoadBalancerName", - # "cluster_owner:Tags.Tag[?TagKey=='cs.cluster.name'].TagValue | [0]" - # ] - ## The following tags added by default: regionId (if discovery enabled), userId, instanceId. - - ## Allow metrics without discovery data, if discovery is enabled. If set to true, then metric without discovery - ## data would be emitted, otherwise dropped. This cane be of help, in case debugging dimension filters, or partial coverage - ## of discovery scope vs monitoring scope - #allow_dps_without_discovery = false -` -) - type ( // AliyunCMS is aliyun cms config info. AliyunCMS struct { @@ -207,16 +103,6 @@ var aliyunRegionList = []string{ "me-east-1", } -// SampleConfig implements telegraf.Inputs interface -func (s *AliyunCMS) SampleConfig() string { - return sampleConfig -} - -// Description implements telegraf.Inputs interface -func (s *AliyunCMS) Description() string { - return description -} - // Init perform checks of plugin inputs and initialize internals func (s *AliyunCMS) Init() error { if s.Project == "" { diff --git a/plugins/inputs/aliyuncms/aliyuncms_sample_config.go b/plugins/inputs/aliyuncms/aliyuncms_sample_config.go new file mode 100644 index 000000000..53fff350e --- /dev/null +++ b/plugins/inputs/aliyuncms/aliyuncms_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package aliyuncms + +func (s *AliyunCMS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/amd_rocm_smi/README.md b/plugins/inputs/amd_rocm_smi/README.md index f33df02c1..392cb94e0 100644 --- a/plugins/inputs/amd_rocm_smi/README.md +++ b/plugins/inputs/amd_rocm_smi/README.md @@ -5,7 +5,7 @@ This plugin uses a query on the [`rocm-smi`](https://github.com/RadeonOpenComput ## Configuration ```toml -# Pulls statistics from AMD GPUs attached to the host +# Query statistics from AMD Graphics cards using rocm-smi binary [[inputs.amd_rocm_smi]] ## Optional: path to rocm-smi binary, defaults to $PATH via exec.LookPath # bin_path = "/opt/rocm/bin/rocm-smi" diff --git a/plugins/inputs/amd_rocm_smi/amd_rocm_smi.go b/plugins/inputs/amd_rocm_smi/amd_rocm_smi.go index 7fdd32f46..41647539a 100644 --- a/plugins/inputs/amd_rocm_smi/amd_rocm_smi.go +++ b/plugins/inputs/amd_rocm_smi/amd_rocm_smi.go @@ -22,24 +22,6 @@ type ROCmSMI struct { Timeout config.Duration } -// Description returns the description of the ROCmSMI plugin -func (rsmi *ROCmSMI) Description() string { - return "Query statistics from AMD Graphics cards using rocm-smi binary" -} - -var ROCmSMIConfig = ` -## Optional: path to rocm-smi binary, defaults to $PATH via exec.LookPath -# bin_path = "/opt/rocm/bin/rocm-smi" - -## Optional: timeout for GPU polling -# timeout = "5s" -` - -// SampleConfig returns the sample configuration for the ROCmSMI plugin -func (rsmi *ROCmSMI) SampleConfig() string { - return ROCmSMIConfig -} - // Gather implements the telegraf interface func (rsmi *ROCmSMI) Gather(acc telegraf.Accumulator) error { if _, err := os.Stat(rsmi.BinPath); os.IsNotExist(err) { diff --git a/plugins/inputs/amd_rocm_smi/amd_rocm_smi_sample_config.go b/plugins/inputs/amd_rocm_smi/amd_rocm_smi_sample_config.go new file mode 100644 index 000000000..2508f6004 --- /dev/null +++ b/plugins/inputs/amd_rocm_smi/amd_rocm_smi_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package amd_rocm_smi + +func (rsmi *ROCmSMI) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/amqp_consumer/README.md b/plugins/inputs/amqp_consumer/README.md index b383b723d..c3455b025 100644 --- a/plugins/inputs/amqp_consumer/README.md +++ b/plugins/inputs/amqp_consumer/README.md @@ -11,14 +11,13 @@ For an introduction to AMQP see: - [amqp - concepts](https://www.rabbitmq.com/tutorials/amqp-concepts.html) - [rabbitmq: getting started](https://www.rabbitmq.com/getstarted.html) +## Configuration + The following defaults are known to work with RabbitMQ: ```toml +# AMQP consumer plugin [[inputs.amqp_consumer]] - ## Broker to consume from. - ## deprecated in 1.7; use the brokers option - # url = "amqp://localhost:5672/influxdb" - ## Brokers to consume from. If multiple brokers are specified a random broker ## will be selected anytime a connection is established. This can be ## helpful for load balancing when not using a dedicated load balancer. diff --git a/plugins/inputs/amqp_consumer/amqp_consumer.go b/plugins/inputs/amqp_consumer/amqp_consumer.go index acd631238..7d4ef02d8 100644 --- a/plugins/inputs/amqp_consumer/amqp_consumer.go +++ b/plugins/inputs/amqp_consumer/amqp_consumer.go @@ -88,87 +88,6 @@ const ( DefaultPrefetchCount = 50 ) -func (a *AMQPConsumer) SampleConfig() string { - return ` - ## Brokers to consume from. If multiple brokers are specified a random broker - ## will be selected anytime a connection is established. This can be - ## helpful for load balancing when not using a dedicated load balancer. - brokers = ["amqp://localhost:5672/influxdb"] - - ## Authentication credentials for the PLAIN auth_method. - # username = "" - # password = "" - - ## Name of the exchange to declare. If unset, no exchange will be declared. - exchange = "telegraf" - - ## Exchange type; common types are "direct", "fanout", "topic", "header", "x-consistent-hash". - # exchange_type = "topic" - - ## If true, exchange will be passively declared. - # exchange_passive = false - - ## Exchange durability can be either "transient" or "durable". - # exchange_durability = "durable" - - ## Additional exchange arguments. - # exchange_arguments = { } - # exchange_arguments = {"hash_property" = "timestamp"} - - ## AMQP queue name. - queue = "telegraf" - - ## AMQP queue durability can be "transient" or "durable". - queue_durability = "durable" - - ## If true, queue will be passively declared. - # queue_passive = false - - ## A binding between the exchange and queue using this binding key is - ## created. If unset, no binding is created. - binding_key = "#" - - ## Maximum number of messages server should give to the worker. - # prefetch_count = 50 - - ## Maximum messages to read from the broker that have not been written by an - ## output. For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message from the queue contains 10 metrics and the - ## output metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## Auth method. PLAIN and EXTERNAL are supported - ## Using EXTERNAL requires enabling the rabbitmq_auth_mechanism_ssl plugin as - ## described here: https://www.rabbitmq.com/plugins.html - # auth_method = "PLAIN" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Content encoding for message payloads, can be set to "gzip" to or - ## "identity" to apply no encoding. - # content_encoding = "identity" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` -} - -func (a *AMQPConsumer) Description() string { - return "AMQP consumer plugin" -} - func (a *AMQPConsumer) SetParser(parser parsers.Parser) { a.parser = parser } diff --git a/plugins/inputs/amqp_consumer/amqp_consumer_sample_config.go b/plugins/inputs/amqp_consumer/amqp_consumer_sample_config.go new file mode 100644 index 000000000..d92caaf7d --- /dev/null +++ b/plugins/inputs/amqp_consumer/amqp_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package amqp_consumer + +func (a *AMQPConsumer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/apache/apache.go b/plugins/inputs/apache/apache.go index 9b9059ac8..7eaf05997 100644 --- a/plugins/inputs/apache/apache.go +++ b/plugins/inputs/apache/apache.go @@ -27,35 +27,6 @@ type Apache struct { client *http.Client } -var sampleConfig = ` - ## An array of URLs to gather from, must be directed at the machine - ## readable version of the mod_status page including the auto query string. - ## Default is "http://localhost/server-status?auto". - urls = ["http://localhost/server-status?auto"] - - ## Credentials for basic HTTP authentication. - # username = "myuser" - # password = "mypassword" - - ## Maximum time to receive response. - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (n *Apache) SampleConfig() string { - return sampleConfig -} - -func (n *Apache) Description() string { - return "Read Apache status information (mod_status)" -} - func (n *Apache) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/apache/apache_sample_config.go b/plugins/inputs/apache/apache_sample_config.go new file mode 100644 index 000000000..4de4091fd --- /dev/null +++ b/plugins/inputs/apache/apache_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package apache + +func (n *Apache) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/apcupsd/README.md b/plugins/inputs/apcupsd/README.md index eb100a462..f02dc0552 100644 --- a/plugins/inputs/apcupsd/README.md +++ b/plugins/inputs/apcupsd/README.md @@ -9,6 +9,7 @@ apcupsd should be installed and it's daemon should be running. ## Configuration ```toml +# Monitor APC UPSes connected to apcupsd [[inputs.apcupsd]] # A list of running apcupsd server to connect to. # If not provided will default to tcp://127.0.0.1:3551 diff --git a/plugins/inputs/apcupsd/apcupsd.go b/plugins/inputs/apcupsd/apcupsd.go index 2cb752298..bd90103dd 100644 --- a/plugins/inputs/apcupsd/apcupsd.go +++ b/plugins/inputs/apcupsd/apcupsd.go @@ -23,23 +23,6 @@ type ApcUpsd struct { Timeout config.Duration } -func (*ApcUpsd) Description() string { - return "Monitor APC UPSes connected to apcupsd" -} - -var sampleConfig = ` - # A list of running apcupsd server to connect to. - # If not provided will default to tcp://127.0.0.1:3551 - servers = ["tcp://127.0.0.1:3551"] - - ## Timeout for dialing server. - timeout = "5s" -` - -func (*ApcUpsd) SampleConfig() string { - return sampleConfig -} - func (h *ApcUpsd) Gather(acc telegraf.Accumulator) error { ctx := context.Background() diff --git a/plugins/inputs/apcupsd/apcupsd_sample_config.go b/plugins/inputs/apcupsd/apcupsd_sample_config.go new file mode 100644 index 000000000..7d8df9f41 --- /dev/null +++ b/plugins/inputs/apcupsd/apcupsd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package apcupsd + +func (*ApcUpsd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/apcupsd/apcupsd_test.go b/plugins/inputs/apcupsd/apcupsd_test.go index f21c5a4c4..ee9474adc 100644 --- a/plugins/inputs/apcupsd/apcupsd_test.go +++ b/plugins/inputs/apcupsd/apcupsd_test.go @@ -15,7 +15,6 @@ import ( func TestApcupsdDocs(_ *testing.T) { apc := &ApcUpsd{} - apc.Description() apc.SampleConfig() } diff --git a/plugins/inputs/aurora/README.md b/plugins/inputs/aurora/README.md index 90910101f..0519c97b3 100644 --- a/plugins/inputs/aurora/README.md +++ b/plugins/inputs/aurora/README.md @@ -7,6 +7,7 @@ For monitoring recommendations reference [Monitoring your Aurora cluster](https: ## Configuration ```toml +# Gather metrics from Apache Aurora schedulers [[inputs.aurora]] ## Schedulers are the base addresses of your Aurora Schedulers schedulers = ["http://127.0.0.1:8081"] diff --git a/plugins/inputs/aurora/aurora.go b/plugins/inputs/aurora/aurora.go index 45a2fabb6..e32a00de6 100644 --- a/plugins/inputs/aurora/aurora.go +++ b/plugins/inputs/aurora/aurora.go @@ -54,39 +54,6 @@ type Aurora struct { urls []*url.URL } -var sampleConfig = ` - ## Schedulers are the base addresses of your Aurora Schedulers - schedulers = ["http://127.0.0.1:8081"] - - ## Set of role types to collect metrics from. - ## - ## The scheduler roles are checked each interval by contacting the - ## scheduler nodes; zookeeper is not contacted. - # roles = ["leader", "follower"] - - ## Timeout is the max time for total network operations. - # timeout = "5s" - - ## Username and password are sent using HTTP Basic Auth. - # username = "username" - # password = "pa$$word" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (a *Aurora) SampleConfig() string { - return sampleConfig -} - -func (a *Aurora) Description() string { - return "Gather metrics from Apache Aurora schedulers" -} - func (a *Aurora) Gather(acc telegraf.Accumulator) error { if a.client == nil { err := a.initialize() diff --git a/plugins/inputs/aurora/aurora_sample_config.go b/plugins/inputs/aurora/aurora_sample_config.go new file mode 100644 index 000000000..daeb81516 --- /dev/null +++ b/plugins/inputs/aurora/aurora_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package aurora + +func (a *Aurora) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/azure_storage_queue/README.md b/plugins/inputs/azure_storage_queue/README.md index c080be456..ded991064 100644 --- a/plugins/inputs/azure_storage_queue/README.md +++ b/plugins/inputs/azure_storage_queue/README.md @@ -5,7 +5,7 @@ This plugin gathers sizes of Azure Storage Queues. ## Configuration ```toml -# Description +# Gather Azure Storage Queue metrics [[inputs.azure_storage_queue]] ## Required Azure Storage Account name account_name = "mystorageaccount" diff --git a/plugins/inputs/azure_storage_queue/azure_storage_queue.go b/plugins/inputs/azure_storage_queue/azure_storage_queue.go index 6d132a5ef..e582b4213 100644 --- a/plugins/inputs/azure_storage_queue/azure_storage_queue.go +++ b/plugins/inputs/azure_storage_queue/azure_storage_queue.go @@ -21,25 +21,6 @@ type AzureStorageQueue struct { serviceURL *azqueue.ServiceURL } -var sampleConfig = ` - ## Required Azure Storage Account name - account_name = "mystorageaccount" - - ## Required Azure Storage Account access key - account_key = "storageaccountaccesskey" - - ## Set to false to disable peeking age of oldest message (executes faster) - # peek_oldest_message_age = true - ` - -func (a *AzureStorageQueue) Description() string { - return "Gather Azure Storage Queue metrics" -} - -func (a *AzureStorageQueue) SampleConfig() string { - return sampleConfig -} - func (a *AzureStorageQueue) Init() error { if a.StorageAccountName == "" { return errors.New("account_name must be configured") diff --git a/plugins/inputs/azure_storage_queue/azure_storage_queue_sample_config.go b/plugins/inputs/azure_storage_queue/azure_storage_queue_sample_config.go new file mode 100644 index 000000000..3e3b123c0 --- /dev/null +++ b/plugins/inputs/azure_storage_queue/azure_storage_queue_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package azure_storage_queue + +func (a *AzureStorageQueue) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/bcache/README.md b/plugins/inputs/bcache/README.md index 0937adcfc..0ab326e2d 100644 --- a/plugins/inputs/bcache/README.md +++ b/plugins/inputs/bcache/README.md @@ -51,11 +51,12 @@ cache_readaheads Count of times readahead occurred. ``` -## Example +## Configuration Using this configuration: ```toml +# Read metrics of bcache from stats_total and dirty_data [[inputs.bcache]] ## Bcache sets path ## If not specified, then default is: diff --git a/plugins/inputs/bcache/bcache.go b/plugins/inputs/bcache/bcache.go index 84eb3262f..e46100d17 100644 --- a/plugins/inputs/bcache/bcache.go +++ b/plugins/inputs/bcache/bcache.go @@ -22,25 +22,6 @@ type Bcache struct { BcacheDevs []string } -var sampleConfig = ` - ## Bcache sets path - ## If not specified, then default is: - bcachePath = "/sys/fs/bcache" - - ## By default, Telegraf gather stats for all bcache devices - ## Setting devices will restrict the stats to the specified - ## bcache devices. - bcacheDevs = ["bcache0"] -` - -func (b *Bcache) SampleConfig() string { - return sampleConfig -} - -func (b *Bcache) Description() string { - return "Read metrics of bcache from stats_total and dirty_data" -} - func getTags(bdev string) map[string]string { backingDevFile, _ := os.Readlink(bdev) backingDevPath := strings.Split(backingDevFile, "/") diff --git a/plugins/inputs/bcache/bcache_sample_config.go b/plugins/inputs/bcache/bcache_sample_config.go new file mode 100644 index 000000000..396a4815a --- /dev/null +++ b/plugins/inputs/bcache/bcache_sample_config.go @@ -0,0 +1,11 @@ +//go:build !windows +// +build !windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package bcache + +func (b *Bcache) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/beanstalkd/README.md b/plugins/inputs/beanstalkd/README.md index 3b3719894..feebca634 100644 --- a/plugins/inputs/beanstalkd/README.md +++ b/plugins/inputs/beanstalkd/README.md @@ -5,6 +5,7 @@ The `beanstalkd` plugin collects server stats as well as tube stats (reported by ## Configuration ```toml +# Collects Beanstalkd server and tubes stats [[inputs.beanstalkd]] ## Server to collect data from server = "localhost:11300" diff --git a/plugins/inputs/beanstalkd/beanstalkd.go b/plugins/inputs/beanstalkd/beanstalkd.go index b8a5c9797..9d67b70b8 100644 --- a/plugins/inputs/beanstalkd/beanstalkd.go +++ b/plugins/inputs/beanstalkd/beanstalkd.go @@ -11,28 +11,11 @@ import ( "gopkg.in/yaml.v2" ) -const sampleConfig = ` - ## Server to collect data from - server = "localhost:11300" - - ## List of tubes to gather stats about. - ## If no tubes specified then data gathered for each tube on server reported by list-tubes command - tubes = ["notifications"] -` - type Beanstalkd struct { Server string `toml:"server"` Tubes []string `toml:"tubes"` } -func (b *Beanstalkd) Description() string { - return "Collects Beanstalkd server and tubes stats" -} - -func (b *Beanstalkd) SampleConfig() string { - return sampleConfig -} - func (b *Beanstalkd) Gather(acc telegraf.Accumulator) error { connection, err := textproto.Dial("tcp", b.Server) if err != nil { diff --git a/plugins/inputs/beanstalkd/beanstalkd_sample_config.go b/plugins/inputs/beanstalkd/beanstalkd_sample_config.go new file mode 100644 index 000000000..d1a820197 --- /dev/null +++ b/plugins/inputs/beanstalkd/beanstalkd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package beanstalkd + +func (b *Beanstalkd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/beat/README.md b/plugins/inputs/beat/README.md index 5f51271da..ecf6f5edb 100644 --- a/plugins/inputs/beat/README.md +++ b/plugins/inputs/beat/README.md @@ -6,6 +6,8 @@ known to work with Filebeat and Kafkabeat. ## Configuration ```toml +# Read metrics exposed by Beat +[[inputs.beat]] ## An URL from which to read Beat-formatted JSON ## Default is "http://127.0.0.1:5066". url = "http://127.0.0.1:5066" diff --git a/plugins/inputs/beat/beat.go b/plugins/inputs/beat/beat.go index 08b5c3851..b76ff0a4b 100644 --- a/plugins/inputs/beat/beat.go +++ b/plugins/inputs/beat/beat.go @@ -15,42 +15,6 @@ import ( jsonparser "github.com/influxdata/telegraf/plugins/parsers/json" ) -const sampleConfig = ` - ## An URL from which to read Beat-formatted JSON - ## Default is "http://127.0.0.1:5066". - url = "http://127.0.0.1:5066" - - ## Enable collection of the listed stats - ## An empty list means collect all. Available options are currently - ## "beat", "libbeat", "system" and "filebeat". - # include = ["beat", "libbeat", "filebeat"] - - ## HTTP method - # method = "GET" - - ## Optional HTTP headers - # headers = {"X-Special-Header" = "Special-Value"} - - ## Override HTTP "Host" header - # host_header = "logstash.example.com" - - ## Timeout for HTTP requests - # timeout = "5s" - - ## Optional HTTP Basic Auth credentials - # username = "username" - # password = "pa$$word" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -const description = "Read metrics exposed by Beat" - const suffixInfo = "/" const suffixStats = "/stats" @@ -113,14 +77,6 @@ func (beat *Beat) Init() error { return nil } -func (beat *Beat) Description() string { - return description -} - -func (beat *Beat) SampleConfig() string { - return sampleConfig -} - // createHTTPClient create a clients to access API func (beat *Beat) createHTTPClient() (*http.Client, error) { tlsConfig, err := beat.ClientConfig.TLSConfig() diff --git a/plugins/inputs/beat/beat_sample_config.go b/plugins/inputs/beat/beat_sample_config.go new file mode 100644 index 000000000..000752ff3 --- /dev/null +++ b/plugins/inputs/beat/beat_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package beat + +func (beat *Beat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/bind/README.md b/plugins/inputs/bind/README.md index 2ebda282c..eb22427d2 100644 --- a/plugins/inputs/bind/README.md +++ b/plugins/inputs/bind/README.md @@ -16,6 +16,19 @@ not enable support for JSON statistics in their BIND packages. ## Configuration +```toml +# Read BIND nameserver XML statistics +[[inputs.bind]] + ## An array of BIND XML statistics URI to gather stats. + ## Default is "http://localhost:8053/xml/v3". + # urls = ["http://localhost:8053/xml/v3"] + # gather_memory_contexts = false + # gather_views = false + + ## Timeout for http requests made by bind nameserver + # timeout = "4s" +``` + - **urls** []string: List of BIND statistics channel URLs to collect from. Do not include a trailing slash in the URL. Default is "http://localhost:8053/xml/v3". - **gather_memory_contexts** bool: Report per-context memory statistics. diff --git a/plugins/inputs/bind/bind.go b/plugins/inputs/bind/bind.go index dd7b3d128..d04283566 100644 --- a/plugins/inputs/bind/bind.go +++ b/plugins/inputs/bind/bind.go @@ -21,25 +21,6 @@ type Bind struct { client http.Client } -var sampleConfig = ` - ## An array of BIND XML statistics URI to gather stats. - ## Default is "http://localhost:8053/xml/v3". - # urls = ["http://localhost:8053/xml/v3"] - # gather_memory_contexts = false - # gather_views = false - - ## Timeout for http requests made by bind nameserver - # timeout = "4s" -` - -func (b *Bind) Description() string { - return "Read BIND nameserver XML statistics" -} - -func (b *Bind) SampleConfig() string { - return sampleConfig -} - func (b *Bind) Init() error { b.client = http.Client{ Timeout: time.Duration(b.Timeout), diff --git a/plugins/inputs/bind/bind_sample_config.go b/plugins/inputs/bind/bind_sample_config.go new file mode 100644 index 000000000..278c9d709 --- /dev/null +++ b/plugins/inputs/bind/bind_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package bind + +func (b *Bind) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/bond/README.md b/plugins/inputs/bond/README.md index 517671f7e..55ec3b812 100644 --- a/plugins/inputs/bond/README.md +++ b/plugins/inputs/bond/README.md @@ -7,6 +7,7 @@ The plugin collects these metrics from `/proc/net/bonding/*` files. ## Configuration ```toml +# Collect bond interface status, slaves statuses and failures count [[inputs.bond]] ## Sets 'proc' directory path ## If not specified, then default is /proc diff --git a/plugins/inputs/bond/bond.go b/plugins/inputs/bond/bond.go index de6f3602b..ed009904a 100644 --- a/plugins/inputs/bond/bond.go +++ b/plugins/inputs/bond/bond.go @@ -34,34 +34,6 @@ type sysFiles struct { ADPortsFile string } -const sampleConfig = ` - ## Sets 'proc' directory path - ## If not specified, then default is /proc - # host_proc = "/proc" - - ## Sets 'sys' directory path - ## If not specified, then default is /sys - # host_sys = "/sys" - - ## By default, telegraf gather stats for all bond interfaces - ## Setting interfaces will restrict the stats to the specified - ## bond interfaces. - # bond_interfaces = ["bond0"] - - ## Tries to collect additional bond details from /sys/class/net/{bond} - ## currently only useful for LACP (mode 4) bonds - # collect_sys_details = false - -` - -func (bond *Bond) Description() string { - return "Collect bond interface status, slaves statuses and failures count" -} - -func (bond *Bond) SampleConfig() string { - return sampleConfig -} - func (bond *Bond) Gather(acc telegraf.Accumulator) error { // load proc path, get default value if config value and env variable are empty bond.loadPaths() diff --git a/plugins/inputs/bond/bond_sample_config.go b/plugins/inputs/bond/bond_sample_config.go new file mode 100644 index 000000000..66d1d23bb --- /dev/null +++ b/plugins/inputs/bond/bond_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package bond + +func (bond *Bond) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/burrow/README.md b/plugins/inputs/burrow/README.md index 2bdddf28c..5eef05f8e 100644 --- a/plugins/inputs/burrow/README.md +++ b/plugins/inputs/burrow/README.md @@ -8,6 +8,7 @@ Supported Burrow version: `1.x` ## Configuration ```toml +# Collect Kafka topics and consumers status from Burrow HTTP API. [[inputs.burrow]] ## Burrow API endpoints in format "schema://host:port". ## Default is "http://localhost:8000". diff --git a/plugins/inputs/burrow/burrow.go b/plugins/inputs/burrow/burrow.go index d575ea7f5..c317c0b72 100644 --- a/plugins/inputs/burrow/burrow.go +++ b/plugins/inputs/burrow/burrow.go @@ -24,48 +24,6 @@ const ( defaultServer = "http://localhost:8000" ) -const configSample = ` - ## Burrow API endpoints in format "schema://host:port". - ## Default is "http://localhost:8000". - servers = ["http://localhost:8000"] - - ## Override Burrow API prefix. - ## Useful when Burrow is behind reverse-proxy. - # api_prefix = "/v3/kafka" - - ## Maximum time to receive response. - # response_timeout = "5s" - - ## Limit per-server concurrent connections. - ## Useful in case of large number of topics or consumer groups. - # concurrent_connections = 20 - - ## Filter clusters, default is no filtering. - ## Values can be specified as glob patterns. - # clusters_include = [] - # clusters_exclude = [] - - ## Filter consumer groups, default is no filtering. - ## Values can be specified as glob patterns. - # groups_include = [] - # groups_exclude = [] - - ## Filter topics, default is no filtering. - ## Values can be specified as glob patterns. - # topics_include = [] - # topics_exclude = [] - - ## Credentials for basic HTTP authentication. - # username = "" - # password = "" - - ## Optional SSL config - # ssl_ca = "/etc/telegraf/ca.pem" - # ssl_cert = "/etc/telegraf/cert.pem" - # ssl_key = "/etc/telegraf/key.pem" - # insecure_skip_verify = false -` - type ( burrow struct { tls.ClientConfig @@ -133,14 +91,6 @@ func init() { }) } -func (b *burrow) SampleConfig() string { - return configSample -} - -func (b *burrow) Description() string { - return "Collect Kafka topics and consumers status from Burrow HTTP API." -} - func (b *burrow) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/burrow/burrow_sample_config.go b/plugins/inputs/burrow/burrow_sample_config.go new file mode 100644 index 000000000..988d4ce9e --- /dev/null +++ b/plugins/inputs/burrow/burrow_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package burrow + +func (b *burrow) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cassandra/README.md b/plugins/inputs/cassandra/README.md index a68f07f22..210d7e998 100644 --- a/plugins/inputs/cassandra/README.md +++ b/plugins/inputs/cassandra/README.md @@ -18,7 +18,7 @@ See: [https://jolokia.org/](https://jolokia.org/) and [Cassandra Documentation]( Cassandra plugin produces one or more measurements for each metric configured, adding Server's name as `host` tag. More than one measurement is generated when querying table metrics with a wildcard for the keyspace or table name. -Given a configuration like: +## Configuration ```toml # Read Cassandra metrics through Jolokia diff --git a/plugins/inputs/cassandra/cassandra.go b/plugins/inputs/cassandra/cassandra.go index d1c23caad..e73a4425e 100644 --- a/plugins/inputs/cassandra/cassandra.go +++ b/plugins/inputs/cassandra/cassandra.go @@ -165,33 +165,6 @@ func (c cassandraMetric) addTagsFields(out map[string]interface{}) { } } -func (c *Cassandra) SampleConfig() string { - return ` - ## DEPRECATED: The cassandra plugin has been deprecated. Please use the - ## jolokia2 plugin instead. - ## - ## see https://github.com/influxdata/telegraf/tree/master/plugins/inputs/jolokia2 - - context = "/jolokia/read" - ## List of cassandra servers exposing jolokia read service - servers = ["myuser:mypassword@10.10.10.1:8778","10.10.10.2:8778",":8778"] - ## List of metrics collected on above servers - ## Each metric consists of a jmx path. - ## This will collect all heap memory usage metrics from the jvm and - ## ReadLatency metrics for all keyspaces and tables. - ## "type=Table" in the query works with Cassandra3.0. Older versions might - ## need to use "type=ColumnFamily" - metrics = [ - "/java.lang:type=Memory/HeapMemoryUsage", - "/org.apache.cassandra.metrics:type=Table,keyspace=*,scope=*,name=ReadLatency" - ] -` -} - -func (c *Cassandra) Description() string { - return "Read Cassandra metrics through Jolokia" -} - func (c *Cassandra) getAttr(requestURL *url.URL) (map[string]interface{}, error) { // Create + send request req, err := http.NewRequest("GET", requestURL.String(), nil) diff --git a/plugins/inputs/cassandra/cassandra_sample_config.go b/plugins/inputs/cassandra/cassandra_sample_config.go new file mode 100644 index 000000000..b06286ad4 --- /dev/null +++ b/plugins/inputs/cassandra/cassandra_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cassandra + +func (c *Cassandra) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ceph/ceph.go b/plugins/inputs/ceph/ceph.go index efd61d563..6569b133f 100644 --- a/plugins/inputs/ceph/ceph.go +++ b/plugins/inputs/ceph/ceph.go @@ -42,57 +42,6 @@ type Ceph struct { Log telegraf.Logger `toml:"-"` } -func (c *Ceph) Description() string { - return "Collects performance metrics from the MON, OSD, MDS and RGW nodes in a Ceph storage cluster." -} - -var sampleConfig = ` - ## This is the recommended interval to poll. Too frequent and you will lose - ## data points due to timeouts during rebalancing and recovery - interval = '1m' - - ## All configuration values are optional, defaults are shown below - - ## location of ceph binary - ceph_binary = "/usr/bin/ceph" - - ## directory in which to look for socket files - socket_dir = "/var/run/ceph" - - ## prefix of MON and OSD socket files, used to determine socket type - mon_prefix = "ceph-mon" - osd_prefix = "ceph-osd" - mds_prefix = "ceph-mds" - rgw_prefix = "ceph-client" - - ## suffix used to identify socket files - socket_suffix = "asok" - - ## Ceph user to authenticate as, ceph will search for the corresponding keyring - ## e.g. client.admin.keyring in /etc/ceph, or the explicit path defined in the - ## client section of ceph.conf for example: - ## - ## [client.telegraf] - ## keyring = /etc/ceph/client.telegraf.keyring - ## - ## Consult the ceph documentation for more detail on keyring generation. - ceph_user = "client.admin" - - ## Ceph configuration to use to locate the cluster - ceph_config = "/etc/ceph/ceph.conf" - - ## Whether to gather statistics via the admin socket - gather_admin_socket_stats = true - - ## Whether to gather statistics via ceph commands, requires ceph_user and ceph_config - ## to be specified - gather_cluster_stats = false -` - -func (c *Ceph) SampleConfig() string { - return sampleConfig -} - func (c *Ceph) Gather(acc telegraf.Accumulator) error { if c.GatherAdminSocketStats { if err := c.gatherAdminSocketStats(acc); err != nil { @@ -312,7 +261,11 @@ func (c *Ceph) flatten(data interface{}) []*metric { switch val := data.(type) { case float64: - metrics = []*metric{{make([]string, 0, 1), val}} + metrics = []*metric{ + { + make([]string, 0, 1), val, + }, + } case map[string]interface{}: metrics = make([]*metric, 0, len(val)) for k, v := range val { diff --git a/plugins/inputs/ceph/ceph_sample_config.go b/plugins/inputs/ceph/ceph_sample_config.go new file mode 100644 index 000000000..61cbd1092 --- /dev/null +++ b/plugins/inputs/ceph/ceph_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ceph + +func (c *Ceph) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cgroup/README.md b/plugins/inputs/cgroup/README.md index 4fbb696db..377a92619 100644 --- a/plugins/inputs/cgroup/README.md +++ b/plugins/inputs/cgroup/README.md @@ -42,7 +42,7 @@ All measurements have the `path` tag. ```toml # Read specific statistics per cgroup -# [[inputs.cgroup]] +[[inputs.cgroup]] ## Directories in which to look for files, globs are supported. ## Consider restricting paths to the set of cgroups you really ## want to monitor if you have a large number of cgroups, to avoid diff --git a/plugins/inputs/cgroup/cgroup.go b/plugins/inputs/cgroup/cgroup.go index f3853a9da..d67315186 100644 --- a/plugins/inputs/cgroup/cgroup.go +++ b/plugins/inputs/cgroup/cgroup.go @@ -10,29 +10,6 @@ type CGroup struct { Files []string `toml:"files"` } -var sampleConfig = ` - ## Directories in which to look for files, globs are supported. - ## Consider restricting paths to the set of cgroups you really - ## want to monitor if you have a large number of cgroups, to avoid - ## any cardinality issues. - # paths = [ - # "/sys/fs/cgroup/memory", - # "/sys/fs/cgroup/memory/child1", - # "/sys/fs/cgroup/memory/child2/*", - # ] - ## cgroup stat fields, as file names, globs are supported. - ## these file names are appended to each path from above. - # files = ["memory.*usage*", "memory.limit_in_bytes"] -` - -func (g *CGroup) SampleConfig() string { - return sampleConfig -} - -func (g *CGroup) Description() string { - return "Read specific statistics per cgroup" -} - func init() { inputs.Add("cgroup", func() telegraf.Input { return &CGroup{} }) } diff --git a/plugins/inputs/cgroup/cgroup_sample_config.go b/plugins/inputs/cgroup/cgroup_sample_config.go new file mode 100644 index 000000000..db6f84f22 --- /dev/null +++ b/plugins/inputs/cgroup/cgroup_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cgroup + +func (g *CGroup) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/chrony/chrony.go b/plugins/inputs/chrony/chrony.go index 3fe18e89c..2a3242ca8 100644 --- a/plugins/inputs/chrony/chrony.go +++ b/plugins/inputs/chrony/chrony.go @@ -22,17 +22,6 @@ type Chrony struct { path string } -func (*Chrony) Description() string { - return "Get standard chrony metrics, requires chronyc executable." -} - -func (*Chrony) SampleConfig() string { - return ` - ## If true, chronyc tries to perform a DNS lookup for the time server. - # dns_lookup = false - ` -} - func (c *Chrony) Init() error { var err error c.path, err = exec.LookPath("chronyc") diff --git a/plugins/inputs/chrony/chrony_sample_config.go b/plugins/inputs/chrony/chrony_sample_config.go new file mode 100644 index 000000000..e0fc79ee7 --- /dev/null +++ b/plugins/inputs/chrony/chrony_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package chrony + +func (*Chrony) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cisco_telemetry_mdt/README.md b/plugins/inputs/cisco_telemetry_mdt/README.md index b3e641cc3..2c041ce85 100644 --- a/plugins/inputs/cisco_telemetry_mdt/README.md +++ b/plugins/inputs/cisco_telemetry_mdt/README.md @@ -12,6 +12,7 @@ The TCP dialout transport is supported on IOS XR (32-bit and 64-bit) 6.1.x and l ## Configuration ```toml +# Cisco model-driven telemetry (MDT) input plugin for IOS XR, IOS XE and NX-OS platforms [[inputs.cisco_telemetry_mdt]] ## Telemetry transport can be "tcp" or "grpc". TLS is only supported when ## using the grpc transport. @@ -37,6 +38,7 @@ The TCP dialout transport is supported on IOS XR (32-bit and 64-bit) 6.1.x and l ## Define aliases to map telemetry encoding paths to simple measurement names [inputs.cisco_telemetry_mdt.aliases] ifstats = "ietf-interfaces:interfaces-state/interface/statistics" + ## Define Property Xformation, please refer README and https://pubhub.devnetcloud.com/media/dme-docs-9-3-3/docs/appendix/ for Model details. [inputs.cisco_telemetry_mdt.dmes] # Global Property Xformation. # prop1 = "uint64 to int" diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go index 25b5ec975..0de6ac328 100644 --- a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go @@ -682,44 +682,6 @@ func (c *CiscoTelemetryMDT) Stop() { c.wg.Wait() } -const sampleConfig = ` - ## Telemetry transport can be "tcp" or "grpc". TLS is only supported when - ## using the grpc transport. - transport = "grpc" - - ## Address and port to host telemetry listener - service_address = ":57000" - - ## Enable TLS; grpc transport only. - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## Enable TLS client authentication and define allowed CA certificates; grpc - ## transport only. - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - - ## Define (for certain nested telemetry measurements with embedded tags) which fields are tags - # embedded_tags = ["Cisco-IOS-XR-qos-ma-oper:qos/interface-table/interface/input/service-policy-names/service-policy-instance/statistics/class-stats/class-name"] - - ## Define aliases to map telemetry encoding paths to simple measurement names - [inputs.cisco_telemetry_mdt.aliases] - ifstats = "ietf-interfaces:interfaces-state/interface/statistics" - ##Define Property Xformation, please refer README and https://pubhub.devnetcloud.com/media/dme-docs-9-3-3/docs/appendix/ for Model details. - [inputs.cisco_telemetry_mdt.dmes] - ModTs = "ignore" - CreateTs = "ignore" -` - -// SampleConfig of plugin -func (c *CiscoTelemetryMDT) SampleConfig() string { - return sampleConfig -} - -// Description of plugin -func (c *CiscoTelemetryMDT) Description() string { - return "Cisco model-driven telemetry (MDT) input plugin for IOS XR, IOS XE and NX-OS platforms" -} - // Gather plugin measurements (unused) func (c *CiscoTelemetryMDT) Gather(_ telegraf.Accumulator) error { return nil diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_sample_config.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_sample_config.go new file mode 100644 index 000000000..fb474a507 --- /dev/null +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cisco_telemetry_mdt + +func (c *CiscoTelemetryMDT) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/clickhouse/clickhouse.go b/plugins/inputs/clickhouse/clickhouse.go index bdd4cf473..7973476e9 100644 --- a/plugins/inputs/clickhouse/clickhouse.go +++ b/plugins/inputs/clickhouse/clickhouse.go @@ -21,72 +21,6 @@ import ( var defaultTimeout = 5 * time.Second -var sampleConfig = ` - ## Username for authorization on ClickHouse server - ## example: username = "default" - username = "default" - - ## Password for authorization on ClickHouse server - ## example: password = "super_secret" - - ## HTTP(s) timeout while getting metrics values - ## The timeout includes connection time, any redirects, and reading the response body. - ## example: timeout = 1s - # timeout = 5s - - ## List of servers for metrics scraping - ## metrics scrape via HTTP(s) clickhouse interface - ## https://clickhouse.tech/docs/en/interfaces/http/ - ## example: servers = ["http://127.0.0.1:8123","https://custom-server.mdb.yandexcloud.net"] - servers = ["http://127.0.0.1:8123"] - - ## If "auto_discovery"" is "true" plugin tries to connect to all servers available in the cluster - ## with using same "user:password" described in "user" and "password" parameters - ## and get this server hostname list from "system.clusters" table - ## see - ## - https://clickhouse.tech/docs/en/operations/system_tables/#system-clusters - ## - https://clickhouse.tech/docs/en/operations/server_settings/settings/#server_settings_remote_servers - ## - https://clickhouse.tech/docs/en/operations/table_engines/distributed/ - ## - https://clickhouse.tech/docs/en/operations/table_engines/replication/#creating-replicated-tables - ## example: auto_discovery = false - # auto_discovery = true - - ## Filter cluster names in "system.clusters" when "auto_discovery" is "true" - ## when this filter present then "WHERE cluster IN (...)" filter will apply - ## please use only full cluster names here, regexp and glob filters is not allowed - ## for "/etc/clickhouse-server/config.d/remote.xml" - ## - ## - ## - ## - ## clickhouse-ru-1.local9000 - ## clickhouse-ru-2.local9000 - ## - ## - ## clickhouse-eu-1.local9000 - ## clickhouse-eu-2.local9000 - ## - ## - ## - ## - ## - ## - ## example: cluster_include = ["my-own-cluster"] - # cluster_include = [] - - ## Filter cluster names in "system.clusters" when "auto_discovery" is "true" - ## when this filter present then "WHERE cluster NOT IN (...)" filter will apply - ## example: cluster_exclude = ["my-internal-not-discovered-cluster"] - # cluster_exclude = [] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - type connect struct { Cluster string `json:"cluster"` ShardNum int `json:"shard_num"` @@ -119,16 +53,6 @@ type ClickHouse struct { tls.ClientConfig } -// SampleConfig returns the sample config -func (*ClickHouse) SampleConfig() string { - return sampleConfig -} - -// Description return plugin description -func (*ClickHouse) Description() string { - return "Read metrics from one or many ClickHouse servers" -} - // Start ClickHouse input service func (ch *ClickHouse) Start(telegraf.Accumulator) error { timeout := defaultTimeout diff --git a/plugins/inputs/clickhouse/clickhouse_sample_config.go b/plugins/inputs/clickhouse/clickhouse_sample_config.go new file mode 100644 index 000000000..d6e2a4cce --- /dev/null +++ b/plugins/inputs/clickhouse/clickhouse_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package clickhouse + +func (*ClickHouse) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cloud_pubsub/README.md b/plugins/inputs/cloud_pubsub/README.md index d05fea611..ea688faef 100644 --- a/plugins/inputs/cloud_pubsub/README.md +++ b/plugins/inputs/cloud_pubsub/README.md @@ -6,6 +6,7 @@ and creates metrics using one of the supported [input data formats][]. ## Configuration ```toml +# Read metrics from Google PubSub [[inputs.cloud_pubsub]] ## Required. Name of Google Cloud Platform (GCP) Project that owns ## the given PubSub subscription. diff --git a/plugins/inputs/cloud_pubsub/pubsub.go b/plugins/inputs/cloud_pubsub/cloud_pubsub.go similarity index 68% rename from plugins/inputs/cloud_pubsub/pubsub.go rename to plugins/inputs/cloud_pubsub/cloud_pubsub.go index 806f84f61..1593eaaf0 100644 --- a/plugins/inputs/cloud_pubsub/pubsub.go +++ b/plugins/inputs/cloud_pubsub/cloud_pubsub.go @@ -59,14 +59,6 @@ type PubSub struct { sem semaphore } -func (ps *PubSub) Description() string { - return "Read metrics from Google PubSub" -} - -func (ps *PubSub) SampleConfig() string { - return fmt.Sprintf(sampleConfig, defaultMaxUndeliveredMessages) -} - // Gather does nothing for this service input. func (ps *PubSub) Gather(_ telegraf.Accumulator) error { return nil @@ -293,77 +285,3 @@ func init() { return ps }) } - -const sampleConfig = ` - ## Required. Name of Google Cloud Platform (GCP) Project that owns - ## the given PubSub subscription. - project = "my-project" - - ## Required. Name of PubSub subscription to ingest metrics from. - subscription = "my-subscription" - - ## Required. Data format to consume. - ## Each data format has its own unique set of configuration options. - ## Read more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" - - ## Optional. Filepath for GCP credentials JSON file to authorize calls to - ## PubSub APIs. If not set explicitly, Telegraf will attempt to use - ## Application Default Credentials, which is preferred. - # credentials_file = "path/to/my/creds.json" - - ## Optional. Number of seconds to wait before attempting to restart the - ## PubSub subscription receiver after an unexpected error. - ## If the streaming pull for a PubSub Subscription fails (receiver), - ## the agent attempts to restart receiving messages after this many seconds. - # retry_delay_seconds = 5 - - ## Optional. Maximum byte length of a message to consume. - ## Larger messages are dropped with an error. If less than 0 or unspecified, - ## treated as no limit. - # max_message_len = 1000000 - - ## Optional. Maximum messages to read from PubSub that have not been written - ## to an output. Defaults to %d. - ## For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message contains 10 metrics and the output - ## metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## The following are optional Subscription ReceiveSettings in PubSub. - ## Read more about these values: - ## https://godoc.org/cloud.google.com/go/pubsub#ReceiveSettings - - ## Optional. Maximum number of seconds for which a PubSub subscription - ## should auto-extend the PubSub ACK deadline for each message. If less than - ## 0, auto-extension is disabled. - # max_extension = 0 - - ## Optional. Maximum number of unprocessed messages in PubSub - ## (unacknowledged but not yet expired in PubSub). - ## A value of 0 is treated as the default PubSub value. - ## Negative values will be treated as unlimited. - # max_outstanding_messages = 0 - - ## Optional. Maximum size in bytes of unprocessed messages in PubSub - ## (unacknowledged but not yet expired in PubSub). - ## A value of 0 is treated as the default PubSub value. - ## Negative values will be treated as unlimited. - # max_outstanding_bytes = 0 - - ## Optional. Max number of goroutines a PubSub Subscription receiver can spawn - ## to pull messages from PubSub concurrently. This limit applies to each - ## subscription separately and is treated as the PubSub default if less than - ## 1. Note this setting does not limit the number of messages that can be - ## processed concurrently (use "max_outstanding_messages" instead). - # max_receiver_go_routines = 0 - - ## Optional. If true, Telegraf will attempt to base64 decode the - ## PubSub message data before parsing - # base64_data = false -` diff --git a/plugins/inputs/cloud_pubsub/cloud_pubsub_sample_config.go b/plugins/inputs/cloud_pubsub/cloud_pubsub_sample_config.go new file mode 100644 index 000000000..c07b8e983 --- /dev/null +++ b/plugins/inputs/cloud_pubsub/cloud_pubsub_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cloud_pubsub + +func (ps *PubSub) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cloud_pubsub/pubsub_test.go b/plugins/inputs/cloud_pubsub/cloud_pubsub_test.go similarity index 100% rename from plugins/inputs/cloud_pubsub/pubsub_test.go rename to plugins/inputs/cloud_pubsub/cloud_pubsub_test.go diff --git a/plugins/inputs/cloud_pubsub_push/README.md b/plugins/inputs/cloud_pubsub_push/README.md index 3163d5bb4..b67259e37 100644 --- a/plugins/inputs/cloud_pubsub_push/README.md +++ b/plugins/inputs/cloud_pubsub_push/README.md @@ -14,6 +14,7 @@ Enable mutually authenticated TLS and authorize client connections by signing ce This is a sample configuration for the plugin. ```toml +# Google Cloud Pub/Sub Push HTTP listener [[inputs.cloud_pubsub_push]] ## Address and port to host HTTP listener on service_address = ":8080" diff --git a/plugins/inputs/cloud_pubsub_push/pubsub_push.go b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go similarity index 75% rename from plugins/inputs/cloud_pubsub_push/pubsub_push.go rename to plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go index 48329e1cd..65018276d 100644 --- a/plugins/inputs/cloud_pubsub_push/pubsub_push.go +++ b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push.go @@ -61,64 +61,6 @@ type Payload struct { Subscription string `json:"subscription"` } -const sampleConfig = ` - ## Address and port to host HTTP listener on - service_address = ":8080" - - ## Application secret to verify messages originate from Cloud Pub/Sub - # token = "" - - ## Path to listen to. - # path = "/" - - ## Maximum duration before timing out read of the request - # read_timeout = "10s" - ## Maximum duration before timing out write of the response. This should be set to a value - ## large enough that you can send at least 'metric_batch_size' number of messages within the - ## duration. - # write_timeout = "10s" - - ## Maximum allowed http request body size in bytes. - ## 0 means to use the default of 524,288,00 bytes (500 mebibytes) - # max_body_size = "500MB" - - ## Whether to add the pubsub metadata, such as message attributes and subscription as a tag. - # add_meta = false - - ## Optional. Maximum messages to read from PubSub that have not been written - ## to an output. Defaults to 1000. - ## For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message contains 10 metrics and the output - ## metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## Set one or more allowed client CA certificate file names to - ## enable mutually authenticated TLS connections - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - - ## Add service certificate and key - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - -func (p *PubSubPush) SampleConfig() string { - return sampleConfig -} - -func (p *PubSubPush) Description() string { - return "Google Cloud Pub/Sub Push HTTP listener" -} - func (p *PubSubPush) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push_sample_config.go b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push_sample_config.go new file mode 100644 index 000000000..ecb01a20f --- /dev/null +++ b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cloud_pubsub_push + +func (p *PubSubPush) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cloud_pubsub_push/pubsub_push_test.go b/plugins/inputs/cloud_pubsub_push/cloud_pubsub_push_test.go similarity index 100% rename from plugins/inputs/cloud_pubsub_push/pubsub_push_test.go rename to plugins/inputs/cloud_pubsub_push/cloud_pubsub_push_test.go diff --git a/plugins/inputs/cloudwatch/README.md b/plugins/inputs/cloudwatch/README.md index a904eb1ea..4a9eb0348 100644 --- a/plugins/inputs/cloudwatch/README.md +++ b/plugins/inputs/cloudwatch/README.md @@ -31,14 +31,14 @@ API endpoint. In the following order the plugin will attempt to authenticate. ## 5) environment variables ## 6) shared credentials file ## 7) EC2 Instance Profile - #access_key = "" - #secret_key = "" - #token = "" - #role_arn = "" - #web_identity_token_file = "" - #role_session_name = "" - #profile = "" - #shared_credential_file = "" + # access_key = "" + # secret_key = "" + # token = "" + # role_arn = "" + # web_identity_token_file = "" + # role_session_name = "" + # profile = "" + # shared_credential_file = "" ## Endpoint to make request against, the correct endpoint is automatically ## determined and this option should only be set if you wish to override the diff --git a/plugins/inputs/cloudwatch/cloudwatch.go b/plugins/inputs/cloudwatch/cloudwatch.go index bf0ab65bf..7c0215ebb 100644 --- a/plugins/inputs/cloudwatch/cloudwatch.go +++ b/plugins/inputs/cloudwatch/cloudwatch.go @@ -90,110 +90,6 @@ type cloudwatchClient interface { GetMetricData(context.Context, *cwClient.GetMetricDataInput, ...func(*cwClient.Options)) (*cwClient.GetMetricDataOutput, error) } -// SampleConfig returns the default configuration of the Cloudwatch input plugin. -func (c *CloudWatch) SampleConfig() string { - return ` - ## Amazon Region - region = "us-east-1" - - ## Amazon Credentials - ## Credentials are loaded in the following order - ## 1) Web identity provider credentials via STS if role_arn and web_identity_token_file are specified - ## 2) Assumed credentials via STS if role_arn is specified - ## 3) explicit credentials from 'access_key' and 'secret_key' - ## 4) shared profile from 'profile' - ## 5) environment variables - ## 6) shared credentials file - ## 7) EC2 Instance Profile - # access_key = "" - # secret_key = "" - # token = "" - # role_arn = "" - # web_identity_token_file = "" - # role_session_name = "" - # profile = "" - # shared_credential_file = "" - - ## Endpoint to make request against, the correct endpoint is automatically - ## determined and this option should only be set if you wish to override the - ## default. - ## ex: endpoint_url = "http://localhost:8000" - # endpoint_url = "" - - ## Set http_proxy (telegraf uses the system wide proxy settings if it's is not set) - # http_proxy_url = "http://localhost:8888" - - # The minimum period for Cloudwatch metrics is 1 minute (60s). However not all - # metrics are made available to the 1 minute period. Some are collected at - # 3 minute, 5 minute, or larger intervals. See https://aws.amazon.com/cloudwatch/faqs/#monitoring. - # Note that if a period is configured that is smaller than the minimum for a - # particular metric, that metric will not be returned by the Cloudwatch API - # and will not be collected by Telegraf. - # - ## Requested CloudWatch aggregation Period (required - must be a multiple of 60s) - period = "5m" - - ## Collection Delay (required - must account for metrics availability via CloudWatch API) - delay = "5m" - - ## Recommended: use metric 'interval' that is a multiple of 'period' to avoid - ## gaps or overlap in pulled data - interval = "5m" - - ## Recommended if "delay" and "period" are both within 3 hours of request time. Invalid values will be ignored. - ## Recently Active feature will only poll for CloudWatch ListMetrics values that occurred within the last 3 Hours. - ## If enabled, it will reduce total API usage of the CloudWatch ListMetrics API and require less memory to retain. - ## Do not enable if "period" or "delay" is longer than 3 hours, as it will not return data more than 3 hours old. - ## See https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html - #recently_active = "PT3H" - - ## Configure the TTL for the internal cache of metrics. - # cache_ttl = "1h" - - ## Metric Statistic Namespaces (required) - namespaces = ["AWS/ELB"] - # A single metric statistic namespace that will be appended to namespaces on startup - # namespace = "AWS/ELB" - - ## Maximum requests per second. Note that the global default AWS rate limit is - ## 50 reqs/sec, so if you define multiple namespaces, these should add up to a - ## maximum of 50. - ## See http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html - # ratelimit = 25 - - ## Timeout for http requests made by the cloudwatch client. - # timeout = "5s" - - ## Namespace-wide statistic filters. These allow fewer queries to be made to - ## cloudwatch. - # statistic_include = [ "average", "sum", "minimum", "maximum", sample_count" ] - # statistic_exclude = [] - - ## Metrics to Pull - ## Defaults to all Metrics in Namespace if nothing is provided - ## Refreshes Namespace available metrics every 1h - #[[inputs.cloudwatch.metrics]] - # names = ["Latency", "RequestCount"] - # - # ## Statistic filters for Metric. These allow for retrieving specific - # ## statistics for an individual metric. - # # statistic_include = [ "average", "sum", "minimum", "maximum", sample_count" ] - # # statistic_exclude = [] - # - # ## Dimension filters for Metric. All dimensions defined for the metric names - # ## must be specified in order to retrieve the metric statistics. - # ## 'value' has wildcard / 'glob' matching support such as 'p-*'. - # [[inputs.cloudwatch.metrics.dimensions]] - # name = "LoadBalancerName" - # value = "p-example" -` -} - -// Description returns a one-sentence description on the Cloudwatch input plugin. -func (c *CloudWatch) Description() string { - return "Pull Metric Statistics from Amazon CloudWatch" -} - func (c *CloudWatch) Init() error { if len(c.Namespace) != 0 { c.Namespaces = append(c.Namespaces, c.Namespace) @@ -395,10 +291,12 @@ func getFilteredMetrics(c *CloudWatch) ([]filteredMetric, error) { return nil, err } - fMetrics = []filteredMetric{{ - metrics: metrics, - statFilter: c.statFilter, - }} + fMetrics = []filteredMetric{ + { + metrics: metrics, + statFilter: c.statFilter, + }, + } } c.metricCache = &metricCache{ diff --git a/plugins/inputs/cloudwatch/cloudwatch_sample_config.go b/plugins/inputs/cloudwatch/cloudwatch_sample_config.go new file mode 100644 index 000000000..2e9c84c46 --- /dev/null +++ b/plugins/inputs/cloudwatch/cloudwatch_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cloudwatch + +func (c *CloudWatch) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/conntrack/conntrack.go b/plugins/inputs/conntrack/conntrack.go index d644f7c18..abbc0fc55 100644 --- a/plugins/inputs/conntrack/conntrack.go +++ b/plugins/inputs/conntrack/conntrack.go @@ -47,29 +47,6 @@ func (c *Conntrack) setDefaults() { } } -func (c *Conntrack) Description() string { - return "Collects conntrack stats from the configured directories and files." -} - -var sampleConfig = ` - ## The following defaults would work with multiple versions of conntrack. - ## Note the nf_ and ip_ filename prefixes are mutually exclusive across - ## kernel versions, as are the directory locations. - - ## Superset of filenames to look for within the conntrack dirs. - ## Missing files will be ignored. - files = ["ip_conntrack_count","ip_conntrack_max", - "nf_conntrack_count","nf_conntrack_max"] - - ## Directories to search within for the conntrack files above. - ## Missing directories will be ignored. - dirs = ["/proc/sys/net/ipv4/netfilter","/proc/sys/net/netfilter"] -` - -func (c *Conntrack) SampleConfig() string { - return sampleConfig -} - func (c *Conntrack) Gather(acc telegraf.Accumulator) error { c.setDefaults() diff --git a/plugins/inputs/conntrack/conntrack_sample_config.go b/plugins/inputs/conntrack/conntrack_sample_config.go new file mode 100644 index 000000000..f308c11d5 --- /dev/null +++ b/plugins/inputs/conntrack/conntrack_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package conntrack + +func (c *Conntrack) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/consul/consul.go b/plugins/inputs/consul/consul.go index 431ebcbcb..135526d85 100644 --- a/plugins/inputs/consul/consul.go +++ b/plugins/inputs/consul/consul.go @@ -27,43 +27,6 @@ type Consul struct { client *api.Client } -var sampleConfig = ` - ## Consul server address - # address = "localhost:8500" - - ## URI scheme for the Consul server, one of "http", "https" - # scheme = "http" - - ## Metric version controls the mapping from Consul metrics into - ## Telegraf metrics. - ## - ## example: metric_version = 1; deprecated in 1.15 - ## metric_version = 2; recommended version - # metric_version = 1 - - ## ACL token used in every request - # token = "" - - ## HTTP Basic Authentication username and password. - # username = "" - # password = "" - - ## Data center to query the health checks from - # datacenter = "" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = true - - ## Consul checks' tag splitting - # When tags are formatted like "key:value" with ":" as a delimiter then - # they will be splitted and reported as proper key:value in Telegraf - # tag_delimiter = ":" -` - func (c *Consul) Init() error { if c.MetricVersion != 2 { c.Log.Warnf("Use of deprecated configuration: 'metric_version = 1'; please update to 'metric_version = 2'") @@ -72,14 +35,6 @@ func (c *Consul) Init() error { return nil } -func (c *Consul) Description() string { - return "Gather health check statuses from services registered in Consul" -} - -func (c *Consul) SampleConfig() string { - return sampleConfig -} - func (c *Consul) createAPIClient() (*api.Client, error) { config := api.DefaultConfig() diff --git a/plugins/inputs/consul/consul_sample_config.go b/plugins/inputs/consul/consul_sample_config.go new file mode 100644 index 000000000..38c4c2210 --- /dev/null +++ b/plugins/inputs/consul/consul_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package consul + +func (c *Consul) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/consul_agent/README.md b/plugins/inputs/consul_agent/README.md index 3cefdf2ca..58f5ad530 100644 --- a/plugins/inputs/consul_agent/README.md +++ b/plugins/inputs/consul_agent/README.md @@ -7,6 +7,7 @@ This plugin grabs metrics from a Consul agent. Telegraf may be present in every ## Configuration ```toml +# Read metrics from the Consul Agent API [[inputs.consul_agent]] ## URL for the Consul agent # url = "http://127.0.0.1:8500" @@ -18,7 +19,7 @@ This plugin grabs metrics from a Consul agent. Telegraf may be present in every ## OR # token = "a1234567-40c7-9048-7bae-378687048181" - ## Set response_timeout (default 5 seconds) + ## Set timeout (default 5 seconds) # timeout = "5s" ## Optional TLS Config diff --git a/plugins/inputs/consul_agent/consul_agent.go b/plugins/inputs/consul_agent/consul_agent.go index 80a082c37..d2d20b34d 100644 --- a/plugins/inputs/consul_agent/consul_agent.go +++ b/plugins/inputs/consul_agent/consul_agent.go @@ -31,25 +31,6 @@ type ConsulAgent struct { const timeLayout = "2006-01-02 15:04:05 -0700 MST" -const sampleConfig = ` - ## URL for the Consul agent - # url = "http://127.0.0.1:8500" - - ## Use auth token for authorization. - ## Only one of the options can be set. Leave empty to not use any token. - # token_file = "/path/to/auth/token" - ## OR - # token = "a1234567-40c7-9048-7bae-378687048181" - - ## Set timeout (default 5 seconds) - # timeout = "5s" - - ## Optional TLS Config - # tls_ca = /path/to/cafile - # tls_cert = /path/to/certfile - # tls_key = /path/to/keyfile -` - func init() { inputs.Add("consul_agent", func() telegraf.Input { return &ConsulAgent{ @@ -58,16 +39,6 @@ func init() { }) } -// SampleConfig returns a sample config -func (n *ConsulAgent) SampleConfig() string { - return sampleConfig -} - -// Description returns a description of the plugin -func (n *ConsulAgent) Description() string { - return "Read metrics from the Consul Agent API" -} - func (n *ConsulAgent) Init() error { if n.URL == "" { n.URL = "http://127.0.0.1:8500" diff --git a/plugins/inputs/consul_agent/consul_agent_sample_config.go b/plugins/inputs/consul_agent/consul_agent_sample_config.go new file mode 100644 index 000000000..1c4cf1e38 --- /dev/null +++ b/plugins/inputs/consul_agent/consul_agent_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package consul_agent + +func (n *ConsulAgent) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/couchbase/couchbase.go b/plugins/inputs/couchbase/couchbase.go index f67e75096..2d34a4c6d 100644 --- a/plugins/inputs/couchbase/couchbase.go +++ b/plugins/inputs/couchbase/couchbase.go @@ -26,40 +26,8 @@ type Couchbase struct { tls.ClientConfig } -var sampleConfig = ` - ## specify servers via a url matching: - ## [protocol://][:password]@address[:port] - ## e.g. - ## http://couchbase-0.example.com/ - ## http://admin:secret@couchbase-0.example.com:8091/ - ## - ## If no servers are specified, then localhost is used as the host. - ## If no protocol is specified, HTTP is used. - ## If no port is specified, 8091 is used. - servers = ["http://localhost:8091"] - - ## Filter bucket fields to include only here. - # bucket_stats_included = ["quota_percent_used", "ops_per_sec", "disk_fetches", "item_count", "disk_used", "data_used", "mem_used"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification (defaults to false) - ## If set to false, tls_cert and tls_key are required - # insecure_skip_verify = false -` - var regexpURI = regexp.MustCompile(`(\S+://)?(\S+\:\S+@)`) -func (cb *Couchbase) SampleConfig() string { - return sampleConfig -} - -func (cb *Couchbase) Description() string { - return "Read per-node and per-bucket metrics from Couchbase" -} - // Reads stats from all configured clusters. Accumulates stats. // Returns one of the errors encountered while gathering stats (if any). func (cb *Couchbase) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/couchbase/couchbase_sample_config.go b/plugins/inputs/couchbase/couchbase_sample_config.go new file mode 100644 index 000000000..984cffdcc --- /dev/null +++ b/plugins/inputs/couchbase/couchbase_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package couchbase + +func (cb *Couchbase) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/couchdb/README.md b/plugins/inputs/couchdb/README.md index a7a6a42f9..5e1b3c6df 100644 --- a/plugins/inputs/couchdb/README.md +++ b/plugins/inputs/couchdb/README.md @@ -5,6 +5,7 @@ The CouchDB plugin gathers metrics of CouchDB using [_stats] endpoint. ## Configuration ```toml +# Read CouchDB Stats from one or more servers [[inputs.couchdb]] ## Works with CouchDB stats endpoints out of the box ## Multiple Hosts from which to read CouchDB stats: diff --git a/plugins/inputs/couchdb/couchdb.go b/plugins/inputs/couchdb/couchdb.go index fc165f4cf..b2f30a4cf 100644 --- a/plugins/inputs/couchdb/couchdb.go +++ b/plugins/inputs/couchdb/couchdb.go @@ -88,22 +88,6 @@ type ( } ) -func (*CouchDB) Description() string { - return "Read CouchDB Stats from one or more servers" -} - -func (*CouchDB) SampleConfig() string { - return ` - ## Works with CouchDB stats endpoints out of the box - ## Multiple Hosts from which to read CouchDB stats: - hosts = ["http://localhost:8086/_stats"] - - ## Use HTTP Basic Authentication. - # basic_username = "telegraf" - # basic_password = "p@ssw0rd" -` -} - func (c *CouchDB) Gather(accumulator telegraf.Accumulator) error { var wg sync.WaitGroup for _, u := range c.Hosts { diff --git a/plugins/inputs/couchdb/couchdb_sample_config.go b/plugins/inputs/couchdb/couchdb_sample_config.go new file mode 100644 index 000000000..64cde4bbe --- /dev/null +++ b/plugins/inputs/couchdb/couchdb_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package couchdb + +func (*CouchDB) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/cpu/cpu.go b/plugins/inputs/cpu/cpu.go index 8c22bb923..611902c29 100644 --- a/plugins/inputs/cpu/cpu.go +++ b/plugins/inputs/cpu/cpu.go @@ -29,25 +29,6 @@ func NewCPUStats(ps system.PS) *CPUStats { } } -func (c *CPUStats) Description() string { - return "Read metrics about cpu usage" -} - -var sampleConfig = ` - ## Whether to report per-cpu stats or not - percpu = true - ## Whether to report total system cpu stats or not - totalcpu = true - ## If true, collect raw CPU time metrics - collect_cpu_time = false - ## If true, compute and report the sum of all non-idle CPU states - report_active = false -` - -func (c *CPUStats) SampleConfig() string { - return sampleConfig -} - func (c *CPUStats) Gather(acc telegraf.Accumulator) error { times, err := c.ps.CPUTimes(c.PerCPU, c.TotalCPU) if err != nil { diff --git a/plugins/inputs/cpu/cpu_sample_config.go b/plugins/inputs/cpu/cpu_sample_config.go new file mode 100644 index 000000000..e195f9d83 --- /dev/null +++ b/plugins/inputs/cpu/cpu_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package cpu + +func (c *CPUStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/csgo/csgo.go b/plugins/inputs/csgo/csgo.go index 59d1110ad..1c344d1c3 100644 --- a/plugins/inputs/csgo/csgo.go +++ b/plugins/inputs/csgo/csgo.go @@ -31,25 +31,6 @@ type CSGO struct { Servers [][]string `toml:"servers"` } -func (*CSGO) Description() string { - return "Fetch metrics from a CSGO SRCDS" -} - -var sampleConfig = ` - ## Specify servers using the following format: - ## servers = [ - ## ["ip1:port1", "rcon_password1"], - ## ["ip2:port2", "rcon_password2"], - ## ] - # - ## If no servers are specified, no data will be collected - servers = [] -` - -func (*CSGO) SampleConfig() string { - return sampleConfig -} - func (s *CSGO) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/csgo/csgo_sample_config.go b/plugins/inputs/csgo/csgo_sample_config.go new file mode 100644 index 000000000..2a1603a1a --- /dev/null +++ b/plugins/inputs/csgo/csgo_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package csgo + +func (*CSGO) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/dcos/README.md b/plugins/inputs/dcos/README.md index cd3a0c739..e3d4d9296 100644 --- a/plugins/inputs/dcos/README.md +++ b/plugins/inputs/dcos/README.md @@ -21,6 +21,7 @@ your database. ## Configuration ```toml +# Input plugin for DC/OS metrics [[inputs.dcos]] ## The DC/OS cluster URL. cluster_url = "https://dcos-master-1" diff --git a/plugins/inputs/dcos/dcos.go b/plugins/inputs/dcos/dcos.go index 5712afcfa..05e1e8f09 100644 --- a/plugins/inputs/dcos/dcos.go +++ b/plugins/inputs/dcos/dcos.go @@ -69,57 +69,6 @@ type DCOS struct { appFilter filter.Filter } -func (d *DCOS) Description() string { - return "Input plugin for DC/OS metrics" -} - -var sampleConfig = ` - ## The DC/OS cluster URL. - cluster_url = "https://dcos-ee-master-1" - - ## The ID of the service account. - service_account_id = "telegraf" - ## The private key file for the service account. - service_account_private_key = "/etc/telegraf/telegraf-sa-key.pem" - - ## Path containing login token. If set, will read on every gather. - # token_file = "/home/dcos/.dcos/token" - - ## In all filter options if both include and exclude are empty all items - ## will be collected. Arrays may contain glob patterns. - ## - ## Node IDs to collect metrics from. If a node is excluded, no metrics will - ## be collected for its containers or apps. - # node_include = [] - # node_exclude = [] - ## Container IDs to collect container metrics from. - # container_include = [] - # container_exclude = [] - ## Container IDs to collect app metrics from. - # app_include = [] - # app_exclude = [] - - ## Maximum concurrent connections to the cluster. - # max_connections = 10 - ## Maximum time to receive a response from cluster. - # response_timeout = "20s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## If false, skip chain & host verification - # insecure_skip_verify = true - - ## Recommended filtering to reduce series cardinality. - # [inputs.dcos.tagdrop] - # path = ["/var/lib/mesos/slave/slaves/*"] -` - -func (d *DCOS) SampleConfig() string { - return sampleConfig -} - func (d *DCOS) Gather(acc telegraf.Accumulator) error { err := d.init() if err != nil { diff --git a/plugins/inputs/dcos/dcos_sample_config.go b/plugins/inputs/dcos/dcos_sample_config.go new file mode 100644 index 000000000..91e8fd58d --- /dev/null +++ b/plugins/inputs/dcos/dcos_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package dcos + +func (d *DCOS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/directory_monitor/README.md b/plugins/inputs/directory_monitor/README.md index c4ad4c20e..44257f4f8 100644 --- a/plugins/inputs/directory_monitor/README.md +++ b/plugins/inputs/directory_monitor/README.md @@ -8,6 +8,7 @@ This plugin is intended to read files that are moved or copied to the monitored ## Configuration ```toml +# Ingests files in a directory and then moves them to a target directory. [[inputs.directory_monitor]] ## The directory to monitor and read files from. directory = "" diff --git a/plugins/inputs/directory_monitor/directory_monitor.go b/plugins/inputs/directory_monitor/directory_monitor.go index c5dfa7b78..45cafbe47 100644 --- a/plugins/inputs/directory_monitor/directory_monitor.go +++ b/plugins/inputs/directory_monitor/directory_monitor.go @@ -24,51 +24,6 @@ import ( "github.com/influxdata/telegraf/selfstat" ) -const sampleConfig = ` - ## The directory to monitor and read files from. - directory = "" - # - ## The directory to move finished files to. - finished_directory = "" - # - ## The directory to move files to upon file error. - ## If not provided, erroring files will stay in the monitored directory. - # error_directory = "" - # - ## The amount of time a file is allowed to sit in the directory before it is picked up. - ## This time can generally be low but if you choose to have a very large file written to the directory and it's potentially slow, - ## set this higher so that the plugin will wait until the file is fully copied to the directory. - # directory_duration_threshold = "50ms" - # - ## A list of the only file names to monitor, if necessary. Supports regex. If left blank, all files are ingested. - # files_to_monitor = ["^.*\.csv"] - # - ## A list of files to ignore, if necessary. Supports regex. - # files_to_ignore = [".DS_Store"] - # - ## Maximum lines of the file to process that have not yet be written by the - ## output. For best throughput set to the size of the output's metric_buffer_limit. - ## Warning: setting this number higher than the output's metric_buffer_limit can cause dropped metrics. - # max_buffered_metrics = 10000 - # - ## The maximum amount of file paths to queue up for processing at once, before waiting until files are processed to find more files. - ## Lowering this value will result in *slightly* less memory use, with a potential sacrifice in speed efficiency, if absolutely necessary. - # file_queue_size = 100000 - # - ## Name a tag containing the name of the file the data was parsed from. Leave empty - ## to disable. Cautious when file name variation is high, this can increase the cardinality - ## significantly. Read more about cardinality here: - ## https://docs.influxdata.com/influxdb/cloud/reference/glossary/#series-cardinality - # file_tag = "" - # - ## The dataformat to be read from the files. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - ## NOTE: We currently only support parsing newline-delimited JSON. See the format here: https://github.com/ndjson/ndjson-spec - data_format = "influx" -` - var ( defaultFilesToMonitor = []string{} defaultFilesToIgnore = []string{} @@ -104,14 +59,6 @@ type DirectoryMonitor struct { filesToProcess chan string } -func (monitor *DirectoryMonitor) SampleConfig() string { - return sampleConfig -} - -func (monitor *DirectoryMonitor) Description() string { - return "Ingests files in a directory and then moves them to a target directory." -} - func (monitor *DirectoryMonitor) Gather(_ telegraf.Accumulator) error { // Get all files sitting in the directory. files, err := os.ReadDir(monitor.Directory) diff --git a/plugins/inputs/directory_monitor/directory_monitor_sample_config.go b/plugins/inputs/directory_monitor/directory_monitor_sample_config.go new file mode 100644 index 000000000..1fca93b67 --- /dev/null +++ b/plugins/inputs/directory_monitor/directory_monitor_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package directory_monitor + +func (monitor *DirectoryMonitor) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/disk/README.md b/plugins/inputs/disk/README.md index a055a61c9..91df0101a 100644 --- a/plugins/inputs/disk/README.md +++ b/plugins/inputs/disk/README.md @@ -9,6 +9,7 @@ Note that `used_percent` is calculated by doing `used / (used + free)`, _not_ ## Configuration ```toml +# Read metrics about disk usage by mount point [[inputs.disk]] ## By default stats will be gathered for all mount points. ## Set mount_points will restrict the stats to only the specified mount points. diff --git a/plugins/inputs/disk/disk.go b/plugins/inputs/disk/disk.go index a995d72cc..461f4bdc9 100644 --- a/plugins/inputs/disk/disk.go +++ b/plugins/inputs/disk/disk.go @@ -21,23 +21,6 @@ type DiskStats struct { Log telegraf.Logger `toml:"-"` } -func (ds *DiskStats) Description() string { - return "Read metrics about disk usage by mount point" -} - -var diskSampleConfig = ` - ## By default stats will be gathered for all mount points. - ## Set mount_points will restrict the stats to only the specified mount points. - # mount_points = ["/"] - - ## Ignore mount points by filesystem type. - ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] -` - -func (ds *DiskStats) SampleConfig() string { - return diskSampleConfig -} - func (ds *DiskStats) Init() error { // Legacy support: if len(ds.LegacyMountPoints) != 0 { diff --git a/plugins/inputs/disk/disk_sample_config.go b/plugins/inputs/disk/disk_sample_config.go new file mode 100644 index 000000000..e7be4f911 --- /dev/null +++ b/plugins/inputs/disk/disk_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package disk + +func (ds *DiskStats) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/diskio/README.md b/plugins/inputs/diskio/README.md index 1e99e81fe..9fd0173bc 100644 --- a/plugins/inputs/diskio/README.md +++ b/plugins/inputs/diskio/README.md @@ -10,7 +10,7 @@ The diskio input plugin gathers metrics about disk traffic and timing. ## By default, telegraf will gather stats for all devices including ## disk partitions. ## Setting devices will restrict the stats to the specified devices. - # devices = ["sda", "sdb"] + # devices = ["sda", "sdb", "vd*"] ## Uncomment the following line if you need disk serial numbers. # skip_serial_number = false # diff --git a/plugins/inputs/diskio/diskio.go b/plugins/inputs/diskio/diskio.go index 9458b2af7..ebd7791a2 100644 --- a/plugins/inputs/diskio/diskio.go +++ b/plugins/inputs/diskio/diskio.go @@ -30,42 +30,6 @@ type DiskIO struct { initialized bool } -func (d *DiskIO) Description() string { - return "Read metrics about disk IO by device" -} - -var diskIOsampleConfig = ` - ## By default, telegraf will gather stats for all devices including - ## disk partitions. - ## Setting devices will restrict the stats to the specified devices. - # devices = ["sda", "sdb", "vd*"] - ## Uncomment the following line if you need disk serial numbers. - # skip_serial_number = false - # - ## On systems which support it, device metadata can be added in the form of - ## tags. - ## Currently only Linux is supported via udev properties. You can view - ## available properties for a device by running: - ## 'udevadm info -q property -n /dev/sda' - ## Note: Most, but not all, udev properties can be accessed this way. Properties - ## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH. - # device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"] - # - ## Using the same metadata source as device_tags, you can also customize the - ## name of the device via templates. - ## The 'name_templates' parameter is a list of templates to try and apply to - ## the device. The template may contain variables in the form of '$PROPERTY' or - ## '${PROPERTY}'. The first template which does not contain any variables not - ## present for the device is used as the device name tag. - ## The typical use case is for LVM volumes, to get the VG/LV name instead of - ## the near-meaningless DM-0 name. - # name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"] -` - -func (d *DiskIO) SampleConfig() string { - return diskIOsampleConfig -} - // hasMeta reports whether s contains any special glob characters. func hasMeta(s string) bool { return strings.ContainsAny(s, "*?[") diff --git a/plugins/inputs/diskio/diskio_sample_config.go b/plugins/inputs/diskio/diskio_sample_config.go new file mode 100644 index 000000000..a840e5eef --- /dev/null +++ b/plugins/inputs/diskio/diskio_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package diskio + +func (d *DiskIO) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/disque/README.md b/plugins/inputs/disque/README.md index 2312bd2c8..351ce6759 100644 --- a/plugins/inputs/disque/README.md +++ b/plugins/inputs/disque/README.md @@ -5,6 +5,7 @@ ## Configuration ```toml +# Read metrics from one or many disque servers [[inputs.disque]] ## An array of URI to gather stats about. Specify an ip or hostname ## with optional port and password. diff --git a/plugins/inputs/disque/disque.go b/plugins/inputs/disque/disque.go index 6fa63ec8b..ead29c67d 100644 --- a/plugins/inputs/disque/disque.go +++ b/plugins/inputs/disque/disque.go @@ -21,24 +21,8 @@ type Disque struct { c net.Conn } -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"] -` - var defaultTimeout = 5 * time.Second -func (d *Disque) SampleConfig() string { - return sampleConfig -} - -func (d *Disque) Description() string { - return "Read metrics from one or many disque servers" -} - var Tracking = map[string]string{ "uptime_in_seconds": "uptime", "connected_clients": "clients", diff --git a/plugins/inputs/disque/disque_sample_config.go b/plugins/inputs/disque/disque_sample_config.go new file mode 100644 index 000000000..fc84362b9 --- /dev/null +++ b/plugins/inputs/disque/disque_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package disque + +func (d *Disque) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/dmcache/README.md b/plugins/inputs/dmcache/README.md index bfc30f678..b228b3f02 100644 --- a/plugins/inputs/dmcache/README.md +++ b/plugins/inputs/dmcache/README.md @@ -9,6 +9,7 @@ This plugin requires sudo, that is why you should setup and be sure that the tel ## Configuration ```toml +# Provide a native collection for dmsetup based statistics for dm-cache [[inputs.dmcache]] ## Whether to report per-device stats or not per_device = true diff --git a/plugins/inputs/dmcache/dmcache.go b/plugins/inputs/dmcache/dmcache.go index 25a398194..5871fc6f8 100644 --- a/plugins/inputs/dmcache/dmcache.go +++ b/plugins/inputs/dmcache/dmcache.go @@ -10,19 +10,6 @@ type DMCache struct { getCurrentStatus func() ([]string, error) } -var sampleConfig = ` - ## Whether to report per-device stats or not - per_device = true -` - -func (c *DMCache) SampleConfig() string { - return sampleConfig -} - -func (c *DMCache) Description() string { - return "Provide a native collection for dmsetup based statistics for dm-cache" -} - func init() { inputs.Add("dmcache", func() telegraf.Input { return &DMCache{ diff --git a/plugins/inputs/dmcache/dmcache_sample_config.go b/plugins/inputs/dmcache/dmcache_sample_config.go new file mode 100644 index 000000000..4b10517fc --- /dev/null +++ b/plugins/inputs/dmcache/dmcache_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package dmcache + +func (c *DMCache) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/dns_query/dns_query.go b/plugins/inputs/dns_query/dns_query.go index a3b2f262b..edf406a2c 100644 --- a/plugins/inputs/dns_query/dns_query.go +++ b/plugins/inputs/dns_query/dns_query.go @@ -41,34 +41,6 @@ type DNSQuery struct { Timeout int } -var sampleConfig = ` - ## servers to query - servers = ["8.8.8.8"] - - ## Network is the network protocol name. - # network = "udp" - - ## Domains or subdomains to query. - # domains = ["."] - - ## Query record type. - ## Possible values: A, AAAA, CNAME, MX, NS, PTR, TXT, SOA, SPF, SRV. - # record_type = "A" - - ## Dns server port. - # port = 53 - - ## Query timeout in seconds. - # timeout = 2 -` - -func (d *DNSQuery) SampleConfig() string { - return sampleConfig -} - -func (d *DNSQuery) Description() string { - return "Query given DNS server and gives statistics" -} func (d *DNSQuery) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup d.setDefaultValues() diff --git a/plugins/inputs/dns_query/dns_query_sample_config.go b/plugins/inputs/dns_query/dns_query_sample_config.go new file mode 100644 index 000000000..14e14e350 --- /dev/null +++ b/plugins/inputs/dns_query/dns_query_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package dns_query + +func (d *DNSQuery) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/docker/docker.go b/plugins/inputs/docker/docker.go index d761a5894..d8850dbfc 100644 --- a/plugins/inputs/docker/docker.go +++ b/plugins/inputs/docker/docker.go @@ -83,68 +83,6 @@ var ( now = time.Now ) -var sampleConfig = ` - ## Docker Endpoint - ## To use TCP, set endpoint = "tcp://[ip]:[port]" - ## To use environment variables (ie, docker-machine), set endpoint = "ENV" - endpoint = "unix:///var/run/docker.sock" - - ## Set to true to collect Swarm metrics(desired_replicas, running_replicas) - gather_services = false - - ## Set the source tag for the metrics to the container ID hostname, eg first 12 chars - source_tag = false - - ## Containers to include and exclude. Globs accepted. - ## Note that an empty array for both will include all containers - container_name_include = [] - container_name_exclude = [] - - ## Container states to include and exclude. Globs accepted. - ## When empty only containers in the "running" state will be captured. - ## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] - ## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] - # container_state_include = [] - # container_state_exclude = [] - - ## Timeout for docker list, info, and stats commands - timeout = "5s" - - ## Specifies for which classes a per-device metric should be issued - ## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...) - ## Please note that this setting has no effect if 'perdevice' is set to 'true' - # perdevice_include = ["cpu"] - - ## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice' values. - ## Possible values are 'cpu', 'blkio' and 'network' - ## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin. - ## Please note that this setting has no effect if 'total' is set to 'false' - # total_include = ["cpu", "blkio", "network"] - - ## Which environment variables should we use as a tag - ##tag_env = ["JAVA_HOME", "HEAP_SIZE"] - - ## docker labels to include and exclude as tags. Globs accepted. - ## Note that an empty array for both will include all labels as tags - docker_label_include = [] - docker_label_exclude = [] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -// SampleConfig returns the default Docker TOML configuration. -func (d *Docker) SampleConfig() string { return sampleConfig } - -// Description the metrics returned. -func (d *Docker) Description() string { - return "Read metrics about docker containers" -} - func (d *Docker) Init() error { err := choice.CheckSlice(d.PerDeviceInclude, containerMetricClasses) if err != nil { diff --git a/plugins/inputs/docker/docker_sample_config.go b/plugins/inputs/docker/docker_sample_config.go new file mode 100644 index 000000000..e25737232 --- /dev/null +++ b/plugins/inputs/docker/docker_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package docker + +func (d *Docker) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/docker_log/README.md b/plugins/inputs/docker_log/README.md index 99fbcee05..0faaf962e 100644 --- a/plugins/inputs/docker_log/README.md +++ b/plugins/inputs/docker_log/README.md @@ -15,6 +15,7 @@ The docker plugin uses the [Official Docker Client][] to gather logs from the ## Configuration ```toml +# Read logging output from the Docker engine [[inputs.docker_log]] ## Docker Endpoint ## To use TCP, set endpoint = "tcp://[ip]:[port]" diff --git a/plugins/inputs/docker_log/docker_log.go b/plugins/inputs/docker_log/docker_log.go index 622f9924e..d340f4de2 100644 --- a/plugins/inputs/docker_log/docker_log.go +++ b/plugins/inputs/docker_log/docker_log.go @@ -24,45 +24,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -var sampleConfig = ` - ## Docker Endpoint - ## To use TCP, set endpoint = "tcp://[ip]:[port]" - ## To use environment variables (ie, docker-machine), set endpoint = "ENV" - # endpoint = "unix:///var/run/docker.sock" - - ## When true, container logs are read from the beginning; otherwise - ## reading begins at the end of the log. - # from_beginning = false - - ## Timeout for Docker API calls. - # timeout = "5s" - - ## Containers to include and exclude. Globs accepted. - ## Note that an empty array for both will include all containers - # container_name_include = [] - # container_name_exclude = [] - - ## Container states to include and exclude. Globs accepted. - ## When empty only containers in the "running" state will be captured. - # container_state_include = [] - # container_state_exclude = [] - - ## docker labels to include and exclude as tags. Globs accepted. - ## Note that an empty array for both will include all labels as tags - # docker_label_include = [] - # docker_label_exclude = [] - - ## Set the source tag for the metrics to the container ID hostname, eg first 12 chars - source_tag = false - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - const ( defaultEndpoint = "unix:///var/run/docker.sock" ) @@ -100,14 +61,6 @@ type DockerLogs struct { containerList map[string]context.CancelFunc } -func (d *DockerLogs) Description() string { - return "Read logging output from the Docker engine" -} - -func (d *DockerLogs) SampleConfig() string { - return sampleConfig -} - func (d *DockerLogs) Init() error { var err error if d.Endpoint == "ENV" { diff --git a/plugins/inputs/docker_log/docker_log_sample_config.go b/plugins/inputs/docker_log/docker_log_sample_config.go new file mode 100644 index 000000000..8194558c5 --- /dev/null +++ b/plugins/inputs/docker_log/docker_log_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package docker_log + +func (d *DockerLogs) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/dovecot/dovecot.go b/plugins/inputs/dovecot/dovecot.go index fbc3b7905..86e6c3805 100644 --- a/plugins/inputs/dovecot/dovecot.go +++ b/plugins/inputs/dovecot/dovecot.go @@ -20,34 +20,12 @@ type Dovecot struct { Servers []string } -func (d *Dovecot) Description() string { - return "Read statistics from one or many dovecot servers" -} - -var sampleConfig = ` - ## specify dovecot servers via an address:port list - ## e.g. - ## localhost:24242 - ## - ## If no servers are specified, then localhost is used as the host. - servers = ["localhost:24242"] - - ## Type is one of "user", "domain", "ip", or "global" - type = "global" - - ## Wildcard matches like "*.com". An empty string "" is same as "*" - ## If type = "ip" filters should be - filters = [""] -` - var defaultTimeout = time.Second * time.Duration(5) var validQuery = map[string]bool{ "user": true, "domain": true, "global": true, "ip": true, } -func (d *Dovecot) SampleConfig() string { return sampleConfig } - // Reads stats from all configured servers. func (d *Dovecot) Gather(acc telegraf.Accumulator) error { if !validQuery[d.Type] { diff --git a/plugins/inputs/dovecot/dovecot_sample_config.go b/plugins/inputs/dovecot/dovecot_sample_config.go new file mode 100644 index 000000000..c396dd9d6 --- /dev/null +++ b/plugins/inputs/dovecot/dovecot_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package dovecot + +func (d *Dovecot) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/dpdk/dpdk.go b/plugins/inputs/dpdk/dpdk.go index 261784942..41aaf46df 100644 --- a/plugins/inputs/dpdk/dpdk.go +++ b/plugins/inputs/dpdk/dpdk.go @@ -17,39 +17,6 @@ import ( ) const ( - description = "Reads metrics from DPDK applications using v2 telemetry interface." - sampleConfig = ` - ## Path to DPDK telemetry socket. This shall point to v2 version of DPDK telemetry interface. - # socket_path = "/var/run/dpdk/rte/dpdk_telemetry.v2" - - ## Duration that defines how long the connected socket client will wait for a response before terminating connection. - ## This includes both writing to and reading from socket. Since it's local socket access - ## to a fast packet processing application, the timeout should be sufficient for most users. - ## Setting the value to 0 disables the timeout (not recommended) - # socket_access_timeout = "200ms" - - ## Enables telemetry data collection for selected device types. - ## Adding "ethdev" enables collection of telemetry from DPDK NICs (stats, xstats, link_status). - ## Adding "rawdev" enables collection of telemetry from DPDK Raw Devices (xstats). - # device_types = ["ethdev"] - - ## List of custom, application-specific telemetry commands to query - ## The list of available commands depend on the application deployed. Applications can register their own commands - ## via telemetry library API http://doc.dpdk.org/guides/prog_guide/telemetry_lib.html#registering-commands - ## For e.g. L3 Forwarding with Power Management Sample Application this could be: - ## additional_commands = ["/l3fwd-power/stats"] - # additional_commands = [] - - ## Allows turning off collecting data for individual "ethdev" commands. - ## Remove "/ethdev/link_status" from list to start getting link status metrics. - [inputs.dpdk.ethdev] - exclude_commands = ["/ethdev/link_status"] - - ## When running multiple instances of the plugin it's recommended to add a unique tag to each instance to identify - ## metrics exposed by an instance of DPDK application. This is useful when multiple DPDK apps run on a single host. - ## [inputs.dpdk.tags] - ## dpdk_instance = "my-fwd-app" -` defaultPathToSocket = "/var/run/dpdk/rte/dpdk_telemetry.v2" defaultAccessTimeout = config.Duration(200 * time.Millisecond) maxCommandLength = 56 @@ -88,14 +55,6 @@ func init() { }) } -func (dpdk *dpdk) SampleConfig() string { - return sampleConfig -} - -func (dpdk *dpdk) Description() string { - return description -} - // Performs validation of all parameters from configuration func (dpdk *dpdk) Init() error { if dpdk.SocketPath == "" { diff --git a/plugins/inputs/dpdk/dpdk_sample_config.go b/plugins/inputs/dpdk/dpdk_sample_config.go new file mode 100644 index 000000000..63e76a961 --- /dev/null +++ b/plugins/inputs/dpdk/dpdk_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package dpdk + +func (dpdk *dpdk) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/dpdk/dpdk_test.go b/plugins/inputs/dpdk/dpdk_test.go index 41d2da3d0..ea000f5be 100644 --- a/plugins/inputs/dpdk/dpdk_test.go +++ b/plugins/inputs/dpdk/dpdk_test.go @@ -155,17 +155,6 @@ func Test_validateCommands(t *testing.T) { }) } -func Test_dpdkPluginDescriber(t *testing.T) { - dpdk := dpdk{} - t.Run("sampleConfig function should return value from constant", func(t *testing.T) { - require.Equal(t, sampleConfig, dpdk.SampleConfig()) - }) - - t.Run("description function should return value from constant", func(t *testing.T) { - require.Equal(t, description, dpdk.Description()) - }) -} - func prepareEnvironment() (*mocks.Conn, dpdk, *testutil.Accumulator) { mockConnection := &mocks.Conn{} dpdk := dpdk{ diff --git a/plugins/inputs/ecs/ecs.go b/plugins/inputs/ecs/ecs.go index dfdc24e7a..8ef3a2f88 100644 --- a/plugins/inputs/ecs/ecs.go +++ b/plugins/inputs/ecs/ecs.go @@ -45,43 +45,6 @@ const ( v2Endpoint = "http://169.254.170.2" ) -var sampleConfig = ` - ## ECS metadata url. - ## Metadata v2 API is used if set explicitly. Otherwise, - ## v3 metadata endpoint API is used if available. - # endpoint_url = "" - - ## Containers to include and exclude. Globs accepted. - ## Note that an empty array for both will include all containers - # container_name_include = [] - # container_name_exclude = [] - - ## Container states to include and exclude. Globs accepted. - ## When empty only containers in the "RUNNING" state will be captured. - ## Possible values are "NONE", "PULLED", "CREATED", "RUNNING", - ## "RESOURCES_PROVISIONED", "STOPPED". - # container_status_include = [] - # container_status_exclude = [] - - ## ecs labels to include and exclude as tags. Globs accepted. - ## Note that an empty array for both will include all labels as tags - ecs_label_include = [ "com.amazonaws.ecs.*" ] - ecs_label_exclude = [] - - ## Timeout for queries. - # timeout = "5s" -` - -// Description describes ECS plugin -func (ecs *Ecs) Description() string { - return "Read metrics about docker containers from Fargate/ECS v2, v3 meta endpoints." -} - -// SampleConfig returns the ECS example config -func (ecs *Ecs) SampleConfig() string { - return sampleConfig -} - // Gather is the entrypoint for telegraf metrics collection func (ecs *Ecs) Gather(acc telegraf.Accumulator) error { err := initSetup(ecs) diff --git a/plugins/inputs/ecs/ecs_sample_config.go b/plugins/inputs/ecs/ecs_sample_config.go new file mode 100644 index 000000000..7ea296648 --- /dev/null +++ b/plugins/inputs/ecs/ecs_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ecs + +func (ecs *Ecs) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/elasticsearch/README.md b/plugins/inputs/elasticsearch/README.md index e39bc025e..c29173301 100644 --- a/plugins/inputs/elasticsearch/README.md +++ b/plugins/inputs/elasticsearch/README.md @@ -24,6 +24,7 @@ Note that specific statistics information can change between Elasticsearch versi ## Configuration ```toml +# Read stats from one or more Elasticsearch servers or clusters [[inputs.elasticsearch]] ## specify a list of one or more Elasticsearch servers ## you can add username and password to your url to use basic authentication: @@ -78,7 +79,9 @@ Note that specific statistics information can change between Elasticsearch versi # insecure_skip_verify = false ## Sets the number of most recent indices to return for indices that are configured with a date-stamped suffix. - ## Each 'indices_include' entry ending with a wildcard (*) or glob matching pattern will group together all indices that match it, and ## sort them by the date or number after the wildcard. Metrics then are gathered for only the 'num_most_recent_indices' amount of most ## recent indices. + ## Each 'indices_include' entry ending with a wildcard (*) or glob matching pattern will group together all indices that match it, and + ## sort them by the date or number after the wildcard. Metrics then are gathered for only the 'num_most_recent_indices' amount of most + ## recent indices. # num_most_recent_indices = 0 ``` diff --git a/plugins/inputs/elasticsearch/elasticsearch.go b/plugins/inputs/elasticsearch/elasticsearch.go index 24142ba38..dcb37dac7 100644 --- a/plugins/inputs/elasticsearch/elasticsearch.go +++ b/plugins/inputs/elasticsearch/elasticsearch.go @@ -86,64 +86,6 @@ type indexStat struct { Shards map[string][]interface{} `json:"shards"` } -const sampleConfig = ` - ## specify a list of one or more Elasticsearch servers - # you can add username and password to your url to use basic authentication: - # servers = ["http://user:pass@localhost:9200"] - servers = ["http://localhost:9200"] - - ## Timeout for HTTP requests to the elastic search server(s) - http_timeout = "5s" - - ## When local is true (the default), the node will read only its own stats. - ## Set local to false when you want to read the node stats from all nodes - ## of the cluster. - local = true - - ## Set cluster_health to true when you want to also obtain cluster health stats - cluster_health = false - - ## Adjust cluster_health_level when you want to also obtain detailed health stats - ## The options are - ## - indices (default) - ## - cluster - # cluster_health_level = "indices" - - ## Set cluster_stats to true when you want to also obtain cluster stats. - cluster_stats = false - - ## Only gather cluster_stats from the master node. To work this require local = true - cluster_stats_only_from_master = true - - ## Indices to collect; can be one or more indices names or _all - ## Use of wildcards is allowed. Use a wildcard at the end to retrieve index names that end with a changing value, like a date. - indices_include = ["_all"] - - ## One of "shards", "cluster", "indices" - indices_level = "shards" - - ## node_stats is a list of sub-stats that you want to have gathered. Valid options - ## are "indices", "os", "process", "jvm", "thread_pool", "fs", "transport", "http", - ## "breaker". Per default, all stats are gathered. - # node_stats = ["jvm", "http"] - - ## HTTP Basic Authentication username and password. - # username = "" - # password = "" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Sets the number of most recent indices to return for indices that are configured with a date-stamped suffix. - ## Each 'indices_include' entry ending with a wildcard (*) or glob matching pattern will group together all indices that match it, and sort them - ## by the date or number after the wildcard. Metrics then are gathered for only the 'num_most_recent_indices' amount of most recent indices. - # num_most_recent_indices = 0 -` - // Elasticsearch is a plugin to read stats from one or many Elasticsearch // servers. type Elasticsearch struct { @@ -214,16 +156,6 @@ func mapShardStatusToCode(s string) int { return 0 } -// SampleConfig returns sample configuration for this plugin. -func (e *Elasticsearch) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description. -func (e *Elasticsearch) Description() string { - return "Read stats from one or more Elasticsearch servers or clusters" -} - // Init the plugin. func (e *Elasticsearch) Init() error { // Compile the configured indexes to match for sorting. diff --git a/plugins/inputs/elasticsearch/elasticsearch_sample_config.go b/plugins/inputs/elasticsearch/elasticsearch_sample_config.go new file mode 100644 index 000000000..06f4a20fd --- /dev/null +++ b/plugins/inputs/elasticsearch/elasticsearch_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package elasticsearch + +func (e *Elasticsearch) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/elasticsearch_query/README.md b/plugins/inputs/elasticsearch_query/README.md index 5e90d19e7..67ceff4b5 100755 --- a/plugins/inputs/elasticsearch_query/README.md +++ b/plugins/inputs/elasticsearch_query/README.md @@ -16,6 +16,7 @@ Currently it is known to break on 7.x or greater versions. ## Configuration ```toml +# Derive metrics from aggregating Elasticsearch query results [[inputs.elasticsearch_query]] ## The full HTTP endpoint URL for your Elasticsearch instance ## Multiple urls can be specified as part of the same cluster, diff --git a/plugins/inputs/elasticsearch_query/elasticsearch_query.go b/plugins/inputs/elasticsearch_query/elasticsearch_query.go index 009577573..aa73b09bd 100644 --- a/plugins/inputs/elasticsearch_query/elasticsearch_query.go +++ b/plugins/inputs/elasticsearch_query/elasticsearch_query.go @@ -17,78 +17,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## The full HTTP endpoint URL for your Elasticsearch instance - ## Multiple urls can be specified as part of the same cluster, - ## this means that only ONE of the urls will be written to each interval. - urls = [ "http://node1.es.example.com:9200" ] # required. - - ## Elasticsearch client timeout, defaults to "5s". - # timeout = "5s" - - ## Set to true to ask Elasticsearch a list of all cluster nodes, - ## thus it is not necessary to list all nodes in the urls config option - # enable_sniffer = false - - ## Set the interval to check if the Elasticsearch nodes are available - ## This option is only used if enable_sniffer is also set (0s to disable it) - # health_check_interval = "10s" - - ## HTTP basic authentication details (eg. when using x-pack) - # username = "telegraf" - # password = "mypassword" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - [[inputs.elasticsearch_query.aggregation]] - ## measurement name for the results of the aggregation query - measurement_name = "measurement" - - ## Elasticsearch indexes to query (accept wildcards). - index = "index-*" - - ## The date/time field in the Elasticsearch index (mandatory). - date_field = "@timestamp" - - ## If the field used for the date/time field in Elasticsearch is also using - ## a custom date/time format it may be required to provide the format to - ## correctly parse the field. - ## - ## If using one of the built in elasticsearch formats this is not required. - # date_field_custom_format = "" - - ## Time window to query (eg. "1m" to query documents from last minute). - ## Normally should be set to same as collection interval - query_period = "1m" - - ## Lucene query to filter results - # filter_query = "*" - - ## Fields to aggregate values (must be numeric fields) - # metric_fields = ["metric"] - - ## Aggregation function to use on the metric fields - ## Must be set if 'metric_fields' is set - ## Valid values are: avg, sum, min, max, sum - # metric_function = "avg" - - ## Fields to be used as tags - ## Must be text, non-analyzed fields. Metric aggregations are performed per tag - # tags = ["field.keyword", "field2.keyword"] - - ## Set to true to not ignore documents when the tag(s) above are missing - # include_missing_tag = false - - ## String value of the tag when the tag does not exist - ## Used when include_missing_tag is true - # missing_tag_value = "null" -` - // ElasticsearchQuery struct type ElasticsearchQuery struct { URLs []string `toml:"urls"` @@ -123,16 +51,6 @@ type esAggregation struct { aggregationQueryList []aggregationQueryData } -// SampleConfig returns sample configuration for this plugin. -func (e *ElasticsearchQuery) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description. -func (e *ElasticsearchQuery) Description() string { - return `Derive metrics from aggregating Elasticsearch query results` -} - // Init the plugin. func (e *ElasticsearchQuery) Init() error { if e.URLs == nil { diff --git a/plugins/inputs/elasticsearch_query/elasticsearch_query_sample_config.go b/plugins/inputs/elasticsearch_query/elasticsearch_query_sample_config.go new file mode 100644 index 000000000..c0c5b1357 --- /dev/null +++ b/plugins/inputs/elasticsearch_query/elasticsearch_query_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package elasticsearch_query + +func (e *ElasticsearchQuery) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ethtool/ethtool.go b/plugins/inputs/ethtool/ethtool.go index 256652640..951b5cee9 100644 --- a/plugins/inputs/ethtool/ethtool.go +++ b/plugins/inputs/ethtool/ethtool.go @@ -34,30 +34,4 @@ const ( tagInterface = "interface" tagDriverName = "driver" fieldInterfaceUp = "interface_up" - - sampleConfig = ` - ## List of interfaces to pull metrics for - # interface_include = ["eth0"] - - ## List of interfaces to ignore when pulling metrics. - # interface_exclude = ["eth1"] - - ## Some drivers declare statistics with extra whitespace, different spacing, - ## and mix cases. This list, when enabled, can be used to clean the keys. - ## Here are the current possible normalizations: - ## * snakecase: converts fooBarBaz to foo_bar_baz - ## * trim: removes leading and trailing whitespace - ## * lower: changes all capitalized letters to lowercase - ## * underscore: replaces spaces with underscores - # normalize_keys = ["snakecase", "trim", "lower", "underscore"] -` ) - -func (e *Ethtool) SampleConfig() string { - return sampleConfig -} - -// Description returns a one-sentence description on the Input -func (e *Ethtool) Description() string { - return "Returns ethtool statistics for given interfaces" -} diff --git a/plugins/inputs/ethtool/ethtool_sample_config.go b/plugins/inputs/ethtool/ethtool_sample_config.go new file mode 100644 index 000000000..d3de2fdb9 --- /dev/null +++ b/plugins/inputs/ethtool/ethtool_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ethtool + +func (e *Ethtool) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/eventhub_consumer/README.md b/plugins/inputs/eventhub_consumer/README.md index dc99bd281..c6964b9ec 100644 --- a/plugins/inputs/eventhub_consumer/README.md +++ b/plugins/inputs/eventhub_consumer/README.md @@ -13,6 +13,7 @@ The main focus for development of this plugin is Azure IoT hub: ## Configuration ```toml +# Azure Event Hubs service input plugin [[inputs.eventhub_consumer]] ## The default behavior is to create a new Event Hub client from environment variables. ## This requires one of the following sets of environment variables to be set: diff --git a/plugins/inputs/eventhub_consumer/eventhub_consumer.go b/plugins/inputs/eventhub_consumer/eventhub_consumer.go index 064502b0e..fcc76e1af 100644 --- a/plugins/inputs/eventhub_consumer/eventhub_consumer.go +++ b/plugins/inputs/eventhub_consumer/eventhub_consumer.go @@ -1,4 +1,4 @@ -package eventhub +package eventhub_consumer import ( "context" @@ -63,99 +63,6 @@ type EventHub struct { in chan []telegraf.Metric } -// SampleConfig is provided here -func (*EventHub) SampleConfig() string { - return ` - ## The default behavior is to create a new Event Hub client from environment variables. - ## This requires one of the following sets of environment variables to be set: - ## - ## 1) Expected Environment Variables: - ## - "EVENTHUB_CONNECTION_STRING" - ## - ## 2) Expected Environment Variables: - ## - "EVENTHUB_NAMESPACE" - ## - "EVENTHUB_NAME" - ## - "EVENTHUB_KEY_NAME" - ## - "EVENTHUB_KEY_VALUE" - - ## 3) Expected Environment Variables: - ## - "EVENTHUB_NAMESPACE" - ## - "EVENTHUB_NAME" - ## - "AZURE_TENANT_ID" - ## - "AZURE_CLIENT_ID" - ## - "AZURE_CLIENT_SECRET" - - ## Uncommenting the option below will create an Event Hub client based solely on the connection string. - ## This can either be the associated environment variable or hard coded directly. - ## If this option is uncommented, environment variables will be ignored. - ## Connection string should contain EventHubName (EntityPath) - # connection_string = "" - - ## Set persistence directory to a valid folder to use a file persister instead of an in-memory persister - # persistence_dir = "" - - ## Change the default consumer group - # consumer_group = "" - - ## By default the event hub receives all messages present on the broker, alternative modes can be set below. - ## The timestamp should be in https://github.com/toml-lang/toml#offset-date-time format (RFC 3339). - ## The 3 options below only apply if no valid persister is read from memory or file (e.g. first run). - # from_timestamp = - # latest = true - - ## Set a custom prefetch count for the receiver(s) - # prefetch_count = 1000 - - ## Add an epoch to the receiver(s) - # epoch = 0 - - ## Change to set a custom user agent, "telegraf" is used by default - # user_agent = "telegraf" - - ## To consume from a specific partition, set the partition_ids option. - ## An empty array will result in receiving from all partitions. - # partition_ids = ["0","1"] - - ## Max undelivered messages - # max_undelivered_messages = 1000 - - ## Set either option below to true to use a system property as timestamp. - ## You have the choice between EnqueuedTime and IoTHubEnqueuedTime. - ## It is recommended to use this setting when the data itself has no timestamp. - # enqueued_time_as_ts = true - # iot_hub_enqueued_time_as_ts = true - - ## Tags or fields to create from keys present in the application property bag. - ## These could for example be set by message enrichments in Azure IoT Hub. - # application_property_tags = [] - # application_property_fields = [] - - ## Tag or field name to use for metadata - ## By default all metadata is disabled - # sequence_number_field = "SequenceNumber" - # enqueued_time_field = "EnqueuedTime" - # offset_field = "Offset" - # partition_id_tag = "PartitionID" - # partition_key_tag = "PartitionKey" - # iot_hub_device_connection_id_tag = "IoTHubDeviceConnectionID" - # iot_hub_auth_generation_id_tag = "IoTHubAuthGenerationID" - # iot_hub_connection_auth_method_tag = "IoTHubConnectionAuthMethod" - # iot_hub_connection_module_id_tag = "IoTHubConnectionModuleID" - # iot_hub_enqueued_time_field = "IoTHubEnqueuedTime" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" - ` -} - -// Description of the plugin -func (*EventHub) Description() string { - return "Azure Event Hubs service input plugin" -} - // SetParser sets the parser func (e *EventHub) SetParser(parser parsers.Parser) { e.parser = parser diff --git a/plugins/inputs/eventhub_consumer/eventhub_consumer_sample_config.go b/plugins/inputs/eventhub_consumer/eventhub_consumer_sample_config.go new file mode 100644 index 000000000..bda841e8b --- /dev/null +++ b/plugins/inputs/eventhub_consumer/eventhub_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package eventhub_consumer + +func (*EventHub) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/example/example.go b/plugins/inputs/example/example.go index c8f5992fe..1e61a51d1 100644 --- a/plugins/inputs/example/example.go +++ b/plugins/inputs/example/example.go @@ -32,37 +32,6 @@ type Example struct { count int64 } -// Usually the default (example) configuration is contained in this constant. -// Please use '## '' to denote comments and '# ' to specify default settings and start each line with two spaces. -const sampleConfig = ` - ## Device name used as a tag - ## This is a mandatory option that needs to be set by the user, so we do not - ## comment it. - device_name = "" - - ## Number of fields contained in the output - ## This should be greater than zero and less then ten. - ## Here, two is the default, so we comment the option with the default value shown. - # number_fields = 2 - - ## Enable setting the field(s) to random values - ## By default, the field values are set to zero. - # enable_random = false - - ## Specify a duration allowing time-unit suffixes ('ns','ms', 's', 'm', etc.) - # timeout = "100ms" -` - -// Description will appear directly above the plugin definition in the config file -func (m *Example) Description() string { - return `This is an example plugin` -} - -// SampleConfig will populate the sample configuration portion of the plugin's configuration -func (m *Example) SampleConfig() string { - return sampleConfig -} - // Init can be implemented to do one-time processing stuff like initializing variables func (m *Example) Init() error { // Check your options according to your requirements diff --git a/plugins/inputs/example/example_sample_config.go b/plugins/inputs/example/example_sample_config.go new file mode 100644 index 000000000..a5ca2518f --- /dev/null +++ b/plugins/inputs/example/example_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package example + +func (m *Example) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/exec/README.md b/plugins/inputs/exec/README.md index e682ef4ab..a7266c98f 100644 --- a/plugins/inputs/exec/README.md +++ b/plugins/inputs/exec/README.md @@ -8,6 +8,7 @@ This plugin can be used to poll for custom metrics from any source. ## Configuration ```toml +# Read metrics from one or more commands that can output to stdout [[inputs.exec]] ## Commands array commands = [ diff --git a/plugins/inputs/exec/exec.go b/plugins/inputs/exec/exec.go index e8ba23db4..e0c497d34 100644 --- a/plugins/inputs/exec/exec.go +++ b/plugins/inputs/exec/exec.go @@ -21,27 +21,6 @@ import ( "github.com/influxdata/telegraf/plugins/parsers/nagios" ) -const sampleConfig = ` - ## Commands array - commands = [ - "/tmp/test.sh", - "/usr/bin/mycollector --foo=bar", - "/tmp/collect_*.sh" - ] - - ## Timeout for each command to complete. - timeout = "5s" - - ## measurement name suffix (for separating different commands) - name_suffix = "_mycollector" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - const MaxStderrBytes int = 512 type Exec struct { @@ -166,14 +145,6 @@ func (e *Exec) ProcessCommand(command string, acc telegraf.Accumulator, wg *sync } } -func (e *Exec) SampleConfig() string { - return sampleConfig -} - -func (e *Exec) Description() string { - return "Read metrics from one or more commands that can output to stdout" -} - func (e *Exec) SetParser(parser parsers.Parser) { e.parser = parser } diff --git a/plugins/inputs/exec/exec_sample_config.go b/plugins/inputs/exec/exec_sample_config.go new file mode 100644 index 000000000..9d0d8bbf7 --- /dev/null +++ b/plugins/inputs/exec/exec_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package exec + +func (e *Exec) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/execd/README.md b/plugins/inputs/execd/README.md index c5299713c..42acbc36e 100644 --- a/plugins/inputs/execd/README.md +++ b/plugins/inputs/execd/README.md @@ -16,6 +16,7 @@ STDERR from the process will be relayed to Telegraf as errors in the logs. ## Configuration ```toml +# Run executable as long-running input plugin [[inputs.execd]] ## One program to run as daemon. ## NOTE: process and each argument should each be their own string diff --git a/plugins/inputs/execd/execd.go b/plugins/inputs/execd/execd.go index a55b2f052..afd0214a6 100644 --- a/plugins/inputs/execd/execd.go +++ b/plugins/inputs/execd/execd.go @@ -17,30 +17,6 @@ import ( "github.com/influxdata/telegraf/plugins/parsers/prometheus" ) -const sampleConfig = ` - ## Program to run as daemon - command = ["telegraf-smartctl", "-d", "/dev/sda"] - - ## Define how the process is signaled on each collection interval. - ## Valid values are: - ## "none" : Do not signal anything. - ## The process must output metrics by itself. - ## "STDIN" : Send a newline on STDIN. - ## "SIGHUP" : Send a HUP signal. Not available on Windows. - ## "SIGUSR1" : Send a USR1 signal. Not available on Windows. - ## "SIGUSR2" : Send a USR2 signal. Not available on Windows. - signal = "none" - - ## Delay before the process is restarted after an unexpected termination - restart_delay = "10s" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - type Execd struct { Command []string `toml:"command"` Signal string `toml:"signal"` @@ -52,14 +28,6 @@ type Execd struct { parser parsers.Parser } -func (e *Execd) SampleConfig() string { - return sampleConfig -} - -func (e *Execd) Description() string { - return "Run executable as long-running input plugin" -} - func (e *Execd) SetParser(parser parsers.Parser) { e.parser = parser } diff --git a/plugins/inputs/execd/execd_sample_config.go b/plugins/inputs/execd/execd_sample_config.go new file mode 100644 index 000000000..bc59d8ef3 --- /dev/null +++ b/plugins/inputs/execd/execd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package execd + +func (e *Execd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/fail2ban/fail2ban.go b/plugins/inputs/fail2ban/fail2ban.go index 37afb87b6..7961a473d 100644 --- a/plugins/inputs/fail2ban/fail2ban.go +++ b/plugins/inputs/fail2ban/fail2ban.go @@ -21,11 +21,6 @@ type Fail2ban struct { UseSudo bool } -var sampleConfig = ` - ## Use sudo to run fail2ban-client - use_sudo = false -` - var metricsTargets = []struct { target string field string @@ -40,14 +35,6 @@ var metricsTargets = []struct { }, } -func (f *Fail2ban) Description() string { - return "Read metrics from fail2ban." -} - -func (f *Fail2ban) SampleConfig() string { - return sampleConfig -} - func (f *Fail2ban) Gather(acc telegraf.Accumulator) error { if len(f.path) == 0 { return errors.New("fail2ban-client not found: verify that fail2ban is installed and that fail2ban-client is in your PATH") diff --git a/plugins/inputs/fail2ban/fail2ban_sample_config.go b/plugins/inputs/fail2ban/fail2ban_sample_config.go new file mode 100644 index 000000000..ea8e27d36 --- /dev/null +++ b/plugins/inputs/fail2ban/fail2ban_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package fail2ban + +func (f *Fail2ban) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/fibaro/fibaro.go b/plugins/inputs/fibaro/fibaro.go index b60eecfa8..aa3532868 100644 --- a/plugins/inputs/fibaro/fibaro.go +++ b/plugins/inputs/fibaro/fibaro.go @@ -14,21 +14,6 @@ import ( const defaultTimeout = 5 * time.Second -const sampleConfig = ` - ## Required Fibaro controller address/hostname. - ## Note: at the time of writing this plugin, Fibaro only implemented http - no https available - url = "http://:80" - - ## Required credentials to access the API (http://) - username = "" - password = "" - - ## Amount of time allowed to complete the HTTP request - # timeout = "5s" -` - -const description = "Read devices value(s) from a Fibaro controller" - // Fibaro contains connection information type Fibaro struct { URL string `toml:"url"` @@ -78,12 +63,6 @@ type Devices struct { } `json:"properties"` } -// Description returns a string explaining the purpose of this plugin -func (f *Fibaro) Description() string { return description } - -// SampleConfig returns text explaining how plugin should be configured -func (f *Fibaro) SampleConfig() string { return sampleConfig } - // getJSON connects, authenticates and reads JSON payload returned by Fibaro box func (f *Fibaro) getJSON(path string, dataStruct interface{}) error { var requestURL = f.URL + path diff --git a/plugins/inputs/fibaro/fibaro_sample_config.go b/plugins/inputs/fibaro/fibaro_sample_config.go new file mode 100644 index 000000000..fb556a448 --- /dev/null +++ b/plugins/inputs/fibaro/fibaro_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package fibaro + +func (f *Fibaro) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/file/README.md b/plugins/inputs/file/README.md index 91ed7a8e1..439c9f996 100644 --- a/plugins/inputs/file/README.md +++ b/plugins/inputs/file/README.md @@ -9,11 +9,21 @@ plugin instead. ## Configuration ```toml +# Parse a complete file each interval [[inputs.file]] ## Files to parse each interval. Accept standard unix glob matching rules, ## as well as ** to match recursive files and directories. files = ["/tmp/metrics.out"] + ## Character encoding to use when interpreting the file contents. Invalid + ## characters are replaced using the unicode replacement character. When set + ## to the empty string the data is not decoded to text. + ## ex: character_encoding = "utf-8" + ## character_encoding = "utf-16le" + ## character_encoding = "utf-16be" + ## character_encoding = "" + # character_encoding = "" + ## Data format to consume. ## Each data format has its own unique set of configuration options, read ## more about them here: diff --git a/plugins/inputs/file/file.go b/plugins/inputs/file/file.go index 5670fc34a..0dfd30ab4 100644 --- a/plugins/inputs/file/file.go +++ b/plugins/inputs/file/file.go @@ -23,44 +23,6 @@ type File struct { decoder *encoding.Decoder } -const sampleConfig = ` - ## Files to parse each interval. Accept standard unix glob matching rules, - ## as well as ** to match recursive files and directories. - files = ["/tmp/metrics.out"] - - - ## Name a tag containing the name of the file the data was parsed from. Leave empty - ## to disable. Cautious when file name variation is high, this can increase the cardinality - ## significantly. Read more about cardinality here: - ## https://docs.influxdata.com/influxdb/cloud/reference/glossary/#series-cardinality - # file_tag = "" - # - - ## Character encoding to use when interpreting the file contents. Invalid - ## characters are replaced using the unicode replacement character. When set - ## to the empty string the data is not decoded to text. - ## ex: character_encoding = "utf-8" - ## character_encoding = "utf-16le" - ## character_encoding = "utf-16be" - ## character_encoding = "" - # character_encoding = "" - - ## The dataformat to be read from files - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - -// SampleConfig returns the default configuration of the Input -func (f *File) SampleConfig() string { - return sampleConfig -} - -func (f *File) Description() string { - return "Parse a complete file each interval" -} - func (f *File) Init() error { var err error f.decoder, err = encoding.NewDecoder(f.CharacterEncoding) diff --git a/plugins/inputs/file/file_sample_config.go b/plugins/inputs/file/file_sample_config.go new file mode 100644 index 000000000..aae05dce6 --- /dev/null +++ b/plugins/inputs/file/file_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package file + +func (f *File) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/filecount/README.md b/plugins/inputs/filecount/README.md index 9c0d4d79d..1a56dd5be 100644 --- a/plugins/inputs/filecount/README.md +++ b/plugins/inputs/filecount/README.md @@ -5,11 +5,8 @@ Reports the number and total size of files in specified directories. ## Configuration ```toml +# Count files in a directory [[inputs.filecount]] - ## Directory to gather stats about. - ## deprecated in 1.9; use the directories option - # directory = "/var/cache/apt/archives" - ## Directories to gather stats about. ## This accept standard unit glob matching rules, but with the addition of ## ** as a "super asterisk". ie: diff --git a/plugins/inputs/filecount/filecount.go b/plugins/inputs/filecount/filecount.go index a8e762144..e796a4163 100644 --- a/plugins/inputs/filecount/filecount.go +++ b/plugins/inputs/filecount/filecount.go @@ -13,39 +13,6 @@ import ( "github.com/pkg/errors" ) -const sampleConfig = ` - ## Directories to gather stats about. - ## This accept standard unit glob matching rules, but with the addition of - ## ** as a "super asterisk". ie: - ## /var/log/** -> recursively find all directories in /var/log and count files in each directories - ## /var/log/*/* -> find all directories with a parent dir in /var/log and count files in each directories - ## /var/log -> count all files in /var/log and all of its subdirectories - directories = ["/var/cache/apt/archives"] - - ## Only count files that match the name pattern. Defaults to "*". - name = "*.deb" - - ## Count files in subdirectories. Defaults to true. - recursive = false - - ## Only count regular files. Defaults to true. - regular_only = true - - ## Follow all symlinks while walking the directory tree. Defaults to false. - follow_symlinks = false - - ## Only count files that are at least this size. If size is - ## a negative number, only count files that are smaller than the - ## absolute value of size. Acceptable units are B, KiB, MiB, KB, ... - ## Without quotes and units, interpreted as size in bytes. - size = "0B" - - ## Only count files that have not been touched for at least this - ## duration. If mtime is negative, only count files that have been - ## touched in this duration. Defaults to "0s". - mtime = "0s" -` - type FileCount struct { Directory string `toml:"directory" deprecated:"1.9.0;use 'directories' instead"` Directories []string @@ -61,12 +28,6 @@ type FileCount struct { Log telegraf.Logger } -func (fc *FileCount) Description() string { - return "Count files in a directory" -} - -func (fc *FileCount) SampleConfig() string { return sampleConfig } - type fileFilterFunc func(os.FileInfo) (bool, error) func rejectNilFilters(filters []fileFilterFunc) []fileFilterFunc { diff --git a/plugins/inputs/filecount/filecount_sample_config.go b/plugins/inputs/filecount/filecount_sample_config.go new file mode 100644 index 000000000..f8d3bf3a4 --- /dev/null +++ b/plugins/inputs/filecount/filecount_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package filecount + +func (fc *FileCount) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/filestat/filestat.go b/plugins/inputs/filestat/filestat.go index 7d1143b74..2811786ee 100644 --- a/plugins/inputs/filestat/filestat.go +++ b/plugins/inputs/filestat/filestat.go @@ -11,22 +11,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const sampleConfig = ` - ## Files to gather stats about. - ## These accept standard unix glob matching rules, but with the addition of - ## ** as a "super asterisk". ie: - ## "/var/log/**.log" -> recursively find all .log files in /var/log - ## "/var/log/*/*.log" -> find all .log files with a parent dir in /var/log - ## "/var/log/apache.log" -> just tail the apache log file - ## - ## See https://github.com/gobwas/glob for more examples - ## - files = ["/var/log/**.log"] - - ## If true, read the entire file and calculate an md5 checksum. - md5 = false -` - type FileStat struct { Md5 bool Files []string @@ -50,12 +34,6 @@ func NewFileStat() *FileStat { } } -func (*FileStat) Description() string { - return "Read stats about given file(s)" -} - -func (*FileStat) SampleConfig() string { return sampleConfig } - func (f *FileStat) Gather(acc telegraf.Accumulator) error { var err error diff --git a/plugins/inputs/filestat/filestat_sample_config.go b/plugins/inputs/filestat/filestat_sample_config.go new file mode 100644 index 000000000..c58f483a6 --- /dev/null +++ b/plugins/inputs/filestat/filestat_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package filestat + +func (*FileStat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/fireboard/README.md b/plugins/inputs/fireboard/README.md index 9b118c081..cb5abe835 100644 --- a/plugins/inputs/fireboard/README.md +++ b/plugins/inputs/fireboard/README.md @@ -7,13 +7,16 @@ the [Fireboard REST API](https://docs.fireboard.io/reference/restapi.html). ## Configuration ```toml +# Read real time temps from fireboard.io servers [[inputs.fireboard]] ## Specify auth token for your account auth_token = "invalidAuthToken" ## You can override the fireboard server URL if necessary # url = https://fireboard.io/api/v1/devices.json ## You can set a different http_timeout if you need to - # http_timeout = 4 + ## You should set a string using an number and time indicator + ## for example "12s" for 12 seconds. + # http_timeout = "4s" ``` ### auth_token diff --git a/plugins/inputs/fireboard/fireboard.go b/plugins/inputs/fireboard/fireboard.go index eba11d619..ff197ab7b 100644 --- a/plugins/inputs/fireboard/fireboard.go +++ b/plugins/inputs/fireboard/fireboard.go @@ -45,28 +45,6 @@ type fireboardStats struct { Latesttemps []RTT `json:"latest_temps"` } -// A sample configuration to only gather stats from localhost, default port. -const sampleConfig = ` - ## Specify auth token for your account - auth_token = "invalidAuthToken" - ## You can override the fireboard server URL if necessary - # url = https://fireboard.io/api/v1/devices.json - ## You can set a different http_timeout if you need to - ## You should set a string using an number and time indicator - ## for example "12s" for 12 seconds. - # http_timeout = "4s" -` - -// SampleConfig Returns a sample configuration for the plugin -func (r *Fireboard) SampleConfig() string { - return sampleConfig -} - -// Description Returns a description of the plugin -func (r *Fireboard) Description() string { - return "Read real time temps from fireboard.io servers" -} - // Init the things func (r *Fireboard) Init() error { if len(r.AuthToken) == 0 { diff --git a/plugins/inputs/fireboard/fireboard_sample_config.go b/plugins/inputs/fireboard/fireboard_sample_config.go new file mode 100644 index 000000000..b4ed9bdb0 --- /dev/null +++ b/plugins/inputs/fireboard/fireboard_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package fireboard + +func (r *Fireboard) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/fluentd/fluentd.go b/plugins/inputs/fluentd/fluentd.go index 9ebd1682a..af1c912d1 100644 --- a/plugins/inputs/fluentd/fluentd.go +++ b/plugins/inputs/fluentd/fluentd.go @@ -12,24 +12,7 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -const ( - measurement = "fluentd" - description = "Read metrics exposed by fluentd in_monitor plugin" - sampleConfig = ` - ## This plugin reads information exposed by fluentd (using /api/plugins.json endpoint). - ## - ## Endpoint: - ## - only one URI is allowed - ## - https is not supported - endpoint = "http://localhost:24220/api/plugins.json" - - ## Define which plugins have to be excluded (based on "type" field - e.g. monitor_agent) - exclude = [ - "monitor_agent", - "dummy", - ] -` -) +const measurement = "fluentd" // Fluentd - plugin main structure type Fluentd struct { @@ -70,12 +53,6 @@ func parse(data []byte) (datapointArray []pluginData, err error) { return datapointArray, err } -// Description - display description -func (h *Fluentd) Description() string { return description } - -// SampleConfig - generate configuration -func (h *Fluentd) SampleConfig() string { return sampleConfig } - // Gather - Main code responsible for gathering, processing and creating metrics func (h *Fluentd) Gather(acc telegraf.Accumulator) error { _, err := url.Parse(h.Endpoint) diff --git a/plugins/inputs/fluentd/fluentd_sample_config.go b/plugins/inputs/fluentd/fluentd_sample_config.go new file mode 100644 index 000000000..286cfc268 --- /dev/null +++ b/plugins/inputs/fluentd/fluentd_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package fluentd + +func (h *Fluentd) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/github/README.md b/plugins/inputs/github/README.md index ed47cdfc4..549916ef0 100644 --- a/plugins/inputs/github/README.md +++ b/plugins/inputs/github/README.md @@ -8,6 +8,7 @@ alternative method for collecting repository information. ## Configuration ```toml +# Gather repository information from GitHub hosted repositories. [[inputs.github]] ## List of repositories to monitor repositories = [ diff --git a/plugins/inputs/github/github.go b/plugins/inputs/github/github.go index 31fcc56ae..d78df6477 100644 --- a/plugins/inputs/github/github.go +++ b/plugins/inputs/github/github.go @@ -33,41 +33,6 @@ type GitHub struct { RateRemaining selfstat.Stat } -const sampleConfig = ` - ## List of repositories to monitor. - repositories = [ - "influxdata/telegraf", - "influxdata/influxdb" - ] - - ## Github API access token. Unauthenticated requests are limited to 60 per hour. - # access_token = "" - - ## Github API enterprise url. Github Enterprise accounts must specify their base url. - # enterprise_base_url = "" - - ## Timeout for HTTP requests. - # http_timeout = "5s" - - ## List of additional fields to query. - ## NOTE: Getting those fields might involve issuing additional API-calls, so please - ## make sure you do not exceed the rate-limit of GitHub. - ## - ## Available fields are: - ## - pull-requests -- number of open and closed pull requests (2 API-calls per repository) - # additional_fields = [] -` - -// SampleConfig returns sample configuration for this plugin. -func (g *GitHub) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description. -func (g *GitHub) Description() string { - return "Gather repository information from GitHub hosted repositories." -} - // Create GitHub Client func (g *GitHub) createGitHubClient(ctx context.Context) (*githubLib.Client, error) { httpClient := &http.Client{ diff --git a/plugins/inputs/github/github_sample_config.go b/plugins/inputs/github/github_sample_config.go new file mode 100644 index 000000000..fc01a79c8 --- /dev/null +++ b/plugins/inputs/github/github_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package github + +func (g *GitHub) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/gnmi/README.md b/plugins/inputs/gnmi/README.md index d25e52efa..49f2a160c 100644 --- a/plugins/inputs/gnmi/README.md +++ b/plugins/inputs/gnmi/README.md @@ -9,6 +9,7 @@ It has been optimized to support gNMI telemetry as produced by Cisco IOS XR (64- ## Configuration ```toml +# gNMI telemetry input plugin [[inputs.gnmi]] ## Address and port of the gNMI GRPC server addresses = ["10.49.234.114:57777"] diff --git a/plugins/inputs/gnmi/gnmi.go b/plugins/inputs/gnmi/gnmi.go index 9f83d755d..e4b0fcd3a 100644 --- a/plugins/inputs/gnmi/gnmi.go +++ b/plugins/inputs/gnmi/gnmi.go @@ -538,85 +538,6 @@ func (c *GNMI) Stop() { c.wg.Wait() } -const sampleConfig = ` - ## Address and port of the gNMI GRPC server - addresses = ["10.49.234.114:57777"] - - ## define credentials - username = "cisco" - password = "cisco" - - ## gNMI encoding requested (one of: "proto", "json", "json_ietf", "bytes") - # encoding = "proto" - - ## redial in case of failures after - redial = "10s" - - ## enable client-side TLS and define CA to authenticate the device - # enable_tls = true - # tls_ca = "/etc/telegraf/ca.pem" - # insecure_skip_verify = true - - ## define client-side TLS certificate & key to authenticate to the device - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## gNMI subscription prefix (optional, can usually be left empty) - ## See: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#222-paths - # origin = "" - # prefix = "" - # target = "" - - ## Define additional aliases to map telemetry encoding paths to simple measurement names - #[inputs.gnmi.aliases] - # ifcounters = "openconfig:/interfaces/interface/state/counters" - - [[inputs.gnmi.subscription]] - ## Name of the measurement that will be emitted - name = "ifcounters" - - ## Origin and path of the subscription - ## See: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#222-paths - ## - ## origin usually refers to a (YANG) data model implemented by the device - ## and path to a specific substructure inside it that should be subscribed to (similar to an XPath) - ## YANG models can be found e.g. here: https://github.com/YangModels/yang/tree/master/vendor/cisco/xr - origin = "openconfig-interfaces" - path = "/interfaces/interface/state/counters" - - # Subscription mode (one of: "target_defined", "sample", "on_change") and interval - subscription_mode = "sample" - sample_interval = "10s" - - ## Suppress redundant transmissions when measured values are unchanged - # suppress_redundant = false - - ## If suppression is enabled, send updates at least every X seconds anyway - # heartbeat_interval = "60s" - - #[[inputs.gnmi.subscription]] - # name = "descr" - # origin = "openconfig-interfaces" - # path = "/interfaces/interface/state/description" - # subscription_mode = "on_change" - - ## If tag_only is set, the subscription in question will be utilized to maintain a map of - ## tags to apply to other measurements emitted by the plugin, by matching path keys - ## All fields from the tag-only subscription will be applied as tags to other readings, - ## in the format _. - # tag_only = true -` - -// SampleConfig of plugin -func (c *GNMI) SampleConfig() string { - return sampleConfig -} - -// Description of plugin -func (c *GNMI) Description() string { - return "gNMI telemetry input plugin" -} - // Gather plugin measurements (unused) func (c *GNMI) Gather(_ telegraf.Accumulator) error { return nil diff --git a/plugins/inputs/gnmi/gnmi_sample_config.go b/plugins/inputs/gnmi/gnmi_sample_config.go new file mode 100644 index 000000000..4454fedee --- /dev/null +++ b/plugins/inputs/gnmi/gnmi_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package gnmi + +func (c *GNMI) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/graylog/README.md b/plugins/inputs/graylog/README.md index 29ca3f694..deb822ac5 100644 --- a/plugins/inputs/graylog/README.md +++ b/plugins/inputs/graylog/README.md @@ -18,8 +18,8 @@ Note: if namespace end point specified metrics array will be ignored for that ca [[inputs.graylog]] ## API endpoint, currently supported API: ## - ## - multiple (e.g. `http://:9000/api/system/metrics/multiple`) - ## - namespace (e.g. `http://:9000/api/system/metrics/namespace/{namespace}`) + ## - multiple (e.g. http://:9000/api/system/metrics/multiple) + ## - namespace (e.g. http://:9000/api/system/metrics/namespace/{namespace}) ## ## For namespace endpoint, the metrics array will be ignored for that call. ## Endpoint can contain namespace and multiple type calls. diff --git a/plugins/inputs/graylog/graylog.go b/plugins/inputs/graylog/graylog.go index 0fe9c68d0..34614af89 100644 --- a/plugins/inputs/graylog/graylog.go +++ b/plugins/inputs/graylog/graylog.go @@ -76,53 +76,6 @@ func (c *RealHTTPClient) HTTPClient() *http.Client { return c.client } -var sampleConfig = ` - ## API endpoint, currently supported API: - ## - ## - multiple (e.g. http://:9000/api/system/metrics/multiple) - ## - namespace (e.g. http://:9000/api/system/metrics/namespace/{namespace}) - ## - ## For namespace endpoint, the metrics array will be ignored for that call. - ## Endpoint can contain namespace and multiple type calls. - ## - ## Please check http://[graylog-server-ip]:9000/api/api-browser for full list - ## of endpoints - servers = [ - "http://[graylog-server-ip]:9000/api/system/metrics/multiple", - ] - - ## Set timeout (default 5 seconds) - # timeout = "5s" - - ## Metrics list - ## List of metrics can be found on Graylog webservice documentation. - ## Or by hitting the web service api at: - ## http://[graylog-host]:9000/api/system/metrics - metrics = [ - "jvm.cl.loaded", - "jvm.memory.pools.Metaspace.committed" - ] - - ## Username and password - username = "" - password = "" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (h *GrayLog) SampleConfig() string { - return sampleConfig -} - -func (h *GrayLog) Description() string { - return "Read flattened metrics from one or more GrayLog HTTP endpoints" -} - // Gathers data for all servers. func (h *GrayLog) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/graylog/graylog_sample_config.go b/plugins/inputs/graylog/graylog_sample_config.go new file mode 100644 index 000000000..8191695e1 --- /dev/null +++ b/plugins/inputs/graylog/graylog_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package graylog + +func (h *GrayLog) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/haproxy/haproxy.go b/plugins/inputs/haproxy/haproxy.go index f95dbcc9f..045dc7c79 100644 --- a/plugins/inputs/haproxy/haproxy.go +++ b/plugins/inputs/haproxy/haproxy.go @@ -30,45 +30,6 @@ type haproxy struct { client *http.Client } -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. - ## Make sure you specify the complete path to the stats endpoint - ## including the protocol, ie http://10.10.3.33:1936/haproxy?stats - - ## If no servers are specified, then default to 127.0.0.1:1936/haproxy?stats - servers = ["http://myhaproxy.com:1936/haproxy?stats"] - - ## Credentials for basic HTTP authentication - # username = "admin" - # password = "admin" - - ## You can also use local socket with standard wildcard globbing. - ## Server address not starting with 'http' will be treated as a possible - ## socket, so both examples below are valid. - # servers = ["socket:/run/haproxy/admin.sock", "/run/haproxy/*.sock"] - - ## By default, some of the fields are renamed from what haproxy calls them. - ## Setting this option to true results in the plugin keeping the original - ## field names. - # keep_field_names = false - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -func (h *haproxy) SampleConfig() string { - return sampleConfig -} - -func (h *haproxy) Description() string { - return "Read metrics of haproxy, via socket or csv stats page" -} - // Reads stats from all configured servers accumulates stats. // Returns one of the errors encountered while gather stats (if any). func (h *haproxy) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/haproxy/haproxy_sample_config.go b/plugins/inputs/haproxy/haproxy_sample_config.go new file mode 100644 index 000000000..7381c3ab1 --- /dev/null +++ b/plugins/inputs/haproxy/haproxy_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package haproxy + +func (h *haproxy) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/hddtemp/README.md b/plugins/inputs/hddtemp/README.md index 71801a4eb..0f7523986 100644 --- a/plugins/inputs/hddtemp/README.md +++ b/plugins/inputs/hddtemp/README.md @@ -7,6 +7,7 @@ Hddtemp should be installed and its daemon running. ## Configuration ```toml +# Monitor disks' temperatures using hddtemp [[inputs.hddtemp]] ## By default, telegraf gathers temps data from all disks detected by the ## hddtemp. diff --git a/plugins/inputs/hddtemp/hddtemp.go b/plugins/inputs/hddtemp/hddtemp.go index 2e6d3a53c..82d06f0b4 100644 --- a/plugins/inputs/hddtemp/hddtemp.go +++ b/plugins/inputs/hddtemp/hddtemp.go @@ -20,10 +20,6 @@ type Fetcher interface { Fetch(address string) ([]gohddtemp.Disk, error) } -func (h *HDDTemp) Description() string { - return "Monitor disks' temperatures using hddtemp" -} - var hddtempSampleConfig = ` ## By default, telegraf gathers temps data from all disks detected by the ## hddtemp. @@ -36,10 +32,6 @@ var hddtempSampleConfig = ` # devices = ["sda", "*"] ` -func (h *HDDTemp) SampleConfig() string { - return hddtempSampleConfig -} - func (h *HDDTemp) Gather(acc telegraf.Accumulator) error { if h.fetcher == nil { h.fetcher = gohddtemp.New() diff --git a/plugins/inputs/hddtemp/hddtemp_sample_config.go b/plugins/inputs/hddtemp/hddtemp_sample_config.go new file mode 100644 index 000000000..c1fb51286 --- /dev/null +++ b/plugins/inputs/hddtemp/hddtemp_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package hddtemp + +func (h *HDDTemp) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/http/http.go b/plugins/inputs/http/http.go index 4555d8909..8b8d95fbf 100644 --- a/plugins/inputs/http/http.go +++ b/plugins/inputs/http/http.go @@ -40,82 +40,6 @@ type HTTP struct { parserFunc telegraf.ParserFunc } -var sampleConfig = ` - ## One or more URLs from which to read formatted metrics - urls = [ - "http://localhost/metrics" - ] - - ## HTTP method - # method = "GET" - - ## Optional HTTP headers - # headers = {"X-Special-Header" = "Special-Value"} - - ## Optional file with Bearer token - ## file content is added as an Authorization header - # bearer_token = "/path/to/file" - - ## Optional HTTP Basic Auth Credentials - # username = "username" - # password = "pa$$word" - - ## HTTP entity-body to send with POST/PUT requests. - # body = "" - - ## HTTP Content-Encoding for write request body, can be set to "gzip" to - ## compress body or "identity" to apply no encoding. - # content_encoding = "identity" - - ## HTTP Proxy support - # http_proxy_url = "" - - ## OAuth2 Client Credentials Grant - # client_id = "clientid" - # client_secret = "secret" - # token_url = "https://indentityprovider/oauth2/v1/token" - # scopes = ["urn:opc:idm:__myscopes__"] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Optional Cookie authentication - # cookie_auth_url = "https://localhost/authMe" - # cookie_auth_method = "POST" - # cookie_auth_username = "username" - # cookie_auth_password = "pa$$word" - # cookie_auth_headers = '{"Content-Type": "application/json", "X-MY-HEADER":"hello"}' - # cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}' - ## cookie_auth_renewal not set or set to "0" will auth once and never renew the cookie - # cookie_auth_renewal = "5m" - - ## Amount of time allowed to complete the HTTP request - # timeout = "5s" - - ## List of success status codes - # success_status_codes = [200] - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - # data_format = "influx" -` - -// SampleConfig returns the default configuration of the Input -func (*HTTP) SampleConfig() string { - return sampleConfig -} - -// Description returns a one-sentence description on the Input -func (*HTTP) Description() string { - return "Read formatted metrics from one or more HTTP endpoints" -} - func (h *HTTP) Init() error { ctx := context.Background() client, err := h.HTTPClientConfig.CreateClient(ctx, h.Log) diff --git a/plugins/inputs/http/http_sample_config.go b/plugins/inputs/http/http_sample_config.go new file mode 100644 index 000000000..4edad1626 --- /dev/null +++ b/plugins/inputs/http/http_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package http + +func (*HTTP) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/http_listener_v2/README.md b/plugins/inputs/http_listener_v2/README.md index 9eebb3cd9..e0b68ffef 100644 --- a/plugins/inputs/http_listener_v2/README.md +++ b/plugins/inputs/http_listener_v2/README.md @@ -14,14 +14,11 @@ InfluxDB it is recommended to use [`influxdb_listener`][influxdb_listener] or [` This is a sample configuration for the plugin. ```toml +# Generic HTTP write listener [[inputs.http_listener_v2]] ## Address and port to host HTTP listener on service_address = ":8080" - ## Path to listen to. - ## This option is deprecated and only available for backward-compatibility. Please use paths instead. - # path = "" - ## Paths to listen to. # paths = ["/telegraf"] diff --git a/plugins/inputs/http_listener_v2/http_listener_v2.go b/plugins/inputs/http_listener_v2/http_listener_v2.go index c81f8d02b..8ce14c7b0 100644 --- a/plugins/inputs/http_listener_v2/http_listener_v2.go +++ b/plugins/inputs/http_listener_v2/http_listener_v2.go @@ -67,65 +67,6 @@ type HTTPListenerV2 struct { acc telegraf.Accumulator } -const sampleConfig = ` - ## Address and port to host HTTP listener on - service_address = ":8080" - - ## Paths to listen to. - # paths = ["/telegraf"] - - ## Save path as http_listener_v2_path tag if set to true - # path_tag = false - - ## HTTP methods to accept. - # methods = ["POST", "PUT"] - - ## maximum duration before timing out read of the request - # read_timeout = "10s" - ## maximum duration before timing out write of the response - # write_timeout = "10s" - - ## Maximum allowed http request body size in bytes. - ## 0 means to use the default of 524,288,000 bytes (500 mebibytes) - # max_body_size = "500MB" - - ## Part of the request to consume. Available options are "body" and - ## "query". - # data_source = "body" - - ## Set one or more allowed client CA certificate file names to - ## enable mutually authenticated TLS connections - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - - ## Add service certificate and key - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## Optional username and password to accept for HTTP basic authentication. - ## You probably want to make sure you have TLS configured above for this. - # basic_username = "foobar" - # basic_password = "barfoo" - - ## Optional setting to map http headers into tags - ## If the http header is not present on the request, no corresponding tag will be added - ## If multiple instances of the http header are present, only the first value will be used - # http_header_tags = {"HTTP_HEADER" = "TAG_NAME"} - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - -func (h *HTTPListenerV2) SampleConfig() string { - return sampleConfig -} - -func (h *HTTPListenerV2) Description() string { - return "Generic HTTP write listener" -} - func (h *HTTPListenerV2) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/http_listener_v2/http_listener_v2_sample_config.go b/plugins/inputs/http_listener_v2/http_listener_v2_sample_config.go new file mode 100644 index 000000000..3b2d52077 --- /dev/null +++ b/plugins/inputs/http_listener_v2/http_listener_v2_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package http_listener_v2 + +func (h *HTTPListenerV2) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/http_response/README.md b/plugins/inputs/http_response/README.md index bd800457f..fded2cd91 100644 --- a/plugins/inputs/http_response/README.md +++ b/plugins/inputs/http_response/README.md @@ -7,8 +7,6 @@ This input plugin checks HTTP/HTTPS connections. ```toml # HTTP/HTTPS request given an address a method and a timeout [[inputs.http_response]] - ## address is Deprecated in 1.12, use 'urls' - ## List of urls to query. # urls = ["http://localhost"] diff --git a/plugins/inputs/http_response/http_response.go b/plugins/inputs/http_response/http_response.go index 1b31791fd..1520a82e3 100644 --- a/plugins/inputs/http_response/http_response.go +++ b/plugins/inputs/http_response/http_response.go @@ -59,85 +59,6 @@ type httpClient interface { Do(req *http.Request) (*http.Response, error) } -// Description returns the plugin Description -func (h *HTTPResponse) Description() string { - return "HTTP/HTTPS request given an address a method and a timeout" -} - -var sampleConfig = ` - ## List of urls to query. - # urls = ["http://localhost"] - - ## Set http_proxy (telegraf uses the system wide proxy settings if it's is not set) - # http_proxy = "http://localhost:8888" - - ## Set response_timeout (default 5 seconds) - # response_timeout = "5s" - - ## HTTP Request Method - # method = "GET" - - ## Whether to follow redirects from the server (defaults to false) - # follow_redirects = false - - ## Optional file with Bearer token - ## file content is added as an Authorization header - # bearer_token = "/path/to/file" - - ## Optional HTTP Basic Auth Credentials - # username = "username" - # password = "pa$$word" - - ## Optional HTTP Request Body - # body = ''' - # {'fake':'data'} - # ''' - - ## Optional name of the field that will contain the body of the response. - ## By default it is set to an empty String indicating that the body's content won't be added - # response_body_field = '' - - ## Maximum allowed HTTP response body size in bytes. - ## 0 means to use the default of 32MiB. - ## If the response body size exceeds this limit a "body_read_error" will be raised - # response_body_max_size = "32MiB" - - ## Optional substring or regex match in body of the response (case sensitive) - # response_string_match = "\"service_status\": \"up\"" - # response_string_match = "ok" - # response_string_match = "\".*_status\".?:.?\"up\"" - - ## Expected response status code. - ## The status code of the response is compared to this value. If they match, the field - ## "response_status_code_match" will be 1, otherwise it will be 0. If the - ## expected status code is 0, the check is disabled and the field won't be added. - # response_status_code = 0 - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## HTTP Request Headers (all values must be strings) - # [inputs.http_response.headers] - # Host = "github.com" - - ## Optional setting to map response http headers into tags - ## If the http header is not present on the request, no corresponding tag will be added - ## If multiple instances of the http header are present, only the first value will be used - # http_header_tags = {"HTTP_HEADER" = "TAG_NAME"} - - ## Interface to use when dialing an address - # interface = "eth0" -` - -// SampleConfig returns the plugin SampleConfig -func (h *HTTPResponse) SampleConfig() string { - return sampleConfig -} - // ErrRedirectAttempted indicates that a redirect occurred var ErrRedirectAttempted = errors.New("redirect") diff --git a/plugins/inputs/http_response/http_response_sample_config.go b/plugins/inputs/http_response/http_response_sample_config.go new file mode 100644 index 000000000..9d679aa76 --- /dev/null +++ b/plugins/inputs/http_response/http_response_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package http_response + +func (h *HTTPResponse) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/httpjson/httpjson.go b/plugins/inputs/httpjson/httpjson.go index d7eb66d9d..233f3e1a9 100644 --- a/plugins/inputs/httpjson/httpjson.go +++ b/plugins/inputs/httpjson/httpjson.go @@ -66,55 +66,6 @@ func (c *RealHTTPClient) HTTPClient() *http.Client { return c.client } -var sampleConfig = ` - ## NOTE This plugin only reads numerical measurements, strings and booleans - ## will be ignored. - - ## URL of each server in the service's cluster - servers = [ - "http://localhost:9999/stats/", - "http://localhost:9998/stats/", - ] - ## Set response_timeout (default 5 seconds) - response_timeout = "5s" - - ## HTTP method to use: GET or POST (case-sensitive) - method = "GET" - - ## List of tag names to extract from top-level of JSON server response - # tag_keys = [ - # "my_tag_1", - # "my_tag_2" - # ] - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## HTTP parameters (all values must be strings). For "GET" requests, data - ## will be included in the query. For "POST" requests, data will be included - ## in the request body as "x-www-form-urlencoded". - # [inputs.httpjson.parameters] - # event_type = "cpu_spike" - # threshold = "0.75" - - ## HTTP Headers (all values must be strings) - # [inputs.httpjson.headers] - # X-Auth-Token = "my-xauth-token" - # apiVersion = "v1" -` - -func (h *HTTPJSON) SampleConfig() string { - return sampleConfig -} - -func (h *HTTPJSON) Description() string { - return "Read flattened metrics from one or more JSON HTTP endpoints" -} - // Gathers data for all servers. func (h *HTTPJSON) Gather(acc telegraf.Accumulator) error { var wg sync.WaitGroup diff --git a/plugins/inputs/httpjson/httpjson_sample_config.go b/plugins/inputs/httpjson/httpjson_sample_config.go new file mode 100644 index 000000000..f8a2281b7 --- /dev/null +++ b/plugins/inputs/httpjson/httpjson_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package httpjson + +func (h *HTTPJSON) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/hugepages/hugepages.go b/plugins/inputs/hugepages/hugepages.go index aeef3b7b8..5280932c6 100644 --- a/plugins/inputs/hugepages/hugepages.go +++ b/plugins/inputs/hugepages/hugepages.go @@ -26,14 +26,6 @@ const ( rootHugepages = "root" perNodeHugepages = "per_node" meminfoHugepages = "meminfo" - - hugepagesSampleConfig = ` - ## Supported huge page types: - ## - "root" - based on root huge page control directory: /sys/kernel/mm/hugepages - ## - "per_node" - based on per NUMA node directories: /sys/devices/system/node/node[0-9]*/hugepages - ## - "meminfo" - based on /proc/meminfo file - # types = ["root", "per_node"] -` ) var ( @@ -80,14 +72,6 @@ type Hugepages struct { meminfoPath string } -func (h *Hugepages) Description() string { - return "Gathers huge pages measurements." -} - -func (h *Hugepages) SampleConfig() string { - return hugepagesSampleConfig -} - func (h *Hugepages) Init() error { err := h.parseHugepagesConfig() if err != nil { diff --git a/plugins/inputs/hugepages/hugepages_sample_config.go b/plugins/inputs/hugepages/hugepages_sample_config.go new file mode 100644 index 000000000..d2929fa43 --- /dev/null +++ b/plugins/inputs/hugepages/hugepages_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package hugepages + +func (h *Hugepages) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/icinga2/README.md b/plugins/inputs/icinga2/README.md index c6ecadb0c..da6824e7f 100644 --- a/plugins/inputs/icinga2/README.md +++ b/plugins/inputs/icinga2/README.md @@ -9,7 +9,7 @@ services and hosts. You can read Icinga2's documentation for their remote API ## Configuration ```toml -# Description +# Gather Icinga2 status [[inputs.icinga2]] ## Required Icinga2 server address # server = "https://localhost:5665" diff --git a/plugins/inputs/icinga2/icinga2.go b/plugins/inputs/icinga2/icinga2.go index f56192a7a..5cfb64ed1 100644 --- a/plugins/inputs/icinga2/icinga2.go +++ b/plugins/inputs/icinga2/icinga2.go @@ -50,36 +50,6 @@ var levels = []string{"ok", "warning", "critical", "unknown"} type ObjectType string -var sampleConfig = ` - ## Required Icinga2 server address - # server = "https://localhost:5665" - - ## Required Icinga2 object type ("services" or "hosts") - # object_type = "services" - - ## Credentials for basic HTTP authentication - # username = "admin" - # password = "admin" - - ## Maximum time to receive response. - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = true - ` - -func (i *Icinga2) Description() string { - return "Gather Icinga2 status" -} - -func (i *Icinga2) SampleConfig() string { - return sampleConfig -} - func (i *Icinga2) GatherStatus(acc telegraf.Accumulator, checks []Object) { for _, check := range checks { serverURL, err := url.Parse(i.Server) diff --git a/plugins/inputs/icinga2/icinga2_sample_config.go b/plugins/inputs/icinga2/icinga2_sample_config.go new file mode 100644 index 000000000..214f537a6 --- /dev/null +++ b/plugins/inputs/icinga2/icinga2_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package icinga2 + +func (i *Icinga2) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/infiniband/README.md b/plugins/inputs/infiniband/README.md index 28eed67c7..441e427f3 100644 --- a/plugins/inputs/infiniband/README.md +++ b/plugins/inputs/infiniband/README.md @@ -9,6 +9,7 @@ system. These are the counters that can be found in ## Configuration ```toml +# Gets counters from all InfiniBand cards and ports installed [[inputs.infiniband]] # no configuration ``` diff --git a/plugins/inputs/infiniband/infiniband.go b/plugins/inputs/infiniband/infiniband.go index 8a99bb0e4..dbb6d639b 100644 --- a/plugins/inputs/infiniband/infiniband.go +++ b/plugins/inputs/infiniband/infiniband.go @@ -9,14 +9,3 @@ import ( type Infiniband struct { Log telegraf.Logger `toml:"-"` } - -// Sample configuration for plugin -var InfinibandConfig = `` - -func (i *Infiniband) SampleConfig() string { - return InfinibandConfig -} - -func (i *Infiniband) Description() string { - return "Gets counters from all InfiniBand cards and ports installed" -} diff --git a/plugins/inputs/infiniband/infiniband_sample_config.go b/plugins/inputs/infiniband/infiniband_sample_config.go new file mode 100644 index 000000000..e2dc0ef99 --- /dev/null +++ b/plugins/inputs/infiniband/infiniband_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package infiniband + +func (i *Infiniband) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/influxdb/influxdb.go b/plugins/inputs/influxdb/influxdb.go index b8c028f05..3e07437fa 100644 --- a/plugins/inputs/influxdb/influxdb.go +++ b/plugins/inputs/influxdb/influxdb.go @@ -43,38 +43,6 @@ type InfluxDB struct { client *http.Client } -func (*InfluxDB) Description() string { - return "Read InfluxDB-formatted JSON metrics from one or more HTTP endpoints" -} - -func (*InfluxDB) SampleConfig() string { - return ` - ## Works with InfluxDB debug endpoints out of the box, - ## but other services can use this format too. - ## See the influxdb plugin's README for more details. - - ## Multiple URLs from which to read InfluxDB-formatted JSON - ## Default is "http://localhost:8086/debug/vars". - urls = [ - "http://localhost:8086/debug/vars" - ] - - ## Username and password to send using HTTP Basic Authentication. - # username = "" - # password = "" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## http request & header timeout - timeout = "5s" -` -} - func (i *InfluxDB) Gather(acc telegraf.Accumulator) error { if len(i.URLs) == 0 { i.URLs = []string{"http://localhost:8086/debug/vars"} diff --git a/plugins/inputs/influxdb/influxdb_sample_config.go b/plugins/inputs/influxdb/influxdb_sample_config.go new file mode 100644 index 000000000..e35777fdb --- /dev/null +++ b/plugins/inputs/influxdb/influxdb_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package influxdb + +func (*InfluxDB) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/influxdb_listener/influxdb_listener.go b/plugins/inputs/influxdb_listener/influxdb_listener.go index ec19f10ce..674433db9 100644 --- a/plugins/inputs/influxdb_listener/influxdb_listener.go +++ b/plugins/inputs/influxdb_listener/influxdb_listener.go @@ -63,56 +63,6 @@ type InfluxDBListener struct { mux http.ServeMux } -const sampleConfig = ` - ## Address and port to host InfluxDB listener on - service_address = ":8186" - - ## maximum duration before timing out read of the request - read_timeout = "10s" - ## maximum duration before timing out write of the response - write_timeout = "10s" - - ## Maximum allowed HTTP request body size in bytes. - ## 0 means to use the default of 32MiB. - max_body_size = "32MiB" - - ## Optional tag name used to store the database. - ## If the write has a database in the query string then it will be kept in this tag name. - ## This tag can be used in downstream outputs. - ## The default value of nothing means it will be off and the database will not be recorded. - # database_tag = "" - - ## If set the retention policy specified in the write query will be added as - ## the value of this tag name. - # retention_policy_tag = "" - - ## Set one or more allowed client CA certificate file names to - ## enable mutually authenticated TLS connections - tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - - ## Add service certificate and key - tls_cert = "/etc/telegraf/cert.pem" - tls_key = "/etc/telegraf/key.pem" - - ## Optional username and password to accept for HTTP basic authentication. - ## You probably want to make sure you have TLS configured above for this. - # basic_username = "foobar" - # basic_password = "barfoo" - - ## Influx line protocol parser - ## 'internal' is the default. 'upstream' is a newer parser that is faster - ## and more memory efficient. - # parser_type = "internal" -` - -func (h *InfluxDBListener) SampleConfig() string { - return sampleConfig -} - -func (h *InfluxDBListener) Description() string { - return "Accept metrics over InfluxDB 1.x HTTP API" -} - func (h *InfluxDBListener) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/influxdb_listener/influxdb_listener_sample_config.go b/plugins/inputs/influxdb_listener/influxdb_listener_sample_config.go new file mode 100644 index 000000000..53000d4d2 --- /dev/null +++ b/plugins/inputs/influxdb_listener/influxdb_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package influxdb_listener + +func (h *InfluxDBListener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/influxdb_v2_listener/README.md b/plugins/inputs/influxdb_v2_listener/README.md index dd7a258a3..116a7a937 100644 --- a/plugins/inputs/influxdb_v2_listener/README.md +++ b/plugins/inputs/influxdb_v2_listener/README.md @@ -14,6 +14,7 @@ Telegraf minimum version: Telegraf 1.16.0 ## Configuration ```toml +# Accept metrics over InfluxDB 2.x HTTP API [[inputs.influxdb_v2_listener]] ## Address and port to host InfluxDB listener on ## (Double check the port. Could be 9999 if using OSS Beta) diff --git a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go index 3f8cae777..a393e5e64 100644 --- a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go +++ b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener.go @@ -71,47 +71,6 @@ type InfluxDBV2Listener struct { mux http.ServeMux } -const sampleConfig = ` - ## Address and port to host InfluxDB listener on - ## (Double check the port. Could be 9999 if using OSS Beta) - service_address = ":8086" - - ## Maximum allowed HTTP request body size in bytes. - ## 0 means to use the default of 32MiB. - # max_body_size = "32MiB" - - ## Optional tag to determine the bucket. - ## If the write has a bucket in the query string then it will be kept in this tag name. - ## This tag can be used in downstream outputs. - ## The default value of nothing means it will be off and the database will not be recorded. - # bucket_tag = "" - - ## Set one or more allowed client CA certificate file names to - ## enable mutually authenticated TLS connections - # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] - - ## Add service certificate and key - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## Optional token to accept for HTTP authentication. - ## You probably want to make sure you have TLS configured above for this. - # token = "some-long-shared-secret-token" - - ## Influx line protocol parser - ## 'internal' is the default. 'upstream' is a newer parser that is faster - ## and more memory efficient. - # parser_type = "internal" -` - -func (h *InfluxDBV2Listener) SampleConfig() string { - return sampleConfig -} - -func (h *InfluxDBV2Listener) Description() string { - return "Accept metrics over InfluxDB 2.x HTTP API" -} - func (h *InfluxDBV2Listener) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_sample_config.go b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_sample_config.go new file mode 100644 index 000000000..66b7c1808 --- /dev/null +++ b/plugins/inputs/influxdb_v2_listener/influxdb_v2_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package influxdb_v2_listener + +func (h *InfluxDBV2Listener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/intel_pmu/intel_pmu.go b/plugins/inputs/intel_pmu/intel_pmu.go index 99818c4a7..63072c992 100644 --- a/plugins/inputs/intel_pmu/intel_pmu.go +++ b/plugins/inputs/intel_pmu/intel_pmu.go @@ -111,60 +111,6 @@ type eventWithQuals struct { custom ia.CustomizableEvent } -func (i *IntelPMU) Description() string { - return "Intel Performance Monitoring Unit plugin exposes Intel PMU metrics available through Linux Perf subsystem" -} - -func (i *IntelPMU) SampleConfig() string { - return ` - ## List of filesystem locations of JSON files that contain PMU event definitions. - event_definitions = ["/var/cache/pmu/GenuineIntel-6-55-4-core.json", "/var/cache/pmu/GenuineIntel-6-55-4-uncore.json"] - - ## List of core events measurement entities. There can be more than one core_events sections. - [[inputs.intel_pmu.core_events]] - ## List of events to be counted. Event names shall match names from event_definitions files. - ## Single entry can contain name of the event (case insensitive) augmented with config options and perf modifiers. - ## If absent, all core events from provided event_definitions are counted skipping unresolvable ones. - events = ["INST_RETIRED.ANY", "CPU_CLK_UNHALTED.THREAD_ANY:config1=0x4043200000000k"] - - ## Limits the counting of events to core numbers specified. - ## If absent, events are counted on all cores. - ## Single "0", multiple "0,1,2" and range "0-2" notation is supported for each array element. - ## example: cores = ["0,2", "4", "12-16"] - cores = ["0"] - - ## Indicator that plugin shall attempt to run core_events.events as a single perf group. - ## If absent or set to false, each event is counted individually. Defaults to false. - ## This limits the number of events that can be measured to a maximum of available hardware counters per core. - ## Could vary depending on type of event, use of fixed counters. - # perf_group = false - - ## Optionally set a custom tag value that will be added to every measurement within this events group. - ## Can be applied to any group of events, unrelated to perf_group setting. - # events_tag = "" - - ## List of uncore event measurement entities. There can be more than one uncore_events sections. - [[inputs.intel_pmu.uncore_events]] - ## List of events to be counted. Event names shall match names from event_definitions files. - ## Single entry can contain name of the event (case insensitive) augmented with config options and perf modifiers. - ## If absent, all uncore events from provided event_definitions are counted skipping unresolvable ones. - events = ["UNC_CHA_CLOCKTICKS", "UNC_CHA_TOR_OCCUPANCY.IA_MISS"] - - ## Limits the counting of events to specified sockets. - ## If absent, events are counted on all sockets. - ## Single "0", multiple "0,1" and range "0-1" notation is supported for each array element. - ## example: sockets = ["0-2"] - sockets = ["0"] - - ## Indicator that plugin shall provide an aggregated value for multiple units of same type distributed in an uncore. - ## If absent or set to false, events for each unit are exposed as separate metric. Defaults to false. - # aggregate_uncore_units = false - - ## Optionally set a custom tag value that will be added to every measurement within this events group. - # events_tag = "" -` -} - // Start is required for IntelPMU to implement the telegraf.ServiceInput interface. // Necessary initialization and config checking are done in Init. func (IntelPMU) Start(_ telegraf.Accumulator) error { diff --git a/plugins/inputs/intel_pmu/intel_pmu_sample_config.go b/plugins/inputs/intel_pmu/intel_pmu_sample_config.go new file mode 100644 index 000000000..ce91a4426 --- /dev/null +++ b/plugins/inputs/intel_pmu/intel_pmu_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux && amd64 +// +build linux,amd64 + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package intel_pmu + +func (i *IntelPMU) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/intel_powerstat/intel_powerstat.go b/plugins/inputs/intel_powerstat/intel_powerstat.go index 181e7642d..983909e8c 100644 --- a/plugins/inputs/intel_powerstat/intel_powerstat.go +++ b/plugins/inputs/intel_powerstat/intel_powerstat.go @@ -43,24 +43,6 @@ type PowerStat struct { skipFirstIteration bool } -// Description returns a one-sentence description on the plugin. -func (p *PowerStat) Description() string { - return `Intel PowerStat plugin enables monitoring of platform metrics (power, TDP) and Core metrics like temperature, power and utilization.` -} - -// SampleConfig returns the default configuration of the plugin. -func (p *PowerStat) SampleConfig() string { - return ` - ## All global metrics are always collected by Intel PowerStat plugin. - ## User can choose which per-CPU metrics are monitored by the plugin in cpu_metrics array. - ## Empty array means no per-CPU specific metrics will be collected by the plugin - in this case only platform level - ## telemetry will be exposed by Intel PowerStat plugin. - ## Supported options: - ## "cpu_frequency", "cpu_busy_frequency", "cpu_temperature", "cpu_c1_state_residency", "cpu_c6_state_residency", "cpu_busy_cycles" - # cpu_metrics = [] -` -} - // Init performs one time setup of the plugin. func (p *PowerStat) Init() error { p.parseCPUMetricsConfig() diff --git a/plugins/inputs/intel_powerstat/intel_powerstat_sample_config.go b/plugins/inputs/intel_powerstat/intel_powerstat_sample_config.go new file mode 100644 index 000000000..24bb2d804 --- /dev/null +++ b/plugins/inputs/intel_powerstat/intel_powerstat_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package intel_powerstat + +func (p *PowerStat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/intel_rdt/intel_rdt.go b/plugins/inputs/intel_rdt/intel_rdt.go index d354bb855..a7044428f 100644 --- a/plugins/inputs/intel_rdt/intel_rdt.go +++ b/plugins/inputs/intel_rdt/intel_rdt.go @@ -77,41 +77,6 @@ func (r *IntelRDT) Gather(_ telegraf.Accumulator) error { return nil } -func (r *IntelRDT) Description() string { - return "Intel Resource Director Technology plugin" -} - -func (r *IntelRDT) SampleConfig() string { - return ` - ## Optionally set sampling interval to Nx100ms. - ## This value is propagated to pqos tool. Interval format is defined by pqos itself. - ## If not provided or provided 0, will be set to 10 = 10x100ms = 1s. - # sampling_interval = "10" - - ## Optionally specify the path to pqos executable. - ## If not provided, auto discovery will be performed. - # pqos_path = "/usr/local/bin/pqos" - - ## Optionally specify if IPC and LLC_Misses metrics shouldn't be propagated. - ## If not provided, default value is false. - # shortened_metrics = false - - ## Specify the list of groups of CPU core(s) to be provided as pqos input. - ## Mandatory if processes aren't set and forbidden if processes are specified. - ## e.g. ["0-3", "4,5,6"] or ["1-3,4"] - # cores = ["0-3"] - - ## Specify the list of processes for which Metrics will be collected. - ## Mandatory if cores aren't set and forbidden if cores are specified. - ## e.g. ["qemu", "pmd"] - # processes = ["process"] - - ## Specify if the pqos process should be called with sudo. - ## Mandatory if the telegraf process does not run as root. - # use_sudo = false -` -} - func (r *IntelRDT) Start(acc telegraf.Accumulator) error { ctx, cancel := context.WithCancel(context.Background()) r.cancel = cancel diff --git a/plugins/inputs/intel_rdt/intel_rdt_sample_config.go b/plugins/inputs/intel_rdt/intel_rdt_sample_config.go new file mode 100644 index 000000000..44b33b4b0 --- /dev/null +++ b/plugins/inputs/intel_rdt/intel_rdt_sample_config.go @@ -0,0 +1,11 @@ +//go:build !windows +// +build !windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package intel_rdt + +func (r *IntelRDT) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/internal/internal.go b/plugins/inputs/internal/internal.go index 2eb8b91c9..0106dbc92 100644 --- a/plugins/inputs/internal/internal.go +++ b/plugins/inputs/internal/internal.go @@ -20,19 +20,6 @@ func NewSelf() telegraf.Input { } } -var sampleConfig = ` - ## If true, collect telegraf memory stats. - # collect_memstats = true -` - -func (s *Self) Description() string { - return "Collect statistics about itself" -} - -func (s *Self) SampleConfig() string { - return sampleConfig -} - func (s *Self) Gather(acc telegraf.Accumulator) error { if s.CollectMemstats { m := &runtime.MemStats{} diff --git a/plugins/inputs/internal/internal_sample_config.go b/plugins/inputs/internal/internal_sample_config.go new file mode 100644 index 000000000..2c200e902 --- /dev/null +++ b/plugins/inputs/internal/internal_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package internal + +func (s *Self) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/internet_speed/README.md b/plugins/inputs/internet_speed/README.md index 4600ab473..23c60dd56 100644 --- a/plugins/inputs/internet_speed/README.md +++ b/plugins/inputs/internet_speed/README.md @@ -5,7 +5,7 @@ The `Internet Speed Monitor` collects data about the internet speed on the syste ## Configuration ```toml -# Monitors internet speed in the network +# Monitors internet speed using speedtest.net service [[inputs.internet_speed]] ## Sets if runs file download test # enable_file_download = false diff --git a/plugins/inputs/internet_speed/internet_speed.go b/plugins/inputs/internet_speed/internet_speed.go index bacbe3ce4..a4bce6b74 100644 --- a/plugins/inputs/internet_speed/internet_speed.go +++ b/plugins/inputs/internet_speed/internet_speed.go @@ -17,24 +17,6 @@ type InternetSpeed struct { serverCache *speedtest.Server } -const sampleConfig = ` - ## Sets if runs file download test - # enable_file_download = false - - ## Caches the closest server location - # cache = false -` - -// Description returns information about the plugin. -func (is *InternetSpeed) Description() string { - return "Monitors internet speed using speedtest.net service" -} - -// SampleConfig displays configuration instructions. -func (is *InternetSpeed) SampleConfig() string { - return sampleConfig -} - const measurement = "internet_speed" func (is *InternetSpeed) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/internet_speed/internet_speed_sample_config.go b/plugins/inputs/internet_speed/internet_speed_sample_config.go new file mode 100644 index 000000000..1283d0be7 --- /dev/null +++ b/plugins/inputs/internet_speed/internet_speed_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package internet_speed + +func (is *InternetSpeed) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/interrupts/README.md b/plugins/inputs/interrupts/README.md index 5bd586fa1..712240395 100644 --- a/plugins/inputs/interrupts/README.md +++ b/plugins/inputs/interrupts/README.md @@ -5,6 +5,7 @@ The interrupts plugin gathers metrics about IRQs from `/proc/interrupts` and `/p ## Configuration ```toml +# This plugin gathers interrupts data from /proc/interrupts and /proc/softirqs. [[inputs.interrupts]] ## When set to true, cpu metrics are tagged with the cpu. Otherwise cpu is ## stored as a field. diff --git a/plugins/inputs/interrupts/interrupts.go b/plugins/inputs/interrupts/interrupts.go index d9e9dd287..7d3458a0e 100644 --- a/plugins/inputs/interrupts/interrupts.go +++ b/plugins/inputs/interrupts/interrupts.go @@ -28,28 +28,6 @@ func NewIRQ(id string) *IRQ { return &IRQ{ID: id, Cpus: []int64{}} } -const sampleConfig = ` - ## When set to true, cpu metrics are tagged with the cpu. Otherwise cpu is - ## stored as a field. - ## - ## The default is false for backwards compatibility, and will be changed to - ## true in a future version. It is recommended to set to true on new - ## deployments. - # cpu_as_tag = false - - ## To filter which IRQs to collect, make use of tagpass / tagdrop, i.e. - # [inputs.interrupts.tagdrop] - # irq = [ "NET_RX", "TASKLET" ] -` - -func (s *Interrupts) Description() string { - return "This plugin gathers interrupts data from /proc/interrupts and /proc/softirqs." -} - -func (s *Interrupts) SampleConfig() string { - return sampleConfig -} - func parseInterrupts(r io.Reader) ([]IRQ, error) { var irqs []IRQ var cpucount int diff --git a/plugins/inputs/interrupts/interrupts_sample_config.go b/plugins/inputs/interrupts/interrupts_sample_config.go new file mode 100644 index 000000000..de5477f6e --- /dev/null +++ b/plugins/inputs/interrupts/interrupts_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package interrupts + +func (s *Interrupts) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ipmi_sensor/ipmi.go b/plugins/inputs/ipmi_sensor/ipmi_sensor.go similarity index 82% rename from plugins/inputs/ipmi_sensor/ipmi.go rename to plugins/inputs/ipmi_sensor/ipmi_sensor.go index 801188130..d79b4d522 100644 --- a/plugins/inputs/ipmi_sensor/ipmi.go +++ b/plugins/inputs/ipmi_sensor/ipmi_sensor.go @@ -42,60 +42,6 @@ type Ipmi struct { Log telegraf.Logger `toml:"-"` } -var sampleConfig = ` - ## optionally specify the path to the ipmitool executable - # path = "/usr/bin/ipmitool" - ## - ## Setting 'use_sudo' to true will make use of sudo to run ipmitool. - ## Sudo must be configured to allow the telegraf user to run ipmitool - ## without a password. - # use_sudo = false - ## - ## optionally force session privilege level. Can be CALLBACK, USER, OPERATOR, ADMINISTRATOR - # privilege = "ADMINISTRATOR" - ## - ## optionally specify one or more servers via a url matching - ## [username[:password]@][protocol[(address)]] - ## e.g. - ## root:passwd@lan(127.0.0.1) - ## - ## if no servers are specified, local machine sensor stats will be queried - ## - # servers = ["USERID:PASSW0RD@lan(192.168.1.1)"] - - ## Recommended: use metric 'interval' that is a multiple of 'timeout' to avoid - ## gaps or overlap in pulled data - interval = "30s" - - ## Timeout for the ipmitool command to complete - timeout = "20s" - - ## Schema Version: (Optional, defaults to version 1) - metric_version = 2 - - ## Optionally provide the hex key for the IMPI connection. - # hex_key = "" - - ## If ipmitool should use a cache - ## for me ipmitool runs about 2 to 10 times faster with cache enabled on HP G10 servers (when using ubuntu20.04) - ## the cache file may not work well for you if some sensors come up late - # use_cache = false - - ## Path to the ipmitools cache file (defaults to OS temp dir) - ## The provided path must exist and must be writable - # cache_path = "" -` - -// SampleConfig returns the documentation about the sample configuration -func (m *Ipmi) SampleConfig() string { - return sampleConfig -} - -// Description returns a basic description for the plugin functions -func (m *Ipmi) Description() string { - return "Read metrics from the bare metal servers via IPMI" -} - // Gather is the main execution function for the plugin func (m *Ipmi) Gather(acc telegraf.Accumulator) error { if len(m.Path) == 0 { diff --git a/plugins/inputs/ipmi_sensor/ipmi_sensor_sample_config.go b/plugins/inputs/ipmi_sensor/ipmi_sensor_sample_config.go new file mode 100644 index 000000000..a3ab73163 --- /dev/null +++ b/plugins/inputs/ipmi_sensor/ipmi_sensor_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ipmi_sensor + +func (m *Ipmi) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ipmi_sensor/ipmi_test.go b/plugins/inputs/ipmi_sensor/ipmi_sensor_test.go similarity index 100% rename from plugins/inputs/ipmi_sensor/ipmi_test.go rename to plugins/inputs/ipmi_sensor/ipmi_sensor_test.go diff --git a/plugins/inputs/ipset/README.md b/plugins/inputs/ipset/README.md index 945ed4384..77b840f01 100644 --- a/plugins/inputs/ipset/README.md +++ b/plugins/inputs/ipset/README.md @@ -47,6 +47,7 @@ Defaults!IPSETSAVE !logfile, !syslog, !pam_session ## Configuration ```toml +# Gather packets and bytes counters from Linux ipsets [[inputs.ipset]] ## By default, we only show sets which have already matched at least 1 packet. ## set include_unmatched_sets = true to gather them all. diff --git a/plugins/inputs/ipset/ipset.go b/plugins/inputs/ipset/ipset.go index 68e7db026..6e98ac4c4 100644 --- a/plugins/inputs/ipset/ipset.go +++ b/plugins/inputs/ipset/ipset.go @@ -29,24 +29,6 @@ const measurement = "ipset" var defaultTimeout = config.Duration(time.Second) -// Description returns a short description of the plugin -func (i *Ipset) Description() string { - return "Gather packets and bytes counters from Linux ipsets" -} - -// SampleConfig returns sample configuration options. -func (i *Ipset) SampleConfig() string { - return ` - ## By default, we only show sets which have already matched at least 1 packet. - ## set include_unmatched_sets = true to gather them all. - include_unmatched_sets = false - ## Adjust your sudo settings appropriately if using this option ("sudo ipset save") - use_sudo = false - ## The default timeout of 1s for ipset execution can be overridden here: - # timeout = "1s" -` -} - func (i *Ipset) Init() error { _, err := exec.LookPath("ipset") if err != nil { diff --git a/plugins/inputs/ipset/ipset_sample_config.go b/plugins/inputs/ipset/ipset_sample_config.go new file mode 100644 index 000000000..ce21dcdb3 --- /dev/null +++ b/plugins/inputs/ipset/ipset_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ipset + +func (i *Ipset) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/iptables/README.md b/plugins/inputs/iptables/README.md index c6d14dd2d..015b0b0a8 100644 --- a/plugins/inputs/iptables/README.md +++ b/plugins/inputs/iptables/README.md @@ -52,15 +52,23 @@ Defining multiple instances of this plugin in telegraf.conf can lead to concurre ## Configuration ```toml - # use sudo to run iptables +# Gather packets and bytes throughput from iptables +[[inputs.iptables]] + ## iptables require root access on most systems. + ## Setting 'use_sudo' to true will make use of sudo to run iptables. + ## Users must configure sudo to allow telegraf user to run iptables with no password. + ## iptables can be restricted to only list command "iptables -nvL". use_sudo = false - # run iptables with the lock option + ## Setting 'use_lock' to true runs iptables with the "-w" option. + ## Adjust your sudo settings appropriately if using this option ("iptables -w 5 -nvl") use_lock = false - # Define an alternate executable, such as "ip6tables". Default is "iptables". + ## Define an alternate executable, such as "ip6tables". Default is "iptables". # binary = "ip6tables" - # defines the table to monitor: + ## defines the table to monitor: table = "filter" - # defines the chains to monitor: + ## defines the chains to monitor. + ## NOTE: iptables rules without a comment will not be monitored. + ## Read the plugin documentation for more information. chains = [ "INPUT" ] ``` diff --git a/plugins/inputs/iptables/iptables.go b/plugins/inputs/iptables/iptables.go index 89924b88d..a1160d0ef 100644 --- a/plugins/inputs/iptables/iptables.go +++ b/plugins/inputs/iptables/iptables.go @@ -24,33 +24,6 @@ type Iptables struct { lister chainLister } -// Description returns a short description of the plugin. -func (ipt *Iptables) Description() string { - return "Gather packets and bytes throughput from iptables" -} - -// SampleConfig returns sample configuration options. -func (ipt *Iptables) SampleConfig() string { - return ` - ## iptables require root access on most systems. - ## Setting 'use_sudo' to true will make use of sudo to run iptables. - ## Users must configure sudo to allow telegraf user to run iptables with no password. - ## iptables can be restricted to only list command "iptables -nvL". - use_sudo = false - ## Setting 'use_lock' to true runs iptables with the "-w" option. - ## Adjust your sudo settings appropriately if using this option ("iptables -w 5 -nvl") - use_lock = false - ## Define an alternate executable, such as "ip6tables". Default is "iptables". - # binary = "ip6tables" - ## defines the table to monitor: - table = "filter" - ## defines the chains to monitor. - ## NOTE: iptables rules without a comment will not be monitored. - ## Read the plugin documentation for more information. - chains = [ "INPUT" ] -` -} - // Gather gathers iptables packets and bytes throughput from the configured tables and chains. func (ipt *Iptables) Gather(acc telegraf.Accumulator) error { if ipt.Table == "" || len(ipt.Chains) == 0 { diff --git a/plugins/inputs/iptables/iptables_sample_config.go b/plugins/inputs/iptables/iptables_sample_config.go new file mode 100644 index 000000000..572222aab --- /dev/null +++ b/plugins/inputs/iptables/iptables_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package iptables + +func (ipt *Iptables) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/ipvs/README.md b/plugins/inputs/ipvs/README.md index 2a44c9d15..d195fa57e 100644 --- a/plugins/inputs/ipvs/README.md +++ b/plugins/inputs/ipvs/README.md @@ -8,6 +8,7 @@ metrics about ipvs virtual and real servers. ## Configuration ```toml +# Collect virtual and real server stats from Linux IPVS [[inputs.ipvs]] # no configuration ``` diff --git a/plugins/inputs/ipvs/ipvs.go b/plugins/inputs/ipvs/ipvs.go index 7dea5240a..7e7092995 100644 --- a/plugins/inputs/ipvs/ipvs.go +++ b/plugins/inputs/ipvs/ipvs.go @@ -21,16 +21,6 @@ type IPVS struct { Log telegraf.Logger } -// Description returns a description string -func (i *IPVS) Description() string { - return "Collect virtual and real server stats from Linux IPVS" -} - -// SampleConfig returns a sample configuration for this input plugin -func (i *IPVS) SampleConfig() string { - return `` -} - // Gather gathers the stats func (i *IPVS) Gather(acc telegraf.Accumulator) error { if i.handle == nil { diff --git a/plugins/inputs/ipvs/ipvs_sample_config.go b/plugins/inputs/ipvs/ipvs_sample_config.go new file mode 100644 index 000000000..2f917971a --- /dev/null +++ b/plugins/inputs/ipvs/ipvs_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package ipvs + +func (i *IPVS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/jenkins/README.md b/plugins/inputs/jenkins/README.md index 5726af2cb..9bcc7eb1d 100644 --- a/plugins/inputs/jenkins/README.md +++ b/plugins/inputs/jenkins/README.md @@ -7,6 +7,7 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API ## Configuration ```toml +# Read jobs and cluster metrics from Jenkins instances [[inputs.jenkins]] ## The Jenkins URL in the format "schema://host:port" url = "http://my-jenkins-instance:8080" diff --git a/plugins/inputs/jenkins/jenkins.go b/plugins/inputs/jenkins/jenkins.go index 9543c3ab1..73eb3330a 100644 --- a/plugins/inputs/jenkins/jenkins.go +++ b/plugins/inputs/jenkins/jenkins.go @@ -47,54 +47,6 @@ type Jenkins struct { semaphore chan struct{} } -const sampleConfig = ` - ## The Jenkins URL in the format "schema://host:port" - url = "http://my-jenkins-instance:8080" - # username = "admin" - # password = "admin" - - ## Set response_timeout - response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use SSL but skip chain & host verification - # insecure_skip_verify = false - - ## Optional Max Job Build Age filter - ## Default 1 hour, ignore builds older than max_build_age - # max_build_age = "1h" - - ## Optional Sub Job Depth filter - ## Jenkins can have unlimited layer of sub jobs - ## This config will limit the layers of pulling, default value 0 means - ## unlimited pulling until no more sub jobs - # max_subjob_depth = 0 - - ## Optional Sub Job Per Layer - ## In workflow-multibranch-plugin, each branch will be created as a sub job. - ## This config will limit to call only the lasted branches in each layer, - ## empty will use default value 10 - # max_subjob_per_layer = 10 - - ## Jobs to include or exclude from gathering - ## When using both lists, job_exclude has priority. - ## Wildcards are supported: [ "jobA/*", "jobB/subjob1/*"] - # job_include = [ "*" ] - # job_exclude = [ ] - - ## Nodes to include or exclude from gathering - ## When using both lists, node_exclude has priority. - # node_include = [ "*" ] - # node_exclude = [ ] - - ## Worker pool for jenkins plugin only - ## Empty this field will use default value 5 - # max_connections = 5 -` - // measurement const ( measurementJenkins = "jenkins" @@ -102,16 +54,6 @@ const ( measurementJob = "jenkins_job" ) -// SampleConfig implements telegraf.Input interface -func (j *Jenkins) SampleConfig() string { - return sampleConfig -} - -// Description implements telegraf.Input interface -func (j *Jenkins) Description() string { - return "Read jobs and cluster metrics from Jenkins instances" -} - // Gather implements telegraf.Input interface func (j *Jenkins) Gather(acc telegraf.Accumulator) error { if j.client == nil { diff --git a/plugins/inputs/jenkins/jenkins_sample_config.go b/plugins/inputs/jenkins/jenkins_sample_config.go new file mode 100644 index 000000000..b1edb6b8a --- /dev/null +++ b/plugins/inputs/jenkins/jenkins_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package jenkins + +func (j *Jenkins) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/jolokia/jolokia.go b/plugins/inputs/jolokia/jolokia.go index af5e3de28..d0cac7d0b 100644 --- a/plugins/inputs/jolokia/jolokia.go +++ b/plugins/inputs/jolokia/jolokia.go @@ -59,81 +59,6 @@ type Jolokia struct { Log telegraf.Logger `toml:"-"` } -const sampleConfig = ` - # DEPRECATED: the jolokia plugin has been deprecated in favor of the - # jolokia2 plugin - # see https://github.com/influxdata/telegraf/tree/master/plugins/inputs/jolokia2 - - ## This is the context root used to compose the jolokia url - ## NOTE that Jolokia requires a trailing slash at the end of the context root - ## NOTE that your jolokia security policy must allow for POST requests. - context = "/jolokia/" - - ## This specifies the mode used - # mode = "proxy" - # - ## When in proxy mode this section is used to specify further - ## proxy address configurations. - ## Remember to change host address to fit your environment. - # [inputs.jolokia.proxy] - # host = "127.0.0.1" - # port = "8080" - - ## Optional http timeouts - ## - ## response_header_timeout, if non-zero, specifies the amount of time to wait - ## for a server's response headers after fully writing the request. - # response_header_timeout = "3s" - ## - ## client_timeout specifies a time limit for requests made by this client. - ## Includes connection time, any redirects, and reading the response body. - # client_timeout = "4s" - - ## Attribute delimiter - ## - ## When multiple attributes are returned for a single - ## [inputs.jolokia.metrics], the field name is a concatenation of the metric - ## name, and the attribute name, separated by the given delimiter. - # delimiter = "_" - - ## List of servers exposing jolokia read service - [[inputs.jolokia.servers]] - name = "as-server-01" - host = "127.0.0.1" - port = "8080" - # username = "myuser" - # password = "mypassword" - - ## List of metrics collected on above servers - ## Each metric consists in a name, a jmx path and either - ## a pass or drop slice attribute. - ## This collect all heap memory usage metrics. - [[inputs.jolokia.metrics]] - name = "heap_memory_usage" - mbean = "java.lang:type=Memory" - attribute = "HeapMemoryUsage" - - ## This collect thread counts metrics. - [[inputs.jolokia.metrics]] - name = "thread_count" - mbean = "java.lang:type=Threading" - attribute = "TotalStartedThreadCount,ThreadCount,DaemonThreadCount,PeakThreadCount" - - ## This collect number of class loaded/unloaded counts metrics. - [[inputs.jolokia.metrics]] - name = "class_count" - mbean = "java.lang:type=ClassLoading" - attribute = "LoadedClassCount,UnloadedClassCount,TotalLoadedClassCount" -` - -func (j *Jolokia) SampleConfig() string { - return sampleConfig -} - -func (j *Jolokia) Description() string { - return "Read JMX metrics through Jolokia" -} - func (j *Jolokia) doRequest(req *http.Request) ([]map[string]interface{}, error) { resp, err := j.jClient.MakeRequest(req) if err != nil { diff --git a/plugins/inputs/jolokia/jolokia_sample_config.go b/plugins/inputs/jolokia/jolokia_sample_config.go new file mode 100644 index 000000000..292682c93 --- /dev/null +++ b/plugins/inputs/jolokia/jolokia_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package jolokia + +func (j *Jolokia) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/jolokia2/README.md b/plugins/inputs/jolokia2/README.md index ae4b6a501..1377df84b 100644 --- a/plugins/inputs/jolokia2/README.md +++ b/plugins/inputs/jolokia2/README.md @@ -2,6 +2,9 @@ The [Jolokia](http://jolokia.org) _agent_ and _proxy_ input plugins collect JMX metrics from an HTTP endpoint using Jolokia's [JSON-over-HTTP protocol](https://jolokia.org/reference/html/protocol.html). +* [jolokia2_agent Configuration](jolokia2_agent/README.md) +* [jolokia2_proxy Configuration](jolokia2_proxy/README.md) + ## Configuration ### Jolokia Agent Configuration @@ -172,16 +175,16 @@ Both `jolokia2_agent` and `jolokia2_proxy` plugins support default configuration ## Example Configurations -- [ActiveMQ](/plugins/inputs/jolokia2/examples/activemq.conf) -- [BitBucket](/plugins/inputs/jolokia2/examples/bitbucket.conf) -- [Cassandra](/plugins/inputs/jolokia2/examples/cassandra.conf) -- [Hadoop-HDFS](/plugins/inputs/jolokia2/examples/hadoop-hdfs.conf) -- [Java JVM](/plugins/inputs/jolokia2/examples/java.conf) -- [JBoss](/plugins/inputs/jolokia2/examples/jboss.conf) -- [Kafka](/plugins/inputs/jolokia2/examples/kafka.conf) -- [Kafka Connect](/plugins/inputs/jolokia2/examples/kafka-connect.conf) -- [Tomcat](/plugins/inputs/jolokia2/examples/tomcat.conf) -- [Weblogic](/plugins/inputs/jolokia2/examples/weblogic.conf) -- [ZooKeeper](/plugins/inputs/jolokia2/examples/zookeeper.conf) +* [ActiveMQ](/plugins/inputs/jolokia2/examples/activemq.conf) +* [BitBucket](/plugins/inputs/jolokia2/examples/bitbucket.conf) +* [Cassandra](/plugins/inputs/jolokia2/examples/cassandra.conf) +* [Hadoop-HDFS](/plugins/inputs/jolokia2/examples/hadoop-hdfs.conf) +* [Java JVM](/plugins/inputs/jolokia2/examples/java.conf) +* [JBoss](/plugins/inputs/jolokia2/examples/jboss.conf) +* [Kafka](/plugins/inputs/jolokia2/examples/kafka.conf) +* [Kafka Connect](/plugins/inputs/jolokia2/examples/kafka-connect.conf) +* [Tomcat](/plugins/inputs/jolokia2/examples/tomcat.conf) +* [Weblogic](/plugins/inputs/jolokia2/examples/weblogic.conf) +* [ZooKeeper](/plugins/inputs/jolokia2/examples/zookeeper.conf) Please help improve this list and contribute new configuration files by opening an issue or pull request. diff --git a/plugins/inputs/jolokia2/client_test.go b/plugins/inputs/jolokia2/client_test.go index a1bd5f4a2..e55daf6b1 100644 --- a/plugins/inputs/jolokia2/client_test.go +++ b/plugins/inputs/jolokia2/client_test.go @@ -1,4 +1,4 @@ -package jolokia2 +package jolokia2_test import ( "encoding/json" @@ -27,7 +27,7 @@ func TestJolokia2_ClientAuthRequest(t *testing.T) { })) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(` + plugin := SetupPlugin(t, fmt.Sprintf(` [jolokia2_agent] urls = ["%s/jolokia"] username = "sally" @@ -64,7 +64,7 @@ func TestJolokia2_ClientProxyAuthRequest(t *testing.T) { })) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(` + plugin := SetupPlugin(t, fmt.Sprintf(` [jolokia2_proxy] url = "%s/jolokia" username = "sally" diff --git a/plugins/inputs/jolokia2/client.go b/plugins/inputs/jolokia2/common/client.go similarity index 99% rename from plugins/inputs/jolokia2/client.go rename to plugins/inputs/jolokia2/common/client.go index e3b42f660..04624eb26 100644 --- a/plugins/inputs/jolokia2/client.go +++ b/plugins/inputs/jolokia2/common/client.go @@ -1,4 +1,4 @@ -package jolokia2 +package common import ( "bytes" diff --git a/plugins/inputs/jolokia2/gatherer.go b/plugins/inputs/jolokia2/common/gatherer.go similarity index 98% rename from plugins/inputs/jolokia2/gatherer.go rename to plugins/inputs/jolokia2/common/gatherer.go index 1dfdc057e..270e74730 100644 --- a/plugins/inputs/jolokia2/gatherer.go +++ b/plugins/inputs/jolokia2/common/gatherer.go @@ -1,4 +1,4 @@ -package jolokia2 +package common import ( "fmt" @@ -93,7 +93,7 @@ func (g *Gatherer) generatePoints(metric Metric, responses []ReadResponse) ([]po continue } - pb := newPointBuilder(metric, response.RequestAttributes, response.RequestPath) + pb := NewPointBuilder(metric, response.RequestAttributes, response.RequestPath) for _, point := range pb.Build(metric.Mbean, response.Value) { if response.RequestTarget != "" { point.Tags["jolokia_agent_url"] = response.RequestTarget diff --git a/plugins/inputs/jolokia2/gatherer_test.go b/plugins/inputs/jolokia2/common/gatherer_test.go similarity index 99% rename from plugins/inputs/jolokia2/gatherer_test.go rename to plugins/inputs/jolokia2/common/gatherer_test.go index e01c603ad..02e2f9f74 100644 --- a/plugins/inputs/jolokia2/gatherer_test.go +++ b/plugins/inputs/jolokia2/common/gatherer_test.go @@ -1,4 +1,4 @@ -package jolokia2 +package common import ( "testing" diff --git a/plugins/inputs/jolokia2/metric.go b/plugins/inputs/jolokia2/common/metric.go similarity index 99% rename from plugins/inputs/jolokia2/metric.go rename to plugins/inputs/jolokia2/common/metric.go index 0f438b3c0..f5e299460 100644 --- a/plugins/inputs/jolokia2/metric.go +++ b/plugins/inputs/jolokia2/common/metric.go @@ -1,4 +1,4 @@ -package jolokia2 +package common import "strings" diff --git a/plugins/inputs/jolokia2/point_builder.go b/plugins/inputs/jolokia2/common/point_builder.go similarity index 93% rename from plugins/inputs/jolokia2/point_builder.go rename to plugins/inputs/jolokia2/common/point_builder.go index c1b985155..feba74b11 100644 --- a/plugins/inputs/jolokia2/point_builder.go +++ b/plugins/inputs/jolokia2/common/point_builder.go @@ -1,4 +1,4 @@ -package jolokia2 +package common import ( "fmt" @@ -17,7 +17,7 @@ type pointBuilder struct { substitutions []string } -func newPointBuilder(metric Metric, attributes []string, path string) *pointBuilder { +func NewPointBuilder(metric Metric, attributes []string, path string) *pointBuilder { return &pointBuilder{ metric: metric, objectAttributes: attributes, @@ -97,18 +97,18 @@ func (pb *pointBuilder) extractFields(mbean string, value interface{}) map[strin if len(pb.objectAttributes) == 0 { // if there were no attributes requested, // then the keys are attributes - pb.fillFields("", valueMap, fieldMap) + pb.FillFields("", valueMap, fieldMap) } else if len(pb.objectAttributes) == 1 { // if there was a single attribute requested, // then the keys are the attribute's properties fieldName := pb.formatFieldName(pb.objectAttributes[0], pb.objectPath) - pb.fillFields(fieldName, valueMap, fieldMap) + pb.FillFields(fieldName, valueMap, fieldMap) } else { // if there were multiple attributes requested, // then the keys are the attribute names for _, attribute := range pb.objectAttributes { fieldName := pb.formatFieldName(attribute, pb.objectPath) - pb.fillFields(fieldName, valueMap[attribute], fieldMap) + pb.FillFields(fieldName, valueMap[attribute], fieldMap) } } } else { @@ -120,7 +120,7 @@ func (pb *pointBuilder) extractFields(mbean string, value interface{}) map[strin fieldName = pb.formatFieldName(pb.objectAttributes[0], pb.objectPath) } - pb.fillFields(fieldName, value, fieldMap) + pb.FillFields(fieldName, value, fieldMap) } if len(pb.substitutions) > 1 { @@ -149,9 +149,9 @@ func (pb *pointBuilder) formatFieldName(attribute, path string) string { return fieldName } -// fillFields recurses into the supplied value object, generating a named field +// FillFields recurses into the supplied value object, generating a named field // for every value it discovers. -func (pb *pointBuilder) fillFields(name string, value interface{}, fieldMap map[string]interface{}) { +func (pb *pointBuilder) FillFields(name string, value interface{}, fieldMap map[string]interface{}) { if valueMap, ok := value.(map[string]interface{}); ok { // keep going until we get to something that is not a map for key, innerValue := range valueMap { @@ -166,7 +166,7 @@ func (pb *pointBuilder) fillFields(name string, value interface{}, fieldMap map[ innerName = name + pb.metric.FieldSeparator + key } - pb.fillFields(innerName, innerValue, fieldMap) + pb.FillFields(innerName, innerValue, fieldMap) } return diff --git a/plugins/inputs/jolokia2/jolokia.go b/plugins/inputs/jolokia2/jolokia.go deleted file mode 100644 index 430f58741..000000000 --- a/plugins/inputs/jolokia2/jolokia.go +++ /dev/null @@ -1,21 +0,0 @@ -package jolokia2 - -import ( - "github.com/influxdata/telegraf" - "github.com/influxdata/telegraf/plugins/inputs" -) - -func init() { - inputs.Add("jolokia2_agent", func() telegraf.Input { - return &JolokiaAgent{ - Metrics: []MetricConfig{}, - DefaultFieldSeparator: ".", - } - }) - inputs.Add("jolokia2_proxy", func() telegraf.Input { - return &JolokiaProxy{ - Metrics: []MetricConfig{}, - DefaultFieldSeparator: ".", - } - }) -} diff --git a/plugins/inputs/jolokia2/jolokia2.go b/plugins/inputs/jolokia2/jolokia2.go new file mode 100644 index 000000000..bf124e2e9 --- /dev/null +++ b/plugins/inputs/jolokia2/jolokia2.go @@ -0,0 +1,24 @@ +package jolokia2 + +import ( + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins/inputs" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/common" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_agent" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_proxy" +) + +func init() { + inputs.Add("jolokia2_agent", func() telegraf.Input { + return &jolokia2_agent.JolokiaAgent{ + Metrics: []common.MetricConfig{}, + DefaultFieldSeparator: ".", + } + }) + inputs.Add("jolokia2_proxy", func() telegraf.Input { + return &jolokia2_proxy.JolokiaProxy{ + Metrics: []common.MetricConfig{}, + DefaultFieldSeparator: ".", + } + }) +} diff --git a/plugins/inputs/jolokia2/jolokia2_agent/README.md b/plugins/inputs/jolokia2/jolokia2_agent/README.md new file mode 100644 index 000000000..54f1428c0 --- /dev/null +++ b/plugins/inputs/jolokia2/jolokia2_agent/README.md @@ -0,0 +1,31 @@ +# Jolokia2 Proxy input plugin + +The `jolokia2_proxy` input plugin reads JMX metrics from one or more _targets_ by interacting with a [Jolokia proxy](https://jolokia.org/features/proxy.html) REST endpoint. + +## Configuration + +```toml +# Read JMX metrics from a Jolokia REST agent endpoint +[[inputs.jolokia2_agent]] + # default_tag_prefix = "" + # default_field_prefix = "" + # default_field_separator = "." + + # Add agents URLs to query + urls = ["http://localhost:8080/jolokia"] + # username = "" + # password = "" + # response_timeout = "5s" + + ## Optional TLS config + # tls_ca = "/var/private/ca.pem" + # tls_cert = "/var/private/client.pem" + # tls_key = "/var/private/client-key.pem" + # insecure_skip_verify = false + + ## Add metrics to read + [[inputs.jolokia2_agent.metric]] + name = "java_runtime" + mbean = "java.lang:type=Runtime" + paths = ["Uptime"] +``` diff --git a/plugins/inputs/jolokia2/jolokia_agent.go b/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent.go similarity index 54% rename from plugins/inputs/jolokia2/jolokia_agent.go rename to plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent.go index 23336dd6f..4cb80f4b0 100644 --- a/plugins/inputs/jolokia2/jolokia_agent.go +++ b/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent.go @@ -1,4 +1,4 @@ -package jolokia2 +package jolokia2_agent import ( "fmt" @@ -8,6 +8,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/common/tls" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/common" ) type JolokiaAgent struct { @@ -22,49 +23,19 @@ type JolokiaAgent struct { tls.ClientConfig - Metrics []MetricConfig `toml:"metric"` - gatherer *Gatherer - clients []*Client -} - -func (ja *JolokiaAgent) SampleConfig() string { - return ` - # default_tag_prefix = "" - # default_field_prefix = "" - # default_field_separator = "." - - # Add agents URLs to query - urls = ["http://localhost:8080/jolokia"] - # username = "" - # password = "" - # response_timeout = "5s" - - ## Optional TLS config - # tls_ca = "/var/private/ca.pem" - # tls_cert = "/var/private/client.pem" - # tls_key = "/var/private/client-key.pem" - # insecure_skip_verify = false - - ## Add metrics to read - [[inputs.jolokia2_agent.metric]] - name = "java_runtime" - mbean = "java.lang:type=Runtime" - paths = ["Uptime"] -` -} - -func (ja *JolokiaAgent) Description() string { - return "Read JMX metrics from a Jolokia REST agent endpoint" + Metrics []common.MetricConfig `toml:"metric"` + gatherer *common.Gatherer + clients []*common.Client } func (ja *JolokiaAgent) Gather(acc telegraf.Accumulator) error { if ja.gatherer == nil { - ja.gatherer = NewGatherer(ja.createMetrics()) + ja.gatherer = common.NewGatherer(ja.createMetrics()) } // Initialize clients once if ja.clients == nil { - ja.clients = make([]*Client, 0, len(ja.URLs)) + ja.clients = make([]*common.Client, 0, len(ja.URLs)) for _, url := range ja.URLs { client, err := ja.createClient(url) if err != nil { @@ -79,7 +50,7 @@ func (ja *JolokiaAgent) Gather(acc telegraf.Accumulator) error { for _, client := range ja.clients { wg.Add(1) - go func(client *Client) { + go func(client *common.Client) { defer wg.Done() err := ja.gatherer.Gather(client, acc) @@ -94,19 +65,19 @@ func (ja *JolokiaAgent) Gather(acc telegraf.Accumulator) error { return nil } -func (ja *JolokiaAgent) createMetrics() []Metric { - var metrics []Metric +func (ja *JolokiaAgent) createMetrics() []common.Metric { + var metrics []common.Metric for _, metricConfig := range ja.Metrics { - metrics = append(metrics, NewMetric(metricConfig, + metrics = append(metrics, common.NewMetric(metricConfig, ja.DefaultFieldPrefix, ja.DefaultFieldSeparator, ja.DefaultTagPrefix)) } return metrics } -func (ja *JolokiaAgent) createClient(url string) (*Client, error) { - return NewClient(url, &ClientConfig{ +func (ja *JolokiaAgent) createClient(url string) (*common.Client, error) { + return common.NewClient(url, &common.ClientConfig{ Username: ja.Username, Password: ja.Password, ResponseTimeout: time.Duration(ja.ResponseTimeout), diff --git a/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent_sample_config.go b/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent_sample_config.go new file mode 100644 index 000000000..27840458d --- /dev/null +++ b/plugins/inputs/jolokia2/jolokia2_agent/jolokia2_agent_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../../tools/generate_plugindata/main.go +//go:generate go run ../../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package jolokia2_agent + +func (ja *JolokiaAgent) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/jolokia2/jolokia2_proxy/README.md b/plugins/inputs/jolokia2/jolokia2_proxy/README.md new file mode 100644 index 000000000..861ef19cd --- /dev/null +++ b/plugins/inputs/jolokia2/jolokia2_proxy/README.md @@ -0,0 +1,39 @@ +# Jolokia2 Agent plugin + +The `jolokia2_agent` input plugin reads JMX metrics from one or more [Jolokia agent](https://jolokia.org/agent/jvm.html) REST endpoints. + +## Configuration + +```toml +# Read JMX metrics from a Jolokia REST proxy endpoint +[[inputs.jolokia2_proxy]] + # default_tag_prefix = "" + # default_field_prefix = "" + # default_field_separator = "." + + ## Proxy agent + url = "http://localhost:8080/jolokia" + # username = "" + # password = "" + # response_timeout = "5s" + + ## Optional TLS config + # tls_ca = "/var/private/ca.pem" + # tls_cert = "/var/private/client.pem" + # tls_key = "/var/private/client-key.pem" + # insecure_skip_verify = false + + ## Add proxy targets to query + # default_target_username = "" + # default_target_password = "" + [[inputs.jolokia2_proxy.target]] + url = "service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi" + # username = "" + # password = "" + + ## Add metrics to read + [[inputs.jolokia2_proxy.metric]] + name = "java_runtime" + mbean = "java.lang:type=Runtime" + paths = ["Uptime"] +``` diff --git a/plugins/inputs/jolokia2/jolokia2_proxy/jolokia2_proxy_sample_config.go b/plugins/inputs/jolokia2/jolokia2_proxy/jolokia2_proxy_sample_config.go new file mode 100644 index 000000000..b99cf0aa9 --- /dev/null +++ b/plugins/inputs/jolokia2/jolokia2_proxy/jolokia2_proxy_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../../tools/generate_plugindata/main.go +//go:generate go run ../../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package jolokia2_proxy + +func (ja *JolokiaProxy) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/jolokia2/jolokia_proxy.go b/plugins/inputs/jolokia2/jolokia2_proxy/jolokia_proxy.go similarity index 51% rename from plugins/inputs/jolokia2/jolokia_proxy.go rename to plugins/inputs/jolokia2/jolokia2_proxy/jolokia_proxy.go index 8654c9308..1354182e1 100644 --- a/plugins/inputs/jolokia2/jolokia_proxy.go +++ b/plugins/inputs/jolokia2/jolokia2_proxy/jolokia_proxy.go @@ -1,4 +1,4 @@ -package jolokia2 +package jolokia2_proxy import ( "time" @@ -6,6 +6,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/plugins/common/tls" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/common" ) type JolokiaProxy struct { @@ -23,9 +24,9 @@ type JolokiaProxy struct { ResponseTimeout config.Duration `toml:"response_timeout"` tls.ClientConfig - Metrics []MetricConfig `toml:"metric"` - client *Client - gatherer *Gatherer + Metrics []common.MetricConfig `toml:"metric"` + client *common.Client + gatherer *common.Gatherer } type JolokiaProxyTargetConfig struct { @@ -34,47 +35,9 @@ type JolokiaProxyTargetConfig struct { Password string } -func (jp *JolokiaProxy) SampleConfig() string { - return ` - # default_tag_prefix = "" - # default_field_prefix = "" - # default_field_separator = "." - - ## Proxy agent - url = "http://localhost:8080/jolokia" - # username = "" - # password = "" - # response_timeout = "5s" - - ## Optional TLS config - # tls_ca = "/var/private/ca.pem" - # tls_cert = "/var/private/client.pem" - # tls_key = "/var/private/client-key.pem" - # insecure_skip_verify = false - - ## Add proxy targets to query - # default_target_username = "" - # default_target_password = "" - [[inputs.jolokia2_proxy.target]] - url = "service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi" - # username = "" - # password = "" - - ## Add metrics to read - [[inputs.jolokia2_proxy.metric]] - name = "java_runtime" - mbean = "java.lang:type=Runtime" - paths = ["Uptime"] -` -} - -func (jp *JolokiaProxy) Description() string { - return "Read JMX metrics from a Jolokia REST proxy endpoint" -} - func (jp *JolokiaProxy) Gather(acc telegraf.Accumulator) error { if jp.gatherer == nil { - jp.gatherer = NewGatherer(jp.createMetrics()) + jp.gatherer = common.NewGatherer(jp.createMetrics()) } if jp.client == nil { @@ -90,32 +53,32 @@ func (jp *JolokiaProxy) Gather(acc telegraf.Accumulator) error { return jp.gatherer.Gather(jp.client, acc) } -func (jp *JolokiaProxy) createMetrics() []Metric { - var metrics []Metric +func (jp *JolokiaProxy) createMetrics() []common.Metric { + var metrics []common.Metric for _, metricConfig := range jp.Metrics { - metrics = append(metrics, NewMetric(metricConfig, + metrics = append(metrics, common.NewMetric(metricConfig, jp.DefaultFieldPrefix, jp.DefaultFieldSeparator, jp.DefaultTagPrefix)) } return metrics } -func (jp *JolokiaProxy) createClient() (*Client, error) { - proxyConfig := &ProxyConfig{ +func (jp *JolokiaProxy) createClient() (*common.Client, error) { + proxyConfig := &common.ProxyConfig{ DefaultTargetUsername: jp.DefaultTargetUsername, DefaultTargetPassword: jp.DefaultTargetPassword, } for _, target := range jp.Targets { - proxyConfig.Targets = append(proxyConfig.Targets, ProxyTargetConfig{ + proxyConfig.Targets = append(proxyConfig.Targets, common.ProxyTargetConfig{ URL: target.URL, Username: target.Username, Password: target.Password, }) } - return NewClient(jp.URL, &ClientConfig{ + return common.NewClient(jp.URL, &common.ClientConfig{ Username: jp.Username, Password: jp.Password, ResponseTimeout: time.Duration(jp.ResponseTimeout), diff --git a/plugins/inputs/jolokia2/jolokia_test.go b/plugins/inputs/jolokia2/jolokia2_test.go similarity index 93% rename from plugins/inputs/jolokia2/jolokia_test.go rename to plugins/inputs/jolokia2/jolokia2_test.go index af22a2735..0320c2d51 100644 --- a/plugins/inputs/jolokia2/jolokia_test.go +++ b/plugins/inputs/jolokia2/jolokia2_test.go @@ -1,4 +1,4 @@ -package jolokia2 +package jolokia2_test import ( "fmt" @@ -9,6 +9,9 @@ import ( "github.com/stretchr/testify/require" "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/common" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_agent" + "github.com/influxdata/telegraf/plugins/inputs/jolokia2/jolokia2_proxy" "github.com/influxdata/telegraf/testutil" "github.com/influxdata/toml" "github.com/influxdata/toml/ast" @@ -77,7 +80,7 @@ func TestJolokia2_ScalarValues(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -237,7 +240,7 @@ func TestJolokia2_ObjectValues(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -325,7 +328,7 @@ func TestJolokia2_StatusCodes(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -375,7 +378,7 @@ func TestJolokia2_TagRenaming(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -468,7 +471,7 @@ func TestJolokia2_FieldRenaming(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -576,7 +579,7 @@ func TestJolokia2_MetricMbeanMatching(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -669,7 +672,7 @@ func TestJolokia2_MetricCompaction(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -730,7 +733,7 @@ func TestJolokia2_ProxyTargets(t *testing.T) { server := setupServer(response) defer server.Close() - plugin := setupPlugin(t, fmt.Sprintf(config, server.URL)) + plugin := SetupPlugin(t, fmt.Sprintf(config, server.URL)) var acc testutil.Accumulator require.NoError(t, plugin.Gather(&acc)) @@ -754,11 +757,11 @@ func TestFillFields(t *testing.T) { scalarPoint := []interface{}{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} results := map[string]interface{}{} - newPointBuilder(Metric{Name: "test", Mbean: "complex"}, []string{"this", "that"}, "/").fillFields("", complexPoint, results) + common.NewPointBuilder(common.Metric{Name: "test", Mbean: "complex"}, []string{"this", "that"}, "/").FillFields("", complexPoint, results) require.Equal(t, map[string]interface{}{}, results) results = map[string]interface{}{} - newPointBuilder(Metric{Name: "test", Mbean: "scalar"}, []string{"this", "that"}, "/").fillFields("", scalarPoint, results) + common.NewPointBuilder(common.Metric{Name: "test", Mbean: "scalar"}, []string{"this", "that"}, "/").FillFields("", scalarPoint, results) require.Equal(t, map[string]interface{}{}, results) } @@ -771,7 +774,7 @@ func setupServer(resp string) *httptest.Server { })) } -func setupPlugin(t *testing.T, conf string) telegraf.Input { +func SetupPlugin(t *testing.T, conf string) telegraf.Input { table, err := toml.Parse([]byte(conf)) if err != nil { t.Fatalf("Unable to parse config! %v", err) @@ -781,8 +784,8 @@ func setupPlugin(t *testing.T, conf string) telegraf.Input { object := table.Fields[name] switch name { case "jolokia2_agent": - plugin := JolokiaAgent{ - Metrics: []MetricConfig{}, + plugin := jolokia2_agent.JolokiaAgent{ + Metrics: []common.MetricConfig{}, DefaultFieldSeparator: ".", } @@ -793,8 +796,8 @@ func setupPlugin(t *testing.T, conf string) telegraf.Input { return &plugin case "jolokia2_proxy": - plugin := JolokiaProxy{ - Metrics: []MetricConfig{}, + plugin := jolokia2_proxy.JolokiaProxy{ + Metrics: []common.MetricConfig{}, DefaultFieldSeparator: ".", } diff --git a/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go similarity index 84% rename from plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go rename to plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go index b95930cd4..b4ca80468 100644 --- a/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry.go +++ b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry.go @@ -18,8 +18,8 @@ import ( "github.com/influxdata/telegraf/config" internaltls "github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/inputs" - "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth" - "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc" + authentication "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/auth" + telemetry "github.com/influxdata/telegraf/plugins/inputs/jti_openconfig_telemetry/oc" ) type OpenConfigTelemetry struct { @@ -44,65 +44,8 @@ type OpenConfigTelemetry struct { var ( // Regex to match and extract data points from path value in received key keyPathRegex = regexp.MustCompile(`/([^/]*)\[([A-Za-z0-9\-/]*=[^\[]*)]`) - sampleConfig = ` - ## List of device addresses to collect telemetry from - servers = ["localhost:1883"] - - ## Authentication details. Username and password are must if device expects - ## authentication. Client ID must be unique when connecting from multiple instances - ## of telegraf to the same device - username = "user" - password = "pass" - client_id = "telegraf" - - ## Frequency to get data - sample_frequency = "1000ms" - - ## Sensors to subscribe for - ## A identifier for each sensor can be provided in path by separating with space - ## Else sensor path will be used as identifier - ## When identifier is used, we can provide a list of space separated sensors. - ## A single subscription will be created with all these sensors and data will - ## be saved to measurement with this identifier name - sensors = [ - "/interfaces/", - "collection /components/ /lldp", - ] - - ## We allow specifying sensor group level reporting rate. To do this, specify the - ## reporting rate in Duration at the beginning of sensor paths / collection - ## name. For entries without reporting rate, we use configured sample frequency - sensors = [ - "1000ms customReporting /interfaces /lldp", - "2000ms collection /components", - "/interfaces", - ] - - ## Optional TLS Config - # enable_tls = true - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## Delay between retry attempts of failed RPC calls or streams. Defaults to 1000ms. - ## Failed streams/calls will not be retried if 0 is provided - retry_delay = "1000ms" - - ## To treat all string values as tags, set this to true - str_as_tags = false -` ) -func (m *OpenConfigTelemetry) SampleConfig() string { - return sampleConfig -} - -func (m *OpenConfigTelemetry) Description() string { - return "Read JTI OpenConfig Telemetry from listed sensors" -} - func (m *OpenConfigTelemetry) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry_sample_config.go b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry_sample_config.go new file mode 100644 index 000000000..8094b58dd --- /dev/null +++ b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package jti_openconfig_telemetry + +func (m *OpenConfigTelemetry) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry_test.go b/plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry_test.go similarity index 100% rename from plugins/inputs/jti_openconfig_telemetry/openconfig_telemetry_test.go rename to plugins/inputs/jti_openconfig_telemetry/jti_openconfig_telemetry_test.go diff --git a/plugins/inputs/kafka_consumer/README.md b/plugins/inputs/kafka_consumer/README.md index 0083142fe..12d8005c1 100644 --- a/plugins/inputs/kafka_consumer/README.md +++ b/plugins/inputs/kafka_consumer/README.md @@ -9,6 +9,7 @@ and use the old zookeeper connection method. ## Configuration ```toml +# Read metrics from Kafka topics [[inputs.kafka_consumer]] ## Kafka brokers. brokers = ["localhost:9092"] diff --git a/plugins/inputs/kafka_consumer/kafka_consumer.go b/plugins/inputs/kafka_consumer/kafka_consumer.go index 777d7261d..393d7e932 100644 --- a/plugins/inputs/kafka_consumer/kafka_consumer.go +++ b/plugins/inputs/kafka_consumer/kafka_consumer.go @@ -17,107 +17,6 @@ import ( "github.com/influxdata/telegraf/plugins/parsers" ) -const sampleConfig = ` - ## Kafka brokers. - brokers = ["localhost:9092"] - - ## Topics to consume. - topics = ["telegraf"] - - ## When set this tag will be added to all metrics with the topic as the value. - # topic_tag = "" - - ## Optional Client id - # client_id = "Telegraf" - - ## Set the minimal supported Kafka version. Setting this enables the use of new - ## Kafka features and APIs. Must be 0.10.2.0 or greater. - ## ex: version = "1.1.0" - # version = "" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## SASL authentication credentials. These settings should typically be used - ## with TLS encryption enabled - # sasl_username = "kafka" - # sasl_password = "secret" - - ## Optional SASL: - ## one of: OAUTHBEARER, PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, GSSAPI - ## (defaults to PLAIN) - # sasl_mechanism = "" - - ## used if sasl_mechanism is GSSAPI (experimental) - # sasl_gssapi_service_name = "" - # ## One of: KRB5_USER_AUTH and KRB5_KEYTAB_AUTH - # sasl_gssapi_auth_type = "KRB5_USER_AUTH" - # sasl_gssapi_kerberos_config_path = "/" - # sasl_gssapi_realm = "realm" - # sasl_gssapi_key_tab_path = "" - # sasl_gssapi_disable_pafxfast = false - - ## used if sasl_mechanism is OAUTHBEARER (experimental) - # sasl_access_token = "" - - ## SASL protocol version. When connecting to Azure EventHub set to 0. - # sasl_version = 1 - - # Disable Kafka metadata full fetch - # metadata_full = false - - ## Name of the consumer group. - # consumer_group = "telegraf_metrics_consumers" - - ## Compression codec represents the various compression codecs recognized by - ## Kafka in messages. - ## 0 : None - ## 1 : Gzip - ## 2 : Snappy - ## 3 : LZ4 - ## 4 : ZSTD - # compression_codec = 0 - - ## Initial offset position; one of "oldest" or "newest". - # offset = "oldest" - - ## Consumer group partition assignment strategy; one of "range", "roundrobin" or "sticky". - # balance_strategy = "range" - - ## Maximum length of a message to consume, in bytes (default 0/unlimited); - ## larger messages are dropped - max_message_len = 1000000 - - ## Maximum messages to read from the broker that have not been written by an - ## output. For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message from the queue contains 10 metrics and the - ## output metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## Maximum amount of time the consumer should take to process messages. If - ## the debug log prints messages from sarama about 'abandoning subscription - ## to [topic] because consuming was taking too long', increase this value to - ## longer than the time taken by the output plugin(s). - ## - ## Note that the effective timeout could be between 'max_processing_time' and - ## '2 * max_processing_time'. - # max_processing_time = "100ms" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" -` - const ( defaultMaxUndeliveredMessages = 1000 defaultMaxProcessingTime = config.Duration(100 * time.Millisecond) @@ -168,14 +67,6 @@ func (*SaramaCreator) Create(brokers []string, group string, cfg *sarama.Config) return sarama.NewConsumerGroup(brokers, group, cfg) } -func (k *KafkaConsumer) SampleConfig() string { - return sampleConfig -} - -func (k *KafkaConsumer) Description() string { - return "Read metrics from Kafka topics" -} - func (k *KafkaConsumer) SetParser(parser parsers.Parser) { k.parser = parser } diff --git a/plugins/inputs/kafka_consumer/kafka_consumer_sample_config.go b/plugins/inputs/kafka_consumer/kafka_consumer_sample_config.go new file mode 100644 index 000000000..985786650 --- /dev/null +++ b/plugins/inputs/kafka_consumer/kafka_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kafka_consumer + +func (k *KafkaConsumer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kafka_consumer_legacy/README.md b/plugins/inputs/kafka_consumer_legacy/README.md index 59b176781..755277ed8 100644 --- a/plugins/inputs/kafka_consumer_legacy/README.md +++ b/plugins/inputs/kafka_consumer_legacy/README.md @@ -11,8 +11,9 @@ from the same topic in parallel. ## Configuration ```toml +## DEPRECATED: The 'kafka_consumer_legacy' plugin is deprecated in version 1.4.0, use 'inputs.kafka_consumer' instead, NOTE: 'kafka_consumer' only supports Kafka v0.8+. # Read metrics from Kafka topic(s) -[[inputs.kafka_consumer]] +[[inputs.kafka_consumer_legacy]] ## topic(s) to consume topics = ["telegraf"] diff --git a/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy.go b/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy.go index ab19e0875..58d6b207f 100644 --- a/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy.go +++ b/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy.go @@ -47,41 +47,6 @@ type Kafka struct { doNotCommitMsgs bool } -var sampleConfig = ` - ## topic(s) to consume - topics = ["telegraf"] - - ## an array of Zookeeper connection strings - zookeeper_peers = ["localhost:2181"] - - ## Zookeeper Chroot - zookeeper_chroot = "" - - ## the name of the consumer group - consumer_group = "telegraf_metrics_consumers" - - ## Offset (must be either "oldest" or "newest") - offset = "oldest" - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" - - ## Maximum length of a message to consume, in bytes (default 0/unlimited); - ## larger messages are dropped - max_message_len = 65536 -` - -func (k *Kafka) SampleConfig() string { - return sampleConfig -} - -func (k *Kafka) Description() string { - return "Read metrics from Kafka topic(s)" -} - func (k *Kafka) SetParser(parser parsers.Parser) { k.parser = parser } diff --git a/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy_sample_config.go b/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy_sample_config.go new file mode 100644 index 000000000..ee4143ddd --- /dev/null +++ b/plugins/inputs/kafka_consumer_legacy/kafka_consumer_legacy_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kafka_consumer_legacy + +func (k *Kafka) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kapacitor/README.md b/plugins/inputs/kapacitor/README.md index ece2210e6..f089cee8f 100644 --- a/plugins/inputs/kapacitor/README.md +++ b/plugins/inputs/kapacitor/README.md @@ -5,6 +5,7 @@ The Kapacitor plugin collects metrics from the given Kapacitor instances. ## Configuration ```toml +# Read Kapacitor-formatted JSON metrics from one or more HTTP endpoints [[inputs.kapacitor]] ## Multiple URLs from which to read Kapacitor-formatted JSON ## Default is "http://localhost:9092/kapacitor/v1/debug/vars". diff --git a/plugins/inputs/kapacitor/kapacitor.go b/plugins/inputs/kapacitor/kapacitor.go index b2e8da4cc..a624bfc30 100644 --- a/plugins/inputs/kapacitor/kapacitor.go +++ b/plugins/inputs/kapacitor/kapacitor.go @@ -25,30 +25,6 @@ type Kapacitor struct { client *http.Client } -func (*Kapacitor) Description() string { - return "Read Kapacitor-formatted JSON metrics from one or more HTTP endpoints" -} - -func (*Kapacitor) SampleConfig() string { - return ` - ## Multiple URLs from which to read Kapacitor-formatted JSON - ## Default is "http://localhost:9092/kapacitor/v1/debug/vars". - urls = [ - "http://localhost:9092/kapacitor/v1/debug/vars" - ] - - ## Time limit for http requests - timeout = "5s" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` -} - func (k *Kapacitor) Gather(acc telegraf.Accumulator) error { if k.client == nil { client, err := k.createHTTPClient() diff --git a/plugins/inputs/kapacitor/kapacitor_sample_config.go b/plugins/inputs/kapacitor/kapacitor_sample_config.go new file mode 100644 index 000000000..9a82a9d2f --- /dev/null +++ b/plugins/inputs/kapacitor/kapacitor_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kapacitor + +func (*Kapacitor) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kernel/kernel.go b/plugins/inputs/kernel/kernel.go index c16c68bf4..3afcd4bff 100644 --- a/plugins/inputs/kernel/kernel.go +++ b/plugins/inputs/kernel/kernel.go @@ -28,12 +28,6 @@ type Kernel struct { entropyStatFile string } -func (k *Kernel) Description() string { - return "Get kernel statistics from /proc/stat" -} - -func (k *Kernel) SampleConfig() string { return "" } - func (k *Kernel) Gather(acc telegraf.Accumulator) error { data, err := k.getProcStat() if err != nil { diff --git a/plugins/inputs/kernel/kernel_sample_config.go b/plugins/inputs/kernel/kernel_sample_config.go new file mode 100644 index 000000000..7109de4c2 --- /dev/null +++ b/plugins/inputs/kernel/kernel_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kernel + +func (k *Kernel) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kernel_vmstat/kernel_vmstat.go b/plugins/inputs/kernel_vmstat/kernel_vmstat.go index 95a7a5e32..b34d2654d 100644 --- a/plugins/inputs/kernel_vmstat/kernel_vmstat.go +++ b/plugins/inputs/kernel_vmstat/kernel_vmstat.go @@ -17,14 +17,6 @@ type KernelVmstat struct { statFile string } -func (k *KernelVmstat) Description() string { - return "Get kernel statistics from /proc/vmstat" -} - -func (k *KernelVmstat) SampleConfig() string { - return "" -} - func (k *KernelVmstat) Gather(acc telegraf.Accumulator) error { data, err := k.getProcVmstat() if err != nil { diff --git a/plugins/inputs/kernel_vmstat/kernel_vmstat_sample_config.go b/plugins/inputs/kernel_vmstat/kernel_vmstat_sample_config.go new file mode 100644 index 000000000..98f0dd27a --- /dev/null +++ b/plugins/inputs/kernel_vmstat/kernel_vmstat_sample_config.go @@ -0,0 +1,11 @@ +//go:build linux +// +build linux + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kernel_vmstat + +func (k *KernelVmstat) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kibana/README.md b/plugins/inputs/kibana/README.md index f59a9efc0..d3391eb2b 100644 --- a/plugins/inputs/kibana/README.md +++ b/plugins/inputs/kibana/README.md @@ -10,6 +10,7 @@ The `kibana` plugin queries the [Kibana][] API to obtain the service status. ## Configuration ```toml +# Read status information from one or more Kibana servers [[inputs.kibana]] ## Specify a list of one or more Kibana servers servers = ["http://localhost:5601"] diff --git a/plugins/inputs/kibana/kibana.go b/plugins/inputs/kibana/kibana.go index d3c4c73e3..749c8d927 100644 --- a/plugins/inputs/kibana/kibana.go +++ b/plugins/inputs/kibana/kibana.go @@ -80,25 +80,6 @@ type heap struct { SizeLimit int64 `json:"size_limit"` } -const sampleConfig = ` - ## Specify a list of one or more Kibana servers - servers = ["http://localhost:5601"] - - ## Timeout for HTTP requests - timeout = "5s" - - ## HTTP Basic Auth credentials - # username = "username" - # password = "pa$$word" - - ## Optional TLS Config - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - type Kibana struct { Local bool Servers []string @@ -129,16 +110,6 @@ func mapHealthStatusToCode(s string) int { return 0 } -// SampleConfig returns sample configuration for this plugin. -func (k *Kibana) SampleConfig() string { - return sampleConfig -} - -// Description returns the plugin description. -func (k *Kibana) Description() string { - return "Read status information from one or more Kibana servers" -} - func (k *Kibana) Gather(acc telegraf.Accumulator) error { if k.client == nil { client, err := k.createHTTPClient() diff --git a/plugins/inputs/kibana/kibana_sample_config.go b/plugins/inputs/kibana/kibana_sample_config.go new file mode 100644 index 000000000..d4d889e2c --- /dev/null +++ b/plugins/inputs/kibana/kibana_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kibana + +func (k *Kibana) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kinesis_consumer/README.md b/plugins/inputs/kinesis_consumer/README.md index 681c77c63..0306627ee 100644 --- a/plugins/inputs/kinesis_consumer/README.md +++ b/plugins/inputs/kinesis_consumer/README.md @@ -6,6 +6,7 @@ and creates metrics using one of the supported [input data formats][]. ## Configuration ```toml +# Configuration for the AWS Kinesis input. [[inputs.kinesis_consumer]] ## Amazon REGION of kinesis endpoint. region = "ap-southeast-2" diff --git a/plugins/inputs/kinesis_consumer/kinesis_consumer.go b/plugins/inputs/kinesis_consumer/kinesis_consumer.go index 4ff66ed1d..343c4b082 100644 --- a/plugins/inputs/kinesis_consumer/kinesis_consumer.go +++ b/plugins/inputs/kinesis_consumer/kinesis_consumer.go @@ -73,81 +73,6 @@ type processContent func([]byte) ([]byte, error) // this is the largest sequence number allowed - https://docs.aws.amazon.com/kinesis/latest/APIReference/API_SequenceNumberRange.html var maxSeq = strToBint(strings.Repeat("9", 129)) -var sampleConfig = ` - ## Amazon REGION of kinesis endpoint. - region = "ap-southeast-2" - - ## Amazon Credentials - ## Credentials are loaded in the following order - ## 1) Web identity provider credentials via STS if role_arn and web_identity_token_file are specified - ## 2) Assumed credentials via STS if role_arn is specified - ## 3) explicit credentials from 'access_key' and 'secret_key' - ## 4) shared profile from 'profile' - ## 5) environment variables - ## 6) shared credentials file - ## 7) EC2 Instance Profile - # access_key = "" - # secret_key = "" - # token = "" - # role_arn = "" - # web_identity_token_file = "" - # role_session_name = "" - # profile = "" - # shared_credential_file = "" - - ## Endpoint to make request against, the correct endpoint is automatically - ## determined and this option should only be set if you wish to override the - ## default. - ## ex: endpoint_url = "http://localhost:8000" - # endpoint_url = "" - - ## Kinesis StreamName must exist prior to starting telegraf. - streamname = "StreamName" - - ## Shard iterator type (only 'TRIM_HORIZON' and 'LATEST' currently supported) - # shard_iterator_type = "TRIM_HORIZON" - - ## Maximum messages to read from the broker that have not been written by an - ## output. For best throughput set based on the number of metrics within - ## each message and the size of the output's metric_batch_size. - ## - ## For example, if each message from the queue contains 10 metrics and the - ## output metric_batch_size is 1000, setting this to 100 will ensure that a - ## full batch is collected and the write is triggered immediately without - ## waiting until the next flush_interval. - # max_undelivered_messages = 1000 - - ## Data format to consume. - ## Each data format has its own unique set of configuration options, read - ## more about them here: - ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md - data_format = "influx" - - ## - ## The content encoding of the data from kinesis - ## If you are processing a cloudwatch logs kinesis stream then set this to "gzip" - ## as AWS compresses cloudwatch log data before it is sent to kinesis (aws - ## also base64 encodes the zip byte data before pushing to the stream. The base64 decoding - ## is done automatically by the golang sdk, as data is read from kinesis) - ## - # content_encoding = "identity" - - ## Optional - ## Configuration for a dynamodb checkpoint - [inputs.kinesis_consumer.checkpoint_dynamodb] - ## unique name for this consumer - app_name = "default" - table_name = "default" -` - -func (k *KinesisConsumer) SampleConfig() string { - return sampleConfig -} - -func (k *KinesisConsumer) Description() string { - return "Configuration for the AWS Kinesis input." -} - func (k *KinesisConsumer) SetParser(parser parsers.Parser) { k.parser = parser } diff --git a/plugins/inputs/kinesis_consumer/kinesis_consumer_sample_config.go b/plugins/inputs/kinesis_consumer/kinesis_consumer_sample_config.go new file mode 100644 index 000000000..df1e931f3 --- /dev/null +++ b/plugins/inputs/kinesis_consumer/kinesis_consumer_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kinesis_consumer + +func (k *KinesisConsumer) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/knx_listener/knx_listener.go b/plugins/inputs/knx_listener/knx_listener.go index 3896d649b..6ecd1865c 100644 --- a/plugins/inputs/knx_listener/knx_listener.go +++ b/plugins/inputs/knx_listener/knx_listener.go @@ -42,35 +42,6 @@ type KNXListener struct { wg sync.WaitGroup } -func (kl *KNXListener) Description() string { - return "Listener capable of handling KNX bus messages provided through a KNX-IP Interface." -} - -func (kl *KNXListener) SampleConfig() string { - return ` - ## Type of KNX-IP interface. - ## Can be either "tunnel" or "router". - # service_type = "tunnel" - - ## Address of the KNX-IP interface. - service_address = "localhost:3671" - - ## Measurement definition(s) - # [[inputs.knx_listener.measurement]] - # ## Name of the measurement - # name = "temperature" - # ## Datapoint-Type (DPT) of the KNX messages - # dpt = "9.001" - # ## List of Group-Addresses (GAs) assigned to the measurement - # addresses = ["5/5/1"] - - # [[inputs.knx_listener.measurement]] - # name = "illumination" - # dpt = "9.004" - # addresses = ["5/5/3"] -` -} - func (kl *KNXListener) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/knx_listener/knx_listener_sample_config.go b/plugins/inputs/knx_listener/knx_listener_sample_config.go new file mode 100644 index 000000000..a40272dd0 --- /dev/null +++ b/plugins/inputs/knx_listener/knx_listener_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package knx_listener + +func (kl *KNXListener) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kube_inventory/README.md b/plugins/inputs/kube_inventory/README.md index 2a7a01025..f58f0e2f8 100644 --- a/plugins/inputs/kube_inventory/README.md +++ b/plugins/inputs/kube_inventory/README.md @@ -34,9 +34,10 @@ avoid cardinality issues: ## Configuration ```toml +# Read metrics from the Kubernetes api [[inputs.kube_inventory]] ## URL for the Kubernetes API - url = "https://$HOSTIP:6443" + url = "https://127.0.0.1" ## Namespace to use. Set to "" to use all namespaces. # namespace = "default" @@ -64,8 +65,8 @@ avoid cardinality issues: ## selectors to include and exclude as tags. Globs accepted. ## Note that an empty array for both will include all selectors as tags ## selector_exclude overrides selector_include if both set. - selector_include = [] - selector_exclude = ["*"] + # selector_include = [] + # selector_exclude = ["*"] ## Optional TLS Config ## Trusted root certificates for server diff --git a/plugins/inputs/kube_inventory/kube_state.go b/plugins/inputs/kube_inventory/kube_inventory.go similarity index 72% rename from plugins/inputs/kube_inventory/kube_state.go rename to plugins/inputs/kube_inventory/kube_inventory.go index a1167a8ed..87af3b4de 100644 --- a/plugins/inputs/kube_inventory/kube_state.go +++ b/plugins/inputs/kube_inventory/kube_inventory.go @@ -44,58 +44,6 @@ type KubernetesInventory struct { selectorFilter filter.Filter } -var sampleConfig = ` - ## URL for the Kubernetes API - url = "https://127.0.0.1" - - ## Namespace to use. Set to "" to use all namespaces. - # namespace = "default" - - ## Use bearer token for authorization. ('bearer_token' takes priority) - ## If both of these are empty, we'll use the default serviceaccount: - ## at: /run/secrets/kubernetes.io/serviceaccount/token - # bearer_token = "/path/to/bearer/token" - ## OR - # bearer_token_string = "abc_123" - - ## Set response_timeout (default 5 seconds) - # response_timeout = "5s" - - ## Optional Resources to exclude from gathering - ## Leave them with blank with try to gather everything available. - ## Values can be - "daemonsets", deployments", "endpoints", "ingress", "nodes", - ## "persistentvolumes", "persistentvolumeclaims", "pods", "services", "statefulsets" - # resource_exclude = [ "deployments", "nodes", "statefulsets" ] - - ## Optional Resources to include when gathering - ## Overrides resource_exclude if both set. - # resource_include = [ "deployments", "nodes", "statefulsets" ] - - ## selectors to include and exclude as tags. Globs accepted. - ## Note that an empty array for both will include all selectors as tags - ## selector_exclude overrides selector_include if both set. - # selector_include = [] - # selector_exclude = ["*"] - - ## Optional TLS Config - # tls_ca = "/path/to/cafile" - # tls_cert = "/path/to/certfile" - # tls_key = "/path/to/keyfile" - # tls_server_name = "kubernetes.example.com" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - -// SampleConfig returns a sample config -func (ki *KubernetesInventory) SampleConfig() string { - return sampleConfig -} - -// Description returns the description of this plugin -func (ki *KubernetesInventory) Description() string { - return "Read metrics from the Kubernetes api" -} - func (ki *KubernetesInventory) Init() error { // If neither are provided, use the default service account. if ki.BearerToken == "" && ki.BearerTokenString == "" { diff --git a/plugins/inputs/kube_inventory/kube_inventory_sample_config.go b/plugins/inputs/kube_inventory/kube_inventory_sample_config.go new file mode 100644 index 000000000..c18c20175 --- /dev/null +++ b/plugins/inputs/kube_inventory/kube_inventory_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kube_inventory + +func (ki *KubernetesInventory) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/kubernetes/README.md b/plugins/inputs/kubernetes/README.md index 07907f7eb..035bdb856 100644 --- a/plugins/inputs/kubernetes/README.md +++ b/plugins/inputs/kubernetes/README.md @@ -35,6 +35,7 @@ avoid cardinality issues: ## Configuration ```toml +# Read metrics from the kubernetes kubelet api [[inputs.kubernetes]] ## URL for the kubelet url = "http://127.0.0.1:10255" diff --git a/plugins/inputs/kubernetes/kubernetes.go b/plugins/inputs/kubernetes/kubernetes.go index 8ca636d48..7a2301919 100644 --- a/plugins/inputs/kubernetes/kubernetes.go +++ b/plugins/inputs/kubernetes/kubernetes.go @@ -36,33 +36,6 @@ type Kubernetes struct { RoundTripper http.RoundTripper } -var sampleConfig = ` - ## URL for the kubelet - url = "http://127.0.0.1:10255" - - ## Use bearer token for authorization. ('bearer_token' takes priority) - ## If both of these are empty, we'll use the default serviceaccount: - ## at: /run/secrets/kubernetes.io/serviceaccount/token - # bearer_token = "/path/to/bearer/token" - ## OR - # bearer_token_string = "abc_123" - - ## Pod labels to be added as tags. An empty array for both include and - ## exclude will include all labels. - # label_include = [] - # label_exclude = ["*"] - - ## Set response_timeout (default 5 seconds) - # response_timeout = "5s" - - ## Optional TLS Config - # tls_ca = /path/to/cafile - # tls_cert = /path/to/certfile - # tls_key = /path/to/keyfile - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false -` - const ( defaultServiceAccountPath = "/run/secrets/kubernetes.io/serviceaccount/token" ) @@ -76,16 +49,6 @@ func init() { }) } -//SampleConfig returns a sample config -func (k *Kubernetes) SampleConfig() string { - return sampleConfig -} - -//Description returns the description of this plugin -func (k *Kubernetes) Description() string { - return "Read metrics from the kubernetes kubelet api" -} - func (k *Kubernetes) Init() error { // If neither are provided, use the default service account. if k.BearerToken == "" && k.BearerTokenString == "" { diff --git a/plugins/inputs/kubernetes/kubernetes_sample_config.go b/plugins/inputs/kubernetes/kubernetes_sample_config.go new file mode 100644 index 000000000..777ed7f4a --- /dev/null +++ b/plugins/inputs/kubernetes/kubernetes_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package kubernetes + +func (k *Kubernetes) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/lanz/README.md b/plugins/inputs/lanz/README.md index f308b1218..589f6773a 100644 --- a/plugins/inputs/lanz/README.md +++ b/plugins/inputs/lanz/README.md @@ -19,7 +19,9 @@ You will need to configure LANZ and enable streaming LANZ data. - ```toml +# Read metrics off Arista LANZ, via socket [[inputs.lanz]] + ## URL to Arista LANZ endpoint servers = [ "tcp://switch1.int.example.com:50001", "tcp://switch2.int.example.com:50001", diff --git a/plugins/inputs/lanz/lanz.go b/plugins/inputs/lanz/lanz.go index a77e99df6..6af46f096 100644 --- a/plugins/inputs/lanz/lanz.go +++ b/plugins/inputs/lanz/lanz.go @@ -13,13 +13,6 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" ) -var sampleConfig = ` - ## URL to Arista LANZ endpoint - servers = [ - "tcp://127.0.0.1:50001" - ] -` - func init() { inputs.Add("lanz", func() telegraf.Input { return NewLanz() @@ -36,14 +29,6 @@ func NewLanz() *Lanz { return &Lanz{} } -func (l *Lanz) SampleConfig() string { - return sampleConfig -} - -func (l *Lanz) Description() string { - return "Read metrics off Arista LANZ, via socket" -} - func (l *Lanz) Gather(_ telegraf.Accumulator) error { return nil } diff --git a/plugins/inputs/lanz/lanz_sample_config.go b/plugins/inputs/lanz/lanz_sample_config.go new file mode 100644 index 000000000..31c66d7d3 --- /dev/null +++ b/plugins/inputs/lanz/lanz_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package lanz + +func (l *Lanz) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/leofs/README.md b/plugins/inputs/leofs/README.md index db77e8a52..4034a7fe9 100644 --- a/plugins/inputs/leofs/README.md +++ b/plugins/inputs/leofs/README.md @@ -5,10 +5,11 @@ The LeoFS plugin gathers metrics of LeoGateway, LeoManager, and LeoStorage using ## Configuration ```toml -# Sample Config: - +# Read metrics from a LeoFS Server via SNMP [[inputs.leofs]] - servers = ["127.0.0.1:4010"] + ## An array of URLs of the form: + ## host [ ":" port] + servers = ["127.0.0.1:4010"] ``` ## Measurements & Fields diff --git a/plugins/inputs/leofs/leofs.go b/plugins/inputs/leofs/leofs.go index bcb992b6f..2888cb23c 100644 --- a/plugins/inputs/leofs/leofs.go +++ b/plugins/inputs/leofs/leofs.go @@ -146,20 +146,6 @@ var serverTypeMapping = map[string]ServerType{ "4001": ServerTypeGateway, } -var sampleConfig = ` - ## An array of URLs of the form: - ## host [ ":" port] - servers = ["127.0.0.1:4020"] -` - -func (l *LeoFS) SampleConfig() string { - return sampleConfig -} - -func (l *LeoFS) Description() string { - return "Read metrics from a LeoFS Server via SNMP" -} - func (l *LeoFS) Gather(acc telegraf.Accumulator) error { if len(l.Servers) == 0 { return l.gatherServer(defaultEndpoint, ServerTypeManagerMaster, acc) diff --git a/plugins/inputs/leofs/leofs_sample_config.go b/plugins/inputs/leofs/leofs_sample_config.go new file mode 100644 index 000000000..94cd25f1e --- /dev/null +++ b/plugins/inputs/leofs/leofs_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package leofs + +func (l *LeoFS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/linux_sysctl_fs/README.md b/plugins/inputs/linux_sysctl_fs/README.md index 30e2f3088..a5a03037f 100644 --- a/plugins/inputs/linux_sysctl_fs/README.md +++ b/plugins/inputs/linux_sysctl_fs/README.md @@ -7,3 +7,11 @@ Example output: ```shell > linux_sysctl_fs,host=foo dentry-want-pages=0i,file-max=44222i,aio-max-nr=65536i,inode-preshrink-nr=0i,dentry-nr=64340i,dentry-unused-nr=55274i,file-nr=1568i,aio-nr=0i,inode-nr=35952i,inode-free-nr=12957i,dentry-age-limit=45i 1490982022000000000 ``` + +## Configuration + +```toml +# Provides Linux sysctl fs metrics +[[inputs.linux_sysctl_fs]] + # no configuration +``` diff --git a/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go b/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go index 19848b6db..61fa3709b 100644 --- a/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go +++ b/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs.go @@ -20,13 +20,6 @@ type SysctlFS struct { var sysctlFSDescription = `Provides Linux sysctl fs metrics` var sysctlFSSampleConfig = `` -func (sfs SysctlFS) Description() string { - return sysctlFSDescription -} -func (sfs SysctlFS) SampleConfig() string { - return sysctlFSSampleConfig -} - func (sfs *SysctlFS) gatherList(file string, fields map[string]interface{}, fieldNames ...string) error { bs, err := os.ReadFile(sfs.path + "/" + file) if err != nil { diff --git a/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs_sample_config.go b/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs_sample_config.go new file mode 100644 index 000000000..a232cf557 --- /dev/null +++ b/plugins/inputs/linux_sysctl_fs/linux_sysctl_fs_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package linux_sysctl_fs + +func (sfs SysctlFS) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/logparser/README.md b/plugins/inputs/logparser/README.md index 6406e8845..3fd2f1de8 100644 --- a/plugins/inputs/logparser/README.md +++ b/plugins/inputs/logparser/README.md @@ -48,6 +48,8 @@ Migration Example: ## Configuration ```toml +## DEPRECATED: The 'logparser' plugin is deprecated in version 1.15.0, use 'inputs.tail' with 'grok' data format instead. +# Read metrics off Arista LANZ, via socket [[inputs.logparser]] ## Log files to parse. ## These accept standard unix glob matching rules, but with the addition of @@ -95,6 +97,10 @@ Migration Example: ## 2. "Canada/Eastern" -- Unix TZ values like those found in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ## 3. UTC -- or blank/unspecified, will return timestamp in UTC # timezone = "Canada/Eastern" + + ## When set to "disable", timestamp will not incremented if there is a + ## duplicate. + # unique_timestamp = "auto" ``` ## Grok Parser diff --git a/plugins/inputs/logparser/logparser.go b/plugins/inputs/logparser/logparser.go index db3b1f2b4..5c21659e9 100644 --- a/plugins/inputs/logparser/logparser.go +++ b/plugins/inputs/logparser/logparser.go @@ -76,69 +76,6 @@ func NewLogParser() *LogParserPlugin { } } -const sampleConfig = ` - ## Log files to parse. - ## These accept standard unix glob matching rules, but with the addition of - ## ** as a "super asterisk". ie: - ## /var/log/**.log -> recursively find all .log files in /var/log - ## /var/log/*/*.log -> find all .log files with a parent dir in /var/log - ## /var/log/apache.log -> only tail the apache log file - files = ["/var/log/apache/access.log"] - - ## Read files that currently exist from the beginning. Files that are created - ## while telegraf is running (and that match the "files" globs) will always - ## be read from the beginning. - from_beginning = false - - ## Method used to watch for file updates. Can be either "inotify" or "poll". - # watch_method = "inotify" - - ## Parse logstash-style "grok" patterns: - [inputs.logparser.grok] - ## This is a list of patterns to check the given log file(s) for. - ## Note that adding patterns here increases processing time. The most - ## efficient configuration is to have one pattern per logparser. - ## Other common built-in patterns are: - ## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs) - ## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent) - patterns = ["%{COMBINED_LOG_FORMAT}"] - - ## Name of the outputted measurement name. - measurement = "apache_access_log" - - ## Full path(s) to custom pattern files. - custom_pattern_files = [] - - ## Custom patterns can also be defined here. Put one pattern per line. - custom_patterns = ''' - ''' - - ## Timezone allows you to provide an override for timestamps that - ## don't already include an offset - ## e.g. 04/06/2016 12:41:45 data one two 5.43µs - ## - ## Default: "" which renders UTC - ## Options are as follows: - ## 1. Local -- interpret based on machine localtime - ## 2. "Canada/Eastern" -- Unix TZ values like those found in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - ## 3. UTC -- or blank/unspecified, will return timestamp in UTC - # timezone = "Canada/Eastern" - - ## When set to "disable", timestamp will not incremented if there is a - ## duplicate. - # unique_timestamp = "auto" -` - -// SampleConfig returns the sample configuration for the plugin -func (l *LogParserPlugin) SampleConfig() string { - return sampleConfig -} - -// Description returns the human readable description for the plugin -func (l *LogParserPlugin) Description() string { - return "Stream and parse log file(s)." -} - func (l *LogParserPlugin) Init() error { l.Log.Warnf(`The logparser plugin is deprecated; please use the 'tail' input with the 'grok' data_format`) return nil diff --git a/plugins/inputs/logparser/logparser_sample_config.go b/plugins/inputs/logparser/logparser_sample_config.go new file mode 100644 index 000000000..aa052b898 --- /dev/null +++ b/plugins/inputs/logparser/logparser_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package logparser + +func (l *LogParserPlugin) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/logstash/README.md b/plugins/inputs/logstash/README.md index ee8ff59fe..d582262d8 100644 --- a/plugins/inputs/logstash/README.md +++ b/plugins/inputs/logstash/README.md @@ -8,6 +8,7 @@ Logstash 5 and later is supported. ## Configuration ```toml +# Read metrics exposed by Logstash [[inputs.logstash]] ## The URL of the exposed Logstash API endpoint. url = "http://127.0.0.1:9600" diff --git a/plugins/inputs/logstash/logstash.go b/plugins/inputs/logstash/logstash.go index 9f5a19858..a8508f5a4 100644 --- a/plugins/inputs/logstash/logstash.go +++ b/plugins/inputs/logstash/logstash.go @@ -17,38 +17,6 @@ import ( jsonParser "github.com/influxdata/telegraf/plugins/parsers/json" ) -const sampleConfig = ` - ## The URL of the exposed Logstash API endpoint. - url = "http://127.0.0.1:9600" - - ## Use Logstash 5 single pipeline API, set to true when monitoring - ## Logstash 5. - # single_pipeline = false - - ## Enable optional collection components. Can contain - ## "pipelines", "process", and "jvm". - # collect = ["pipelines", "process", "jvm"] - - ## Timeout for HTTP requests. - # timeout = "5s" - - ## Optional HTTP Basic Auth credentials. - # username = "username" - # password = "pa$$word" - - ## Optional TLS Config. - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - - ## Use TLS but skip chain & host verification. - # insecure_skip_verify = false - - ## Optional HTTP headers. - # [inputs.logstash.headers] - # "X-Special-Header" = "Special-Value" -` - type Logstash struct { URL string `toml:"url"` @@ -75,16 +43,6 @@ func NewLogstash() *Logstash { } } -// Description returns short info about plugin -func (logstash *Logstash) Description() string { - return "Read metrics exposed by Logstash" -} - -// SampleConfig returns details how to configure plugin -func (logstash *Logstash) SampleConfig() string { - return sampleConfig -} - type ProcessStats struct { ID string `json:"id"` Process interface{} `json:"process"` diff --git a/plugins/inputs/logstash/logstash_sample_config.go b/plugins/inputs/logstash/logstash_sample_config.go new file mode 100644 index 000000000..c9c62e6d0 --- /dev/null +++ b/plugins/inputs/logstash/logstash_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package logstash + +func (logstash *Logstash) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/lustre2/lustre2.go b/plugins/inputs/lustre2/lustre2.go index 6ffe8086b..73762be8d 100644 --- a/plugins/inputs/lustre2/lustre2.go +++ b/plugins/inputs/lustre2/lustre2.go @@ -32,23 +32,6 @@ type Lustre2 struct { allFields map[tags]map[string]interface{} } -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", - # "/proc/fs/lustre/obdfilter/*/job_stats", - # "/proc/fs/lustre/obdfilter/*/exports/*/stats", - # ] - # mds_procfiles = [ - # "/proc/fs/lustre/mdt/*/md_stats", - # "/proc/fs/lustre/mdt/*/job_stats", - # "/proc/fs/lustre/mdt/*/exports/*/stats", - # ] -` - /* The wanted fields would be a []string if not for the lines that start with read_bytes/write_bytes and contain both the byte count and the function call count @@ -448,16 +431,6 @@ func (l *Lustre2) GetLustreProcStats(fileglob string, wantedFields []*mapping) e return nil } -// SampleConfig returns sample configuration message -func (l *Lustre2) SampleConfig() string { - return sampleConfig -} - -// Description returns description of Lustre2 plugin -func (l *Lustre2) Description() string { - return "Read metrics from local Lustre service on OST, MDS" -} - // Gather reads stats from all lustre targets func (l *Lustre2) Gather(acc telegraf.Accumulator) error { //l.allFields = make(map[string]map[string]interface{}) diff --git a/plugins/inputs/lustre2/lustre2_sample_config.go b/plugins/inputs/lustre2/lustre2_sample_config.go new file mode 100644 index 000000000..2e1a031f1 --- /dev/null +++ b/plugins/inputs/lustre2/lustre2_sample_config.go @@ -0,0 +1,11 @@ +//go:build !windows +// +build !windows + +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package lustre2 + +func (l *Lustre2) SampleConfig() string { + return `{{ .SampleConfig }}` +} diff --git a/plugins/inputs/lvm/lvm.go b/plugins/inputs/lvm/lvm.go index ce46af8a3..8ae6526b8 100644 --- a/plugins/inputs/lvm/lvm.go +++ b/plugins/inputs/lvm/lvm.go @@ -17,23 +17,10 @@ var ( execCommand = exec.Command ) -var sampleConfig = ` -## Use sudo to run LVM commands -use_sudo = false -` - type LVM struct { UseSudo bool `toml:"use_sudo"` } -func (lvm *LVM) Description() string { - return "Read metrics about LVM physical volumes, volume groups, logical volumes." -} - -func (lvm *LVM) SampleConfig() string { - return sampleConfig -} - func (lvm *LVM) Init() error { return nil } diff --git a/plugins/inputs/lvm/lvm_sample_config.go b/plugins/inputs/lvm/lvm_sample_config.go new file mode 100644 index 000000000..a7caf7252 --- /dev/null +++ b/plugins/inputs/lvm/lvm_sample_config.go @@ -0,0 +1,8 @@ +//go:generate go run ../../../tools/generate_plugindata/main.go +//go:generate go run ../../../tools/generate_plugindata/main.go --clean +// DON'T EDIT; This file is used as a template by tools/generate_plugindata +package lvm + +func (lvm *LVM) SampleConfig() string { + return `{{ .SampleConfig }}` +}