chore: Embed sample configurations into README for inputs (#11136)

This commit is contained in:
Sven Rebhan 2022-05-24 15:49:47 +02:00 committed by GitHub
parent a840006e58
commit 56eb914998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
677 changed files with 3164 additions and 2422 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
/telegraf /telegraf
/telegraf.exe /telegraf.exe
/telegraf.gz /telegraf.gz
/tools/readme_config_includer/generator
/vendor /vendor
.DS_Store .DS_Store
process.yml process.yml

View File

@ -115,13 +115,22 @@ versioninfo:
go run scripts/generate_versioninfo/main.go; \ go run scripts/generate_versioninfo/main.go; \
go generate cmd/telegraf/telegraf_windows.go; \ go generate cmd/telegraf/telegraf_windows.go; \
.PHONY: build_generator
build_generator:
go build -o ./tools/readme_config_includer/generator ./tools/readme_config_includer/generator.go
insert_config_to_readme_%: build_generator
go generate -run="readme_config_includer/generator$$" ./plugins/$*/...
generate_plugins_%: build_generator
go generate -run="plugindata/main.go$$" ./plugins/$*/...
.PHONY: generate .PHONY: generate
generate: generate: insert_config_to_readme_inputs generate_plugins_outputs generate_plugins_processors generate_plugins_aggregators
go generate -run="plugindata/main.go$$" ./plugins/inputs/... ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/...
.PHONY: generate-clean .PHONY: generate-clean
generate-clean: generate-clean:
go generate -run="plugindata/main.go --clean" ./plugins/inputs/... ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/... go generate -run="plugindata/main.go --clean" ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/...
.PHONY: build .PHONY: build
build: build:
@ -223,6 +232,8 @@ clean:
rm -f telegraf rm -f telegraf
rm -f telegraf.exe rm -f telegraf.exe
rm -rf build rm -rf build
rm -rf tools/readme_config_includer/generator
rm -rf tools/readme_config_includer/generator.exe
.PHONY: docker-image .PHONY: docker-image
docker-image: docker-image:

View File

@ -539,7 +539,7 @@ The inverse of `tagpass`. If a match is found the metric is discarded. This
is tested on metrics after they have passed the `tagpass` test. is tested on metrics after they have passed the `tagpass` test.
> NOTE: Due to the way TOML is parsed, `tagpass` and `tagdrop` parameters must be > NOTE: Due to the way TOML is parsed, `tagpass` and `tagdrop` parameters must be
defined at the *_end_* of the plugin definition, otherwise subsequent plugin config defined at the **end** of the plugin definition, otherwise subsequent plugin config
options will be interpreted as part of the tagpass/tagdrop tables. options will be interpreted as part of the tagpass/tagdrop tables.
### Modifiers ### Modifiers

View File

@ -4,7 +4,7 @@ This plugin gather queues, topics & subscribers metrics using ActiveMQ Console A
## Configuration ## Configuration
```toml ```toml @sample.conf
# Gather ActiveMQ metrics # Gather ActiveMQ metrics
[[inputs.activemq]] [[inputs.activemq]]
## ActiveMQ WebConsole URL ## ActiveMQ WebConsole URL

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package activemq package activemq
import ( import (
_ "embed"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io" "io"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type ActiveMQ struct { type ActiveMQ struct {
Server string `toml:"server" deprecated:"1.11.0;use 'url' instead"` Server string `toml:"server" deprecated:"1.11.0;use 'url' instead"`
Port int `toml:"port" deprecated:"1.11.0;use 'url' instead"` Port int `toml:"port" deprecated:"1.11.0;use 'url' instead"`
@ -98,6 +104,10 @@ func (a *ActiveMQ) createHTTPClient() (*http.Client, error) {
return client, nil return client, nil
} }
func (*ActiveMQ) SampleConfig() string {
return sampleConfig
}
func (a *ActiveMQ) Init() error { func (a *ActiveMQ) Init() error {
if a.ResponseTimeout < config.Duration(time.Second) { if a.ResponseTimeout < config.Duration(time.Second) {
a.ResponseTimeout = config.Duration(time.Second * 5) a.ResponseTimeout = config.Duration(time.Second * 5)

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -11,7 +11,7 @@ All metrics are attempted to be cast to integers, then booleans, then strings.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read stats from aerospike server(s) # Read stats from aerospike server(s)
[[inputs.aerospike]] [[inputs.aerospike]]
## Aerospike servers to connect to (with port) ## Aerospike servers to connect to (with port)

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package aerospike package aerospike
import ( import (
"crypto/tls" "crypto/tls"
_ "embed"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Aerospike struct { type Aerospike struct {
Servers []string `toml:"servers"` Servers []string `toml:"servers"`
@ -50,6 +56,10 @@ var protectedHexFields = map[string]bool{
"paxos_principal": true, "paxos_principal": true,
} }
func (*Aerospike) SampleConfig() string {
return sampleConfig
}
func (a *Aerospike) Gather(acc telegraf.Accumulator) error { func (a *Aerospike) Gather(acc telegraf.Accumulator) error {
if !a.initialized { if !a.initialized {
tlsConfig, err := a.ClientConfig.TLSConfig() tlsConfig, err := a.ClientConfig.TLSConfig()

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -19,7 +19,7 @@ In the following order the plugin will attempt to authenticate.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Pull Metric Statistics from Aliyun CMS # Pull Metric Statistics from Aliyun CMS
[[inputs.aliyuncms]] [[inputs.aliyuncms]]
## Aliyun Credentials ## Aliyun Credentials

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package aliyuncms package aliyuncms
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv" "strconv"
@ -11,15 +13,20 @@ import (
"github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers"
"github.com/aliyun/alibaba-cloud-sdk-go/services/cms" "github.com/aliyun/alibaba-cloud-sdk-go/services/cms"
"github.com/jmespath/go-jmespath"
"github.com/pkg/errors"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/limiter" "github.com/influxdata/telegraf/internal/limiter"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
"github.com/jmespath/go-jmespath"
"github.com/pkg/errors"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type ( type (
// AliyunCMS is aliyun cms config info. // AliyunCMS is aliyun cms config info.
AliyunCMS struct { AliyunCMS struct {
@ -103,6 +110,10 @@ var aliyunRegionList = []string{
"me-east-1", "me-east-1",
} }
func (*AliyunCMS) SampleConfig() string {
return sampleConfig
}
// Init perform checks of plugin inputs and initialize internals // Init perform checks of plugin inputs and initialize internals
func (s *AliyunCMS) Init() error { func (s *AliyunCMS) Init() error {
if s.Project == "" { if s.Project == "" {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -4,7 +4,7 @@ This plugin uses a query on the [`rocm-smi`](https://github.com/RadeonOpenComput
## Configuration ## Configuration
```toml ```toml @sample.conf
# Query statistics from AMD Graphics cards using rocm-smi binary # Query statistics from AMD Graphics cards using rocm-smi binary
[[inputs.amd_rocm_smi]] [[inputs.amd_rocm_smi]]
## Optional: path to rocm-smi binary, defaults to $PATH via exec.LookPath ## Optional: path to rocm-smi binary, defaults to $PATH via exec.LookPath

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package amd_rocm_smi package amd_rocm_smi
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
@ -15,6 +17,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const measurement = "amd_rocm_smi" const measurement = "amd_rocm_smi"
type ROCmSMI struct { type ROCmSMI struct {
@ -22,6 +28,10 @@ type ROCmSMI struct {
Timeout config.Duration Timeout config.Duration
} }
func (*ROCmSMI) SampleConfig() string {
return sampleConfig
}
// Gather implements the telegraf interface // Gather implements the telegraf interface
func (rsmi *ROCmSMI) Gather(acc telegraf.Accumulator) error { func (rsmi *ROCmSMI) Gather(acc telegraf.Accumulator) error {
if _, err := os.Stat(rsmi.BinPath); os.IsNotExist(err) { if _, err := os.Stat(rsmi.BinPath); os.IsNotExist(err) {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -15,7 +15,7 @@ For an introduction to AMQP see:
The following defaults are known to work with RabbitMQ: The following defaults are known to work with RabbitMQ:
```toml ```toml @sample.conf
# AMQP consumer plugin # AMQP consumer plugin
[[inputs.amqp_consumer]] [[inputs.amqp_consumer]]
## Brokers to consume from. If multiple brokers are specified a random broker ## Brokers to consume from. If multiple brokers are specified a random broker

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package amqp_consumer package amqp_consumer
import ( import (
"context" "context"
_ "embed"
"errors" "errors"
"fmt" "fmt"
"math/rand" "math/rand"
@ -18,6 +20,10 @@ import (
"github.com/influxdata/telegraf/plugins/parsers" "github.com/influxdata/telegraf/plugins/parsers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultMaxUndeliveredMessages = 1000 defaultMaxUndeliveredMessages = 1000
) )
@ -88,6 +94,10 @@ const (
DefaultPrefetchCount = 50 DefaultPrefetchCount = 50
) )
func (*AMQPConsumer) SampleConfig() string {
return sampleConfig
}
func (a *AMQPConsumer) SetParser(parser parsers.Parser) { func (a *AMQPConsumer) SetParser(parser parsers.Parser) {
a.parser = parser a.parser = parser
} }

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -6,7 +6,7 @@ Typically, the `mod_status` module is configured to expose a page at the `/serve
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read Apache status information (mod_status) # Read Apache status information (mod_status)
[[inputs.apache]] [[inputs.apache]]
## An array of URLs to gather from, must be directed at the machine ## An array of URLs to gather from, must be directed at the machine

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package apache package apache
import ( import (
"bufio" "bufio"
_ "embed"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Apache struct { type Apache struct {
Urls []string Urls []string
Username string Username string
@ -27,6 +33,10 @@ type Apache struct {
client *http.Client client *http.Client
} }
func (*Apache) SampleConfig() string {
return sampleConfig
}
func (n *Apache) Gather(acc telegraf.Accumulator) error { func (n *Apache) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup var wg sync.WaitGroup

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -8,7 +8,7 @@ apcupsd should be installed and it's daemon should be running.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Monitor APC UPSes connected to apcupsd # Monitor APC UPSes connected to apcupsd
[[inputs.apcupsd]] [[inputs.apcupsd]]
# A list of running apcupsd server to connect to. # A list of running apcupsd server to connect to.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package apcupsd package apcupsd
import ( import (
"context" "context"
_ "embed"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
@ -14,6 +16,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const defaultAddress = "tcp://127.0.0.1:3551" const defaultAddress = "tcp://127.0.0.1:3551"
var defaultTimeout = config.Duration(5 * time.Second) var defaultTimeout = config.Duration(5 * time.Second)
@ -23,6 +29,10 @@ type ApcUpsd struct {
Timeout config.Duration Timeout config.Duration
} }
func (*ApcUpsd) SampleConfig() string {
return sampleConfig
}
func (h *ApcUpsd) Gather(acc telegraf.Accumulator) error { func (h *ApcUpsd) Gather(acc telegraf.Accumulator) error {
ctx := context.Background() ctx := context.Background()

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -6,7 +6,7 @@ For monitoring recommendations reference [Monitoring your Aurora cluster](https:
## Configuration ## Configuration
```toml ```toml @sample.conf
# Gather metrics from Apache Aurora schedulers # Gather metrics from Apache Aurora schedulers
[[inputs.aurora]] [[inputs.aurora]]
## Schedulers are the base addresses of your Aurora Schedulers ## Schedulers are the base addresses of your Aurora Schedulers

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package aurora package aurora
import ( import (
"context" "context"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type RoleType int type RoleType int
const ( const (
@ -54,6 +60,10 @@ type Aurora struct {
urls []*url.URL urls []*url.URL
} }
func (*Aurora) SampleConfig() string {
return sampleConfig
}
func (a *Aurora) Gather(acc telegraf.Accumulator) error { func (a *Aurora) Gather(acc telegraf.Accumulator) error {
if a.client == nil { if a.client == nil {
err := a.initialize() err := a.initialize()

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -4,7 +4,7 @@ This plugin gathers sizes of Azure Storage Queues.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Gather Azure Storage Queue metrics # Gather Azure Storage Queue metrics
[[inputs.azure_storage_queue]] [[inputs.azure_storage_queue]]
## Required Azure Storage Account name ## Required Azure Storage Account name

View File

@ -1,17 +1,24 @@
//go:generate ../../../tools/readme_config_includer/generator
package azure_storage_queue package azure_storage_queue
import ( import (
"context" "context"
_ "embed"
"errors" "errors"
"net/url" "net/url"
"strings" "strings"
"time" "time"
"github.com/Azure/azure-storage-queue-go/azqueue" "github.com/Azure/azure-storage-queue-go/azqueue"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type AzureStorageQueue struct { type AzureStorageQueue struct {
StorageAccountName string `toml:"account_name"` StorageAccountName string `toml:"account_name"`
StorageAccountKey string `toml:"account_key"` StorageAccountKey string `toml:"account_key"`
@ -21,6 +28,10 @@ type AzureStorageQueue struct {
serviceURL *azqueue.ServiceURL serviceURL *azqueue.ServiceURL
} }
func (*AzureStorageQueue) SampleConfig() string {
return sampleConfig
}
func (a *AzureStorageQueue) Init() error { func (a *AzureStorageQueue) Init() error {
if a.StorageAccountName == "" { if a.StorageAccountName == "" {
return errors.New("account_name must be configured") return errors.New("account_name must be configured")

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -55,7 +55,7 @@ cache_readaheads
Using this configuration: Using this configuration:
```toml ```toml @sample.conf
# Read metrics of bcache from stats_total and dirty_data # Read metrics of bcache from stats_total and dirty_data
[[inputs.bcache]] [[inputs.bcache]]
## Bcache sets path ## Bcache sets path

View File

@ -1,3 +1,4 @@
//go:generate ../../../tools/readme_config_includer/generator
//go:build !windows //go:build !windows
// +build !windows // +build !windows
@ -6,6 +7,7 @@
package bcache package bcache
import ( import (
_ "embed"
"errors" "errors"
"fmt" "fmt"
"os" "os"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Bcache struct { type Bcache struct {
BcachePath string BcachePath string
BcacheDevs []string BcacheDevs []string
@ -94,6 +100,10 @@ func (b *Bcache) gatherBcache(bdev string, acc telegraf.Accumulator) error {
return nil return nil
} }
func (*Bcache) SampleConfig() string {
return sampleConfig
}
func (b *Bcache) Gather(acc telegraf.Accumulator) error { func (b *Bcache) Gather(acc telegraf.Accumulator) error {
bcacheDevsChecked := make(map[string]bool) bcacheDevsChecked := make(map[string]bool)
var restrictDevs bool var restrictDevs bool

View File

@ -1,11 +0,0 @@
//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 }}`
}

View File

@ -4,7 +4,7 @@ The `beanstalkd` plugin collects server stats as well as tube stats (reported by
## Configuration ## Configuration
```toml ```toml @sample.conf
# Collects Beanstalkd server and tubes stats # Collects Beanstalkd server and tubes stats
[[inputs.beanstalkd]] [[inputs.beanstalkd]]
## Server to collect data from ## Server to collect data from

View File

@ -1,21 +1,32 @@
//go:generate ../../../tools/readme_config_includer/generator
package beanstalkd package beanstalkd
import ( import (
_ "embed"
"fmt" "fmt"
"io" "io"
"net/textproto" "net/textproto"
"sync" "sync"
"gopkg.in/yaml.v2"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
"gopkg.in/yaml.v2"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Beanstalkd struct { type Beanstalkd struct {
Server string `toml:"server"` Server string `toml:"server"`
Tubes []string `toml:"tubes"` Tubes []string `toml:"tubes"`
} }
func (*Beanstalkd) SampleConfig() string {
return sampleConfig
}
func (b *Beanstalkd) Gather(acc telegraf.Accumulator) error { func (b *Beanstalkd) Gather(acc telegraf.Accumulator) error {
connection, err := textproto.Dial("tcp", b.Server) connection, err := textproto.Dial("tcp", b.Server)
if err != nil { if err != nil {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -5,7 +5,7 @@ known to work with Filebeat and Kafkabeat.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read metrics exposed by Beat # Read metrics exposed by Beat
[[inputs.beat]] [[inputs.beat]]
## An URL from which to read Beat-formatted JSON ## An URL from which to read Beat-formatted JSON

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package beat package beat
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -15,6 +17,10 @@ import (
jsonparser "github.com/influxdata/telegraf/plugins/parsers/json" jsonparser "github.com/influxdata/telegraf/plugins/parsers/json"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const suffixInfo = "/" const suffixInfo = "/"
const suffixStats = "/stats" const suffixStats = "/stats"
@ -59,6 +65,10 @@ func NewBeat() *Beat {
} }
} }
func (*Beat) SampleConfig() string {
return sampleConfig
}
func (beat *Beat) Init() error { func (beat *Beat) Init() error {
availableStats := []string{"beat", "libbeat", "system", "filebeat"} availableStats := []string{"beat", "libbeat", "system", "filebeat"}

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -16,7 +16,7 @@ not enable support for JSON statistics in their BIND packages.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read BIND nameserver XML statistics # Read BIND nameserver XML statistics
[[inputs.bind]] [[inputs.bind]]
## An array of BIND XML statistics URI to gather stats. ## An array of BIND XML statistics URI to gather stats.

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package bind package bind
import ( import (
_ "embed"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
@ -12,6 +14,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Bind struct { type Bind struct {
Urls []string Urls []string
GatherMemoryContexts bool GatherMemoryContexts bool
@ -21,6 +27,10 @@ type Bind struct {
client http.Client client http.Client
} }
func (*Bind) SampleConfig() string {
return sampleConfig
}
func (b *Bind) Init() error { func (b *Bind) Init() error {
b.client = http.Client{ b.client = http.Client{
Timeout: time.Duration(b.Timeout), Timeout: time.Duration(b.Timeout),

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -6,7 +6,7 @@ The plugin collects these metrics from `/proc/net/bonding/*` files.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Collect bond interface status, slaves statuses and failures count # Collect bond interface status, slaves statuses and failures count
[[inputs.bond]] [[inputs.bond]]
## Sets 'proc' directory path ## Sets 'proc' directory path

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package bond package bond
import ( import (
"bufio" "bufio"
_ "embed"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@ -12,6 +14,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// default host proc path // default host proc path
const defaultHostProc = "/proc" const defaultHostProc = "/proc"
const defaultHostSys = "/sys" const defaultHostSys = "/sys"
@ -34,6 +40,10 @@ type sysFiles struct {
ADPortsFile string ADPortsFile string
} }
func (*Bond) SampleConfig() string {
return sampleConfig
}
func (bond *Bond) Gather(acc telegraf.Accumulator) error { func (bond *Bond) Gather(acc telegraf.Accumulator) error {
// load proc path, get default value if config value and env variable are empty // load proc path, get default value if config value and env variable are empty
bond.loadPaths() bond.loadPaths()

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -7,7 +7,7 @@ Supported Burrow version: `1.x`
## Configuration ## Configuration
```toml ```toml @sample.conf
# Collect Kafka topics and consumers status from Burrow HTTP API. # Collect Kafka topics and consumers status from Burrow HTTP API.
[[inputs.burrow]] [[inputs.burrow]]
## Burrow API endpoints in format "schema://host:port". ## Burrow API endpoints in format "schema://host:port".

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package burrow package burrow
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net" "net"
@ -18,6 +20,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultBurrowPrefix = "/v3/kafka" defaultBurrowPrefix = "/v3/kafka"
defaultConcurrentConnections = 20 defaultConcurrentConnections = 20
@ -92,6 +98,10 @@ func init() {
}) })
} }
func (*burrow) SampleConfig() string {
return sampleConfig
}
func (b *burrow) Gather(acc telegraf.Accumulator) error { func (b *burrow) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup var wg sync.WaitGroup

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -20,7 +20,7 @@ Cassandra plugin produces one or more measurements for each metric configured, a
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read Cassandra metrics through Jolokia # Read Cassandra metrics through Jolokia
[[inputs.cassandra]] [[inputs.cassandra]]
## DEPRECATED: The cassandra plugin has been deprecated. Please use the ## DEPRECATED: The cassandra plugin has been deprecated. Please use the

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package cassandra package cassandra
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -13,6 +15,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type JolokiaClient interface { type JolokiaClient interface {
MakeRequest(req *http.Request) (*http.Response, error) MakeRequest(req *http.Request) (*http.Response, error)
} }
@ -228,6 +234,10 @@ func parseServerTokens(server string) map[string]string {
return serverTokens return serverTokens
} }
func (*Cassandra) SampleConfig() string {
return sampleConfig
}
func (c *Cassandra) Start(_ telegraf.Accumulator) error { func (c *Cassandra) Start(_ telegraf.Accumulator) error {
c.Log.Warn("DEPRECATED: The cassandra plugin has been deprecated. " + c.Log.Warn("DEPRECATED: The cassandra plugin has been deprecated. " +
"Please use the jolokia2 plugin instead. " + "Please use the jolokia2 plugin instead. " +

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -43,7 +43,7 @@ the cluster. The currently supported commands are:
## Configuration ## Configuration
```toml ```toml @sample.conf
# Collects performance metrics from the MON, OSD, MDS and RGW nodes in a Ceph storage cluster. # Collects performance metrics from the MON, OSD, MDS and RGW nodes in a Ceph storage cluster.
[[inputs.ceph]] [[inputs.ceph]]
## This is the recommended interval to poll. Too frequent and you will lose ## This is the recommended interval to poll. Too frequent and you will lose

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package ceph package ceph
import ( import (
"bytes" "bytes"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
@ -13,6 +15,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
measurement = "ceph" measurement = "ceph"
typeMon = "monitor" typeMon = "monitor"
@ -42,6 +48,10 @@ type Ceph struct {
Log telegraf.Logger `toml:"-"` Log telegraf.Logger `toml:"-"`
} }
func (*Ceph) SampleConfig() string {
return sampleConfig
}
func (c *Ceph) Gather(acc telegraf.Accumulator) error { func (c *Ceph) Gather(acc telegraf.Accumulator) error {
if c.GatherAdminSocketStats { if c.GatherAdminSocketStats {
if err := c.gatherAdminSocketStats(acc); err != nil { if err := c.gatherAdminSocketStats(acc); err != nil {
@ -110,21 +120,21 @@ func (c *Ceph) gatherClusterStats(acc telegraf.Accumulator) error {
} }
func init() { func init() {
c := Ceph{ inputs.Add(measurement, func() telegraf.Input {
CephBinary: "/usr/bin/ceph", return &Ceph{
OsdPrefix: osdPrefix, CephBinary: "/usr/bin/ceph",
MonPrefix: monPrefix, OsdPrefix: osdPrefix,
MdsPrefix: mdsPrefix, MonPrefix: monPrefix,
RgwPrefix: rgwPrefix, MdsPrefix: mdsPrefix,
SocketDir: "/var/run/ceph", RgwPrefix: rgwPrefix,
SocketSuffix: sockSuffix, SocketDir: "/var/run/ceph",
CephUser: "client.admin", SocketSuffix: sockSuffix,
CephConfig: "/etc/ceph/ceph.conf", CephUser: "client.admin",
GatherAdminSocketStats: true, CephConfig: "/etc/ceph/ceph.conf",
GatherClusterStats: false, GatherAdminSocketStats: true,
} GatherClusterStats: false,
}
inputs.Add(measurement, func() telegraf.Input { return &c }) })
} }
var perfDump = func(binary string, socket *socket) (string, error) { var perfDump = func(binary string, socket *socket) (string, error) {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -40,7 +40,7 @@ All measurements have the `path` tag.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read specific statistics per cgroup # Read specific statistics per cgroup
[[inputs.cgroup]] [[inputs.cgroup]]
## Directories in which to look for files, globs are supported. ## Directories in which to look for files, globs are supported.

View File

@ -1,15 +1,26 @@
//go:generate ../../../tools/readme_config_includer/generator
package cgroup package cgroup
import ( import (
_ "embed"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type CGroup struct { type CGroup struct {
Paths []string `toml:"paths"` Paths []string `toml:"paths"`
Files []string `toml:"files"` Files []string `toml:"files"`
} }
func (*CGroup) SampleConfig() string {
return sampleConfig
}
func init() { func init() {
inputs.Add("cgroup", func() telegraf.Input { return &CGroup{} }) inputs.Add("cgroup", func() telegraf.Input { return &CGroup{} })
} }

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -53,7 +53,7 @@ Delete second or Not synchronised.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Get standard chrony metrics, requires chronyc executable. # Get standard chrony metrics, requires chronyc executable.
[[inputs.chrony]] [[inputs.chrony]]
## If true, chronyc tries to perform a DNS lookup for the time server. ## If true, chronyc tries to perform a DNS lookup for the time server.

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package chrony package chrony
import ( import (
_ "embed"
"errors" "errors"
"fmt" "fmt"
"os/exec" "os/exec"
@ -13,6 +15,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
var ( var (
execCommand = exec.Command // execCommand is used to mock commands in tests. execCommand = exec.Command // execCommand is used to mock commands in tests.
) )
@ -22,6 +28,10 @@ type Chrony struct {
path string path string
} }
func (*Chrony) SampleConfig() string {
return sampleConfig
}
func (c *Chrony) Init() error { func (c *Chrony) Init() error {
var err error var err error
c.path, err = exec.LookPath("chronyc") c.path, err = exec.LookPath("chronyc")

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -11,7 +11,7 @@ The TCP dialout transport is supported on IOS XR (32-bit and 64-bit) 6.1.x and l
## Configuration ## Configuration
```toml ```toml @sample.conf
# Cisco model-driven telemetry (MDT) input plugin for IOS XR, IOS XE and NX-OS platforms # Cisco model-driven telemetry (MDT) input plugin for IOS XR, IOS XE and NX-OS platforms
[[inputs.cisco_telemetry_mdt]] [[inputs.cisco_telemetry_mdt]]
## Telemetry transport can be "tcp" or "grpc". TLS is only supported when ## Telemetry transport can be "tcp" or "grpc". TLS is only supported when

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package cisco_telemetry_mdt package cisco_telemetry_mdt
import ( import (
"bytes" "bytes"
_ "embed"
"encoding/binary" "encoding/binary"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -17,7 +19,7 @@ import (
telemetry "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis" telemetry "github.com/cisco-ie/nx-telemetry-proto/telemetry_bis"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
_ "google.golang.org/grpc/encoding/gzip" // Register GRPC gzip decoder to support compressed telemetry _ "google.golang.org/grpc/encoding/gzip" // Required to allow gzip encoding
"google.golang.org/grpc/peer" "google.golang.org/grpc/peer"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
@ -27,6 +29,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
// Maximum telemetry payload size (in bytes) to accept for GRPC dialout transport // Maximum telemetry payload size (in bytes) to accept for GRPC dialout transport
tcpMaxMsgLen uint32 = 1024 * 1024 tcpMaxMsgLen uint32 = 1024 * 1024
@ -74,6 +80,10 @@ type NxPayloadXfromStructure struct {
} `json:"prop"` } `json:"prop"`
} }
func (*CiscoTelemetryMDT) SampleConfig() string {
return sampleConfig
}
// Start the Cisco MDT service // Start the Cisco MDT service
func (c *CiscoTelemetryMDT) Start(acc telegraf.Accumulator) error { func (c *CiscoTelemetryMDT) Start(acc telegraf.Accumulator) error {
var err error var err error

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -4,7 +4,7 @@ This plugin gathers the statistic data from [ClickHouse](https://github.com/Clic
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read metrics from one or many ClickHouse servers # Read metrics from one or many ClickHouse servers
[[inputs.clickhouse]] [[inputs.clickhouse]]
## Username for authorization on ClickHouse server ## Username for authorization on ClickHouse server

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package clickhouse package clickhouse
import ( import (
"bytes" "bytes"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@ -19,6 +21,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
var defaultTimeout = 5 * time.Second var defaultTimeout = 5 * time.Second
type connect struct { type connect struct {
@ -53,6 +59,10 @@ type ClickHouse struct {
tls.ClientConfig tls.ClientConfig
} }
func (*ClickHouse) SampleConfig() string {
return sampleConfig
}
// Start ClickHouse input service // Start ClickHouse input service
func (ch *ClickHouse) Start(telegraf.Accumulator) error { func (ch *ClickHouse) Start(telegraf.Accumulator) error {
timeout := defaultTimeout timeout := defaultTimeout

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -5,7 +5,7 @@ and creates metrics using one of the supported [input data formats][].
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read metrics from Google PubSub # Read metrics from Google PubSub
[[inputs.cloud_pubsub]] [[inputs.cloud_pubsub]]
## Required. Name of Google Cloud Platform (GCP) Project that owns ## Required. Name of Google Cloud Platform (GCP) Project that owns

View File

@ -1,23 +1,29 @@
//go:generate ../../../tools/readme_config_includer/generator
package cloud_pubsub package cloud_pubsub
import ( import (
"context" "context"
_ "embed"
"encoding/base64"
"fmt" "fmt"
"sync" "sync"
"encoding/base64"
"time" "time"
"cloud.google.com/go/pubsub" "cloud.google.com/go/pubsub"
"golang.org/x/oauth2/google"
"google.golang.org/api/option"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/plugins/parsers" "github.com/influxdata/telegraf/plugins/parsers"
"golang.org/x/oauth2/google"
"google.golang.org/api/option"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type empty struct{} type empty struct{}
type semaphore chan empty type semaphore chan empty
@ -59,6 +65,10 @@ type PubSub struct {
sem semaphore sem semaphore
} }
func (*PubSub) SampleConfig() string {
return sampleConfig
}
// Gather does nothing for this service input. // Gather does nothing for this service input.
func (ps *PubSub) Gather(_ telegraf.Accumulator) error { func (ps *PubSub) Gather(_ telegraf.Accumulator) error {
return nil return nil

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -13,7 +13,7 @@ Enable mutually authenticated TLS and authorize client connections by signing ce
This is a sample configuration for the plugin. This is a sample configuration for the plugin.
```toml ```toml @sample.conf
# Google Cloud Pub/Sub Push HTTP listener # Google Cloud Pub/Sub Push HTTP listener
[[inputs.cloud_pubsub_push]] [[inputs.cloud_pubsub_push]]
## Address and port to host HTTP listener on ## Address and port to host HTTP listener on

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package cloud_pubsub_push package cloud_pubsub_push
import ( import (
"context" "context"
"crypto/subtle" "crypto/subtle"
_ "embed"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"io" "io"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/parsers" "github.com/influxdata/telegraf/plugins/parsers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// defaultMaxBodySize is the default maximum request body size, in bytes. // defaultMaxBodySize is the default maximum request body size, in bytes.
// if the request body is over this size, we will return an HTTP 413 error. // if the request body is over this size, we will return an HTTP 413 error.
// 500 MB // 500 MB
@ -61,6 +67,10 @@ type Payload struct {
Subscription string `json:"subscription"` Subscription string `json:"subscription"`
} }
func (*PubSubPush) SampleConfig() string {
return sampleConfig
}
func (p *PubSubPush) Gather(_ telegraf.Accumulator) error { func (p *PubSubPush) Gather(_ telegraf.Accumulator) error {
return nil return nil
} }

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -16,7 +16,7 @@ API endpoint. In the following order the plugin will attempt to authenticate.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Pull Metric Statistics from Amazon CloudWatch # Pull Metric Statistics from Amazon CloudWatch
[[inputs.cloudwatch]] [[inputs.cloudwatch]]
## Amazon Region ## Amazon Region

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package cloudwatch package cloudwatch
import ( import (
"context" "context"
_ "embed"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -25,6 +27,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
StatisticAverage = "Average" StatisticAverage = "Average"
StatisticMaximum = "Maximum" StatisticMaximum = "Maximum"
@ -90,6 +96,10 @@ type cloudwatchClient interface {
GetMetricData(context.Context, *cwClient.GetMetricDataInput, ...func(*cwClient.Options)) (*cwClient.GetMetricDataOutput, error) GetMetricData(context.Context, *cwClient.GetMetricDataInput, ...func(*cwClient.Options)) (*cwClient.GetMetricDataOutput, error)
} }
func (*CloudWatch) SampleConfig() string {
return sampleConfig
}
func (c *CloudWatch) Init() error { func (c *CloudWatch) Init() error {
if len(c.Namespace) != 0 { if len(c.Namespace) != 0 {
c.Namespaces = append(c.Namespaces, c.Namespace) c.Namespaces = append(c.Namespaces, c.Namespace)

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -20,7 +20,7 @@ For more information on conntrack-tools, see the
## Configuration ## Configuration
```toml ```toml @sample.conf
# Collects conntrack stats from the configured directories and files. # Collects conntrack stats from the configured directories and files.
[[inputs.conntrack]] [[inputs.conntrack]]
## The following defaults would work with multiple versions of conntrack. ## The following defaults would work with multiple versions of conntrack.

View File

@ -1,20 +1,25 @@
//go:generate ../../../tools/readme_config_includer/generator
//go:build linux //go:build linux
// +build linux // +build linux
package conntrack package conntrack
import ( import (
_ "embed"
"fmt" "fmt"
"os" "os"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"path/filepath"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Conntrack struct { type Conntrack struct {
Path string Path string
Dirs []string Dirs []string
@ -47,6 +52,10 @@ func (c *Conntrack) setDefaults() {
} }
} }
func (*Conntrack) SampleConfig() string {
return sampleConfig
}
func (c *Conntrack) Gather(acc telegraf.Accumulator) error { func (c *Conntrack) Gather(acc telegraf.Accumulator) error {
c.setDefaults() c.setDefaults()

View File

@ -1,11 +0,0 @@
//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 }}`
}

View File

@ -8,7 +8,7 @@ report those stats already using StatsD protocol if needed.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Gather health check statuses from services registered in Consul # Gather health check statuses from services registered in Consul
[[inputs.consul]] [[inputs.consul]]
## Consul server address ## Consul server address

View File

@ -1,15 +1,22 @@
//go:generate ../../../tools/readme_config_includer/generator
package consul package consul
import ( import (
_ "embed"
"net/http" "net/http"
"strings" "strings"
"github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/common/tls"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Consul struct { type Consul struct {
Address string Address string
Scheme string Scheme string
@ -27,6 +34,10 @@ type Consul struct {
client *api.Client client *api.Client
} }
func (*Consul) SampleConfig() string {
return sampleConfig
}
func (c *Consul) Init() error { func (c *Consul) Init() error {
if c.MetricVersion != 2 { if c.MetricVersion != 2 {
c.Log.Warnf("Use of deprecated configuration: 'metric_version = 1'; please update to 'metric_version = 2'") c.Log.Warnf("Use of deprecated configuration: 'metric_version = 1'; please update to 'metric_version = 2'")

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -6,7 +6,7 @@ This plugin grabs metrics from a Consul agent. Telegraf may be present in every
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read metrics from the Consul Agent API # Read metrics from the Consul Agent API
[[inputs.consul_agent]] [[inputs.consul_agent]]
## URL for the Consul agent ## URL for the Consul agent

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package consul_agent package consul_agent
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -15,6 +17,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// consul_agent configuration object // consul_agent configuration object
type ConsulAgent struct { type ConsulAgent struct {
URL string `toml:"url"` URL string `toml:"url"`
@ -39,6 +45,10 @@ func init() {
}) })
} }
func (*ConsulAgent) SampleConfig() string {
return sampleConfig
}
func (n *ConsulAgent) Init() error { func (n *ConsulAgent) Init() error {
if n.URL == "" { if n.URL == "" {
n.URL = "http://127.0.0.1:8500" n.URL = "http://127.0.0.1:8500"

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -5,7 +5,7 @@ This plugin gets metrics for each Couchbase node, as well as detailed metrics fo
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read per-node and per-bucket metrics from Couchbase # Read per-node and per-bucket metrics from Couchbase
[[inputs.couchbase]] [[inputs.couchbase]]
## specify servers via a url matching: ## specify servers via a url matching:

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package couchbase package couchbase
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"net/http" "net/http"
"regexp" "regexp"
@ -15,6 +17,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Couchbase struct { type Couchbase struct {
Servers []string Servers []string
@ -28,6 +34,10 @@ type Couchbase struct {
var regexpURI = regexp.MustCompile(`(\S+://)?(\S+\:\S+@)`) var regexpURI = regexp.MustCompile(`(\S+://)?(\S+\:\S+@)`)
func (*Couchbase) SampleConfig() string {
return sampleConfig
}
// Reads stats from all configured clusters. Accumulates stats. // Reads stats from all configured clusters. Accumulates stats.
// Returns one of the errors encountered while gathering stats (if any). // Returns one of the errors encountered while gathering stats (if any).
func (cb *Couchbase) Gather(acc telegraf.Accumulator) error { func (cb *Couchbase) Gather(acc telegraf.Accumulator) error {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -4,7 +4,7 @@ The CouchDB plugin gathers metrics of CouchDB using [_stats] endpoint.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read CouchDB Stats from one or more servers # Read CouchDB Stats from one or more servers
[[inputs.couchdb]] [[inputs.couchdb]]
## Works with CouchDB stats endpoints out of the box ## Works with CouchDB stats endpoints out of the box

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package couchdb package couchdb
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -11,6 +13,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type ( type (
metaData struct { metaData struct {
Current *float64 `json:"current"` Current *float64 `json:"current"`
@ -88,6 +94,10 @@ type (
} }
) )
func (*CouchDB) SampleConfig() string {
return sampleConfig
}
func (c *CouchDB) Gather(accumulator telegraf.Accumulator) error { func (c *CouchDB) Gather(accumulator telegraf.Accumulator) error {
var wg sync.WaitGroup var wg sync.WaitGroup
for _, u := range c.Hosts { for _, u := range c.Hosts {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -4,7 +4,7 @@ The `cpu` plugin gather metrics on the system CPUs.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Read metrics about cpu usage # Read metrics about cpu usage
[[inputs.cpu]] [[inputs.cpu]]
## Whether to report per-cpu stats or not ## Whether to report per-cpu stats or not

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package cpu package cpu
import ( import (
_ "embed"
"fmt" "fmt"
"time" "time"
@ -11,6 +13,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs/system" "github.com/influxdata/telegraf/plugins/inputs/system"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type CPUStats struct { type CPUStats struct {
ps system.PS ps system.PS
lastStats map[string]cpuUtil.TimesStat lastStats map[string]cpuUtil.TimesStat
@ -35,6 +41,10 @@ func NewCPUStats(ps system.PS) *CPUStats {
} }
} }
func (*CPUStats) SampleConfig() string {
return sampleConfig
}
func (c *CPUStats) Gather(acc telegraf.Accumulator) error { func (c *CPUStats) Gather(acc telegraf.Accumulator) error {
times, err := c.ps.CPUTimes(c.PerCPU, c.TotalCPU) times, err := c.ps.CPUTimes(c.PerCPU, c.TotalCPU)
if err != nil { if err != nil {

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -8,3 +8,5 @@
collect_cpu_time = false collect_cpu_time = false
## If true, compute and report the sum of all non-idle CPU states ## If true, compute and report the sum of all non-idle CPU states
report_active = false report_active = false
## If true and the info is available then add core_id and physical_id tags
core_tags = false

View File

@ -4,7 +4,7 @@ The `csgo` plugin gather metrics from Counter-Strike: Global Offensive servers.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Fetch metrics from a CSGO SRCDS # Fetch metrics from a CSGO SRCDS
[[inputs.csgo]] [[inputs.csgo]]
## Specify servers using the following format: ## Specify servers using the following format:

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package csgo package csgo
import ( import (
_ "embed"
"encoding/json" "encoding/json"
"errors" "errors"
"strconv" "strconv"
@ -14,6 +16,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type statsData struct { type statsData struct {
CPU float64 `json:"cpu"` CPU float64 `json:"cpu"`
NetIn float64 `json:"net_in"` NetIn float64 `json:"net_in"`
@ -31,6 +37,10 @@ type CSGO struct {
Servers [][]string `toml:"servers"` Servers [][]string `toml:"servers"`
} }
func (*CSGO) SampleConfig() string {
return sampleConfig
}
func (s *CSGO) Gather(acc telegraf.Accumulator) error { func (s *CSGO) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup var wg sync.WaitGroup

View File

@ -1,8 +0,0 @@
//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 }}`
}

View File

@ -20,7 +20,7 @@ your database.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Input plugin for DC/OS metrics # Input plugin for DC/OS metrics
[[inputs.dcos]] [[inputs.dcos]]
## The DC/OS cluster URL. ## The DC/OS cluster URL.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package dcos package dcos
import ( import (
"context" "context"
_ "embed"
"net/url" "net/url"
"os" "os"
"sort" "sort"
@ -18,6 +20,10 @@ import (
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultMaxConnections = 10 defaultMaxConnections = 10
defaultResponseTimeout = 20 * time.Second defaultResponseTimeout = 20 * time.Second
@ -69,6 +75,10 @@ type DCOS struct {
appFilter filter.Filter appFilter filter.Filter
} }
func (*DCOS) SampleConfig() string {
return sampleConfig
}
func (d *DCOS) Gather(acc telegraf.Accumulator) error { func (d *DCOS) Gather(acc telegraf.Accumulator) error {
err := d.init() err := d.init()
if err != nil { if err != nil {

View File

@ -1,8 +0,0 @@
//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 }}`
}

Some files were not shown because too many files have changed in this diff Show More