chore: embed sample configurations into README for outputs (#11182)

This commit is contained in:
Sven Rebhan 2022-05-25 16:48:59 +02:00 committed by GitHub
parent 7d2016b84c
commit d9a6d8b774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
162 changed files with 622 additions and 501 deletions

View File

@ -126,11 +126,11 @@ generate_plugins_%: build_generator
go generate -run="plugindata/main.go$$" ./plugins/$*/... go generate -run="plugindata/main.go$$" ./plugins/$*/...
.PHONY: generate .PHONY: generate
generate: insert_config_to_readme_inputs generate_plugins_outputs generate_plugins_processors generate_plugins_aggregators generate: insert_config_to_readme_inputs insert_config_to_readme_outputs generate_plugins_processors generate_plugins_aggregators
.PHONY: generate-clean .PHONY: generate-clean
generate-clean: generate-clean:
go generate -run="plugindata/main.go --clean" ./plugins/outputs/... ./plugins/processors/... ./plugins/aggregators/... go generate -run="plugindata/main.go --clean" ./plugins/processors/... ./plugins/aggregators/...
.PHONY: build .PHONY: build
build: build:

View File

@ -11,7 +11,7 @@ Metrics are grouped by converting any `_` characters to `.` in the Point Name.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for Amon Server to send metrics to. # Configuration for Amon Server to send metrics to.
[[outputs.amon]] [[outputs.amon]]
## Amon Server Key ## Amon Server Key

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package amon package amon
import ( import (
"bytes" "bytes"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -13,6 +15,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Amon struct { type Amon struct {
ServerKey string `toml:"server_key"` ServerKey string `toml:"server_key"`
AmonInstance string `toml:"amon_instance"` AmonInstance string `toml:"amon_instance"`
@ -33,6 +39,10 @@ type Metric struct {
type Point [2]float64 type Point [2]float64
func (*Amon) SampleConfig() string {
return sampleConfig
}
func (a *Amon) Connect() error { func (a *Amon) Connect() error {
if a.ServerKey == "" || a.AmonInstance == "" { if a.ServerKey == "" || a.AmonInstance == "" {
return fmt.Errorf("serverkey and amon_instance are required fields for amon output") return fmt.Errorf("serverkey and amon_instance are required fields for amon output")

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 amon
func (a *Amon) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -12,7 +12,7 @@ For an introduction to AMQP see:
## Configuration ## Configuration
```toml ```toml @sample.conf
# Publishes metrics to an AMQP broker # Publishes metrics to an AMQP broker
[[outputs.amqp]] [[outputs.amqp]]
## Broker to publish to. ## Broker to publish to.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package amqp package amqp
import ( import (
"bytes" "bytes"
_ "embed"
"strings" "strings"
"time" "time"
@ -15,6 +17,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
DefaultURL = "amqp://localhost:5672/influxdb" DefaultURL = "amqp://localhost:5672/influxdb"
DefaultAuthMethod = "PLAIN" DefaultAuthMethod = "PLAIN"
@ -71,6 +77,10 @@ type Client interface {
Close() error Close() error
} }
func (*AMQP) SampleConfig() string {
return sampleConfig
}
func (q *AMQP) SetSerializer(serializer serializers.Serializer) { func (q *AMQP) SetSerializer(serializer serializers.Serializer) {
q.serializer = serializer q.serializer = serializer
} }

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
func (q *AMQP) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -5,7 +5,7 @@ Insights](https://azure.microsoft.com/en-us/services/application-insights/).
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send metrics to Azure Application Insights # Send metrics to Azure Application Insights
[[outputs.application_insights]] [[outputs.application_insights]]
## Instrumentation key of the Application Insights resource. ## Instrumentation key of the Application Insights resource.

View File

@ -1,17 +1,24 @@
//go:generate ../../../tools/readme_config_includer/generator
package application_insights package application_insights
import ( import (
_ "embed"
"fmt" "fmt"
"math" "math"
"time" "time"
"unsafe" "unsafe"
"github.com/microsoft/ApplicationInsights-Go/appinsights"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
"github.com/microsoft/ApplicationInsights-Go/appinsights"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type TelemetryTransmitter interface { type TelemetryTransmitter interface {
Track(appinsights.Telemetry) Track(appinsights.Telemetry)
Close() <-chan struct{} Close() <-chan struct{}
@ -39,6 +46,10 @@ var (
is32BitChecked bool is32BitChecked bool
) )
func (*ApplicationInsights) SampleConfig() string {
return sampleConfig
}
func (a *ApplicationInsights) Connect() error { func (a *ApplicationInsights) Connect() error {
if a.InstrumentationKey == "" { if a.InstrumentationKey == "" {
return fmt.Errorf("instrumentation key is required") return fmt.Errorf("instrumentation key is required")

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 application_insights
func (a *ApplicationInsights) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -15,7 +15,7 @@ of logs, metrics and time series data.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Sends metrics to Azure Data Explorer # Sends metrics to Azure Data Explorer
[[outputs.azure_data_explorer]] [[outputs.azure_data_explorer]]
## The URI property of the Azure Data Explorer resource on Azure ## The URI property of the Azure Data Explorer resource on Azure

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package azure_data_explorer package azure_data_explorer
import ( import (
"bytes" "bytes"
"context" "context"
_ "embed"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -13,6 +15,7 @@ import (
"github.com/Azure/azure-kusto-go/kusto/ingest" "github.com/Azure/azure-kusto-go/kusto/ingest"
"github.com/Azure/azure-kusto-go/kusto/unsafe" "github.com/Azure/azure-kusto-go/kusto/unsafe"
"github.com/Azure/go-autorest/autorest/azure/auth" "github.com/Azure/go-autorest/autorest/azure/auth"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
@ -20,6 +23,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers/json" "github.com/influxdata/telegraf/plugins/serializers/json"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type AzureDataExplorer struct { type AzureDataExplorer struct {
Endpoint string `toml:"endpoint_url"` Endpoint string `toml:"endpoint_url"`
Database string `toml:"database"` Database string `toml:"database"`
@ -55,6 +62,10 @@ type ingestorFactory func(localClient, string, string) (localIngestor, error)
const createTableCommand = `.create-merge table ['%s'] (['fields']:dynamic, ['name']:string, ['tags']:dynamic, ['timestamp']:datetime);` const createTableCommand = `.create-merge table ['%s'] (['fields']:dynamic, ['name']:string, ['tags']:dynamic, ['timestamp']:datetime);`
const createTableMappingCommand = `.create-or-alter table ['%s'] ingestion json mapping '%s_mapping' '[{"column":"fields", "Properties":{"Path":"$[\'fields\']"}},{"column":"name", "Properties":{"Path":"$[\'name\']"}},{"column":"tags", "Properties":{"Path":"$[\'tags\']"}},{"column":"timestamp", "Properties":{"Path":"$[\'timestamp\']"}}]'` const createTableMappingCommand = `.create-or-alter table ['%s'] ingestion json mapping '%s_mapping' '[{"column":"fields", "Properties":{"Path":"$[\'fields\']"}},{"column":"name", "Properties":{"Path":"$[\'name\']"}},{"column":"tags", "Properties":{"Path":"$[\'tags\']"}},{"column":"timestamp", "Properties":{"Path":"$[\'timestamp\']"}}]'`
func (*AzureDataExplorer) SampleConfig() string {
return sampleConfig
}
func (adx *AzureDataExplorer) Connect() error { func (adx *AzureDataExplorer) Connect() error {
authorizer, err := auth.NewAuthorizerFromEnvironmentWithResource(adx.Endpoint) authorizer, err := auth.NewAuthorizerFromEnvironmentWithResource(adx.Endpoint)
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 azure_data_explorer
func (adx *AzureDataExplorer) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -16,7 +16,7 @@ dimension on each Azure Monitor metric.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send aggregate metrics to Azure Monitor # Send aggregate metrics to Azure Monitor
[[outputs.azure_monitor]] [[outputs.azure_monitor]]
## Timeout for HTTP writes. ## Timeout for HTTP writes.

View File

@ -1,9 +1,11 @@
//go:generate ../../../tools/readme_config_includer/generator
package azure_monitor package azure_monitor
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"context" "context"
_ "embed"
"encoding/binary" "encoding/binary"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -25,6 +27,10 @@ import (
"github.com/influxdata/telegraf/selfstat" "github.com/influxdata/telegraf/selfstat"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// AzureMonitor allows publishing of metrics to the Azure Monitor custom metrics // AzureMonitor allows publishing of metrics to the Azure Monitor custom metrics
// service // service
type AzureMonitor struct { type AzureMonitor struct {
@ -103,6 +109,10 @@ const (
maxRequestBodySize = 4000000 maxRequestBodySize = 4000000
) )
func (*AzureMonitor) SampleConfig() string {
return sampleConfig
}
// Connect initializes the plugin and validates connectivity // Connect initializes the plugin and validates connectivity
func (a *AzureMonitor) Connect() error { func (a *AzureMonitor) Connect() error {
a.cache = make(map[time.Time]map[uint64]*aggregate, 36) a.cache = make(map[time.Time]map[uint64]*aggregate, 36)

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_monitor
func (a *AzureMonitor) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -10,7 +10,7 @@ Be aware that this plugin accesses APIs that are
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for Google Cloud BigQuery to send entries # Configuration for Google Cloud BigQuery to send entries
[[outputs.bigquery]] [[outputs.bigquery]]
## Credentials File ## Credentials File

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package bigquery package bigquery
import ( import (
"context" "context"
_ "embed"
"fmt" "fmt"
"reflect" "reflect"
"strings" "strings"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const timeStampFieldName = "timestamp" const timeStampFieldName = "timestamp"
var defaultTimeout = config.Duration(5 * time.Second) var defaultTimeout = config.Duration(5 * time.Second)
@ -36,6 +42,10 @@ type BigQuery struct {
warnedOnHyphens map[string]bool warnedOnHyphens map[string]bool
} }
func (*BigQuery) SampleConfig() string {
return sampleConfig
}
func (s *BigQuery) Connect() error { func (s *BigQuery) Connect() error {
if s.Project == "" { if s.Project == "" {
return fmt.Errorf("Project is a required field for BigQuery output") return fmt.Errorf("Project is a required field for BigQuery output")

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 bigquery
func (s *BigQuery) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -5,7 +5,7 @@ as one of the supported [output data formats][].
## Configuration ## Configuration
```toml ```toml @sample.conf
# Publish Telegraf metrics to a Google Cloud PubSub topic # Publish Telegraf metrics to a Google Cloud PubSub topic
[[outputs.cloud_pubsub]] [[outputs.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,22 +1,29 @@
//go:generate ../../../tools/readme_config_includer/generator
package cloud_pubsub package cloud_pubsub
import ( import (
"context" "context"
_ "embed"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"sync" "sync"
"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/outputs" "github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
"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 PubSub struct { type PubSub struct {
CredentialsFile string `toml:"credentials_file"` CredentialsFile string `toml:"credentials_file"`
Project string `toml:"project"` Project string `toml:"project"`
@ -41,6 +48,10 @@ type PubSub struct {
publishResults []publishResult publishResults []publishResult
} }
func (*PubSub) SampleConfig() string {
return sampleConfig
}
func (ps *PubSub) SetSerializer(serializer serializers.Serializer) { func (ps *PubSub) SetSerializer(serializer serializers.Serializer) {
ps.serializer = serializer ps.serializer = serializer
} }

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

@ -29,7 +29,7 @@ The IAM user needs only the `cloudwatch:PutMetricData` permission.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for AWS CloudWatch output. # Configuration for AWS CloudWatch output.
[[outputs.cloudwatch]] [[outputs.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"
"math" "math"
"sort" "sort"
"strings" "strings"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type CloudWatch struct { type CloudWatch struct {
Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace
HighResolutionMetrics bool `toml:"high_resolution_metrics"` HighResolutionMetrics bool `toml:"high_resolution_metrics"`
@ -148,6 +154,10 @@ func (f *valueField) buildDatum() []types.MetricDatum {
} }
} }
func (*CloudWatch) SampleConfig() string {
return sampleConfig
}
func (c *CloudWatch) Connect() error { func (c *CloudWatch) Connect() error {
cfg, err := c.CredentialConfig.Credentials() cfg, err := c.CredentialConfig.Credentials()
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 cloudwatch
func (c *CloudWatch) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -33,7 +33,7 @@ The IAM user needs the following permissions (see this [reference][4] for more):
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for AWS CloudWatchLogs output. # Configuration for AWS CloudWatchLogs output.
[[outputs.cloudwatch_logs]] [[outputs.cloudwatch_logs]]
## The region is the Amazon region that you wish to connect to. ## The region is the Amazon region that you wish to connect to.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package cloudwatch_logs package cloudwatch_logs
import ( import (
"context" "context"
_ "embed"
"fmt" "fmt"
"sort" "sort"
"strings" "strings"
@ -9,11 +11,16 @@ import (
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/config/aws" internalaws "github.com/influxdata/telegraf/config/aws"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type messageBatch struct { type messageBatch struct {
logEvents []types.InputLogEvent logEvents []types.InputLogEvent
messageCount int messageCount int
@ -73,6 +80,10 @@ const (
// Otherwise, the operation fails. // Otherwise, the operation fails.
) )
func (*CloudWatchLogs) SampleConfig() string {
return sampleConfig
}
// Init initialize plugin with checking configuration parameters // Init initialize plugin with checking configuration parameters
func (c *CloudWatchLogs) Init() error { func (c *CloudWatchLogs) Init() error {
if c.LogGroup == "" { if c.LogGroup == "" {

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_logs
func (c *CloudWatchLogs) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -23,7 +23,7 @@ config option, see below.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for CrateDB to send metrics to. # Configuration for CrateDB to send metrics to.
[[outputs.cratedb]] [[outputs.cratedb]]
# A github.com/jackc/pgx/v4 connection string. # A github.com/jackc/pgx/v4 connection string.

View File

@ -1,9 +1,11 @@
//go:generate ../../../tools/readme_config_includer/generator
package cratedb package cratedb
import ( import (
"context" "context"
"crypto/sha512" "crypto/sha512"
"database/sql" "database/sql"
_ "embed"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"sort" "sort"
@ -18,6 +20,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const MaxInt64 = int64(^uint64(0) >> 1) const MaxInt64 = int64(^uint64(0) >> 1)
type CrateDB struct { type CrateDB struct {
@ -29,6 +35,10 @@ type CrateDB struct {
DB *sql.DB DB *sql.DB
} }
func (*CrateDB) SampleConfig() string {
return sampleConfig
}
func (c *CrateDB) Connect() error { func (c *CrateDB) Connect() error {
db, err := sql.Open("pgx", c.URL) db, err := sql.Open("pgx", c.URL)
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 cratedb
func (c *CrateDB) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -5,7 +5,7 @@ This plugin writes to the [Datadog Metrics API][metrics] and requires an
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for DataDog API to send metrics to. # Configuration for DataDog API to send metrics to.
[[outputs.datadog]] [[outputs.datadog]]
## Datadog API key ## Datadog API key

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package datadog package datadog
import ( import (
"bytes" "bytes"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"math" "math"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Datadog struct { type Datadog struct {
Apikey string `toml:"apikey"` Apikey string `toml:"apikey"`
Timeout config.Duration `toml:"timeout"` Timeout config.Duration `toml:"timeout"`
@ -45,6 +51,10 @@ type Point [2]float64
const datadogAPI = "https://app.datadoghq.com/api/v1/series" const datadogAPI = "https://app.datadoghq.com/api/v1/series"
func (*Datadog) SampleConfig() string {
return sampleConfig
}
func (d *Datadog) Connect() error { func (d *Datadog) Connect() error {
if d.Apikey == "" { if d.Apikey == "" {
return fmt.Errorf("apikey is a required field for datadog output") return fmt.Errorf("apikey is a required field for datadog output")

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 datadog
func (d *Datadog) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -5,7 +5,7 @@ meant to be used for testing purposes.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send metrics to nowhere at all # Send metrics to nowhere at all
[[outputs.discard]] [[outputs.discard]]
# no configuration # no configuration

View File

@ -1,12 +1,23 @@
//go:generate ../../../tools/readme_config_includer/generator
package discard package discard
import ( import (
_ "embed"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Discard struct{} type Discard struct{}
func (*Discard) SampleConfig() string {
return sampleConfig
}
func (d *Discard) Connect() error { return nil } func (d *Discard) Connect() error { return nil }
func (d *Discard) Close() error { return nil } func (d *Discard) Close() error { return nil }
func (d *Discard) Write(_ []telegraf.Metric) error { func (d *Discard) Write(_ []telegraf.Metric) 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 discard
func (d *Discard) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -93,7 +93,7 @@ You can learn more about how to use the Dynatrace API
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send telegraf metrics to a Dynatrace environment # Send telegraf metrics to a Dynatrace environment
[[outputs.dynatrace]] [[outputs.dynatrace]]
## For usage with the Dynatrace OneAgent you can omit any configuration, ## For usage with the Dynatrace OneAgent you can omit any configuration,

View File

@ -1,23 +1,29 @@
//go:generate ../../../tools/readme_config_includer/generator
package dynatrace package dynatrace
import ( import (
"bytes" "bytes"
_ "embed"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"strings" "strings"
"time" "time"
dtMetric "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric"
"github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/apiconstants"
"github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/dimensions"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/plugins/common/tls" "github.com/influxdata/telegraf/plugins/common/tls"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
dtMetric "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric"
"github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/apiconstants"
"github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/dimensions"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// Dynatrace Configuration for the Dynatrace output plugin // Dynatrace Configuration for the Dynatrace output plugin
type Dynatrace struct { type Dynatrace struct {
URL string `toml:"url"` URL string `toml:"url"`
@ -38,6 +44,10 @@ type Dynatrace struct {
loggedMetrics map[string]bool // New empty set loggedMetrics map[string]bool // New empty set
} }
func (*Dynatrace) SampleConfig() string {
return sampleConfig
}
// Connect Connects the Dynatrace output plugin to the Telegraf stream // Connect Connects the Dynatrace output plugin to the Telegraf stream
func (d *Dynatrace) Connect() error { func (d *Dynatrace) Connect() 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 dynatrace
func (d *Dynatrace) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -197,7 +197,7 @@ POST https://es.us-east-1.amazonaws.com/2021-01-01/opensearch/upgradeDomain
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for Elasticsearch to send metrics to. # Configuration for Elasticsearch to send metrics to.
[[outputs.elasticsearch]] [[outputs.elasticsearch]]
## The full HTTP endpoint URL for your Elasticsearch instance ## The full HTTP endpoint URL for your Elasticsearch instance

View File

@ -1,8 +1,11 @@
//go:generate ../../../tools/readme_config_includer/generator
package elasticsearch package elasticsearch
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/sha256"
_ "embed"
"fmt" "fmt"
"math" "math"
"net/http" "net/http"
@ -12,8 +15,6 @@ import (
"text/template" "text/template"
"time" "time"
"crypto/sha256"
"github.com/olivere/elastic" "github.com/olivere/elastic"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
@ -22,6 +23,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Elasticsearch struct { type Elasticsearch struct {
AuthBearerToken string `toml:"auth_bearer_token"` AuthBearerToken string `toml:"auth_bearer_token"`
DefaultPipeline string `toml:"default_pipeline"` DefaultPipeline string `toml:"default_pipeline"`
@ -127,6 +132,10 @@ type templatePart struct {
Version int Version int
} }
func (*Elasticsearch) SampleConfig() string {
return sampleConfig
}
func (a *Elasticsearch) Connect() error { func (a *Elasticsearch) Connect() error {
if a.URLs == nil || a.IndexName == "" { if a.URLs == nil || a.IndexName == "" {
return fmt.Errorf("elasticsearch urls or index_name is not defined") return fmt.Errorf("elasticsearch urls or index_name is not defined")

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 elasticsearch
func (a *Elasticsearch) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -15,7 +15,7 @@ JSON is probably the easiest to integrate with downstream components.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for Event Hubs output plugin # Configuration for Event Hubs output plugin
[[outputs.event_hubs]] [[outputs.event_hubs]]
## The full connection string to the Event Hub (required) ## The full connection string to the Event Hub (required)

View File

@ -1,16 +1,23 @@
//go:generate ../../../tools/readme_config_includer/generator
package event_hubs package event_hubs
import ( import (
"context" "context"
_ "embed"
"time" "time"
eventhub "github.com/Azure/azure-event-hubs-go/v3" eventhub "github.com/Azure/azure-event-hubs-go/v3"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config" "github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
/* /*
** Wrapper interface for eventhub.Hub ** Wrapper interface for eventhub.Hub
*/ */
@ -61,6 +68,10 @@ const (
defaultRequestTimeout = time.Second * 30 defaultRequestTimeout = time.Second * 30
) )
func (*EventHubs) SampleConfig() string {
return sampleConfig
}
func (e *EventHubs) Init() error { func (e *EventHubs) Init() error {
err := e.Hub.GetHub(e.ConnectionString) err := e.Hub.GetHub(e.ConnectionString)

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 event_hubs
func (e *EventHubs) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -3,8 +3,16 @@
## The full connection string to the Event Hub (required) ## The full connection string to the Event Hub (required)
## The shared access key must have "Send" permissions on the target Event Hub. ## The shared access key must have "Send" permissions on the target Event Hub.
connection_string = "Endpoint=sb://namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=superSecret1234=;EntityPath=hubName" connection_string = "Endpoint=sb://namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=superSecret1234=;EntityPath=hubName"
## Client timeout (defaults to 30s) ## Client timeout (defaults to 30s)
# timeout = "30s" # timeout = "30s"
## Partition key
## Metric tag or field name to use for the event partition key. The value of
## this tag or field is set as the key for events if it exists. If both, tag
## and field, exist the tag is preferred.
# partition_key = ""
## Data format to output. ## Data format to output.
## Each data format has its own unique set of configuration options, read ## Each data format has its own unique set of configuration options, read
## more about them here: ## more about them here:

View File

@ -14,7 +14,7 @@ For better performance, consider execd, which runs continuously.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send metrics to command as input over stdin # Send metrics to command as input over stdin
[[outputs.exec]] [[outputs.exec]]
## Command to ingest metrics via stdin. ## Command to ingest metrics via stdin.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package exec package exec
import ( import (
"bytes" "bytes"
_ "embed"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const maxStderrBytes = 512 const maxStderrBytes = 512
// Exec defines the exec output plugin. // Exec defines the exec output plugin.
@ -29,6 +35,10 @@ type Exec struct {
serializer serializers.Serializer serializer serializers.Serializer
} }
func (*Exec) SampleConfig() string {
return sampleConfig
}
func (e *Exec) Init() error { func (e *Exec) Init() error {
e.runner = &CommandRunner{log: e.Log} e.runner = &CommandRunner{log: e.Log}

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 exec
func (e *Exec) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -6,7 +6,7 @@ Telegraf minimum version: Telegraf 1.15.0
## Configuration ## Configuration
```toml ```toml @sample.conf
# Run executable as long-running output plugin # Run executable as long-running output plugin
[[outputs.execd]] [[outputs.execd]]
## One program to run as daemon. ## One program to run as daemon.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package execd package execd
import ( import (
"bufio" "bufio"
_ "embed"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -14,6 +16,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Execd struct { type Execd struct {
Command []string `toml:"command"` Command []string `toml:"command"`
Environment []string `toml:"environment"` Environment []string `toml:"environment"`
@ -24,6 +30,10 @@ type Execd struct {
serializer serializers.Serializer serializer serializers.Serializer
} }
func (*Execd) SampleConfig() string {
return sampleConfig
}
func (e *Execd) SetSerializer(s serializers.Serializer) { func (e *Execd) SetSerializer(s serializers.Serializer) {
e.serializer = s e.serializer = s
} }

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 execd
func (e *Execd) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -4,7 +4,7 @@ This plugin writes telegraf metrics to files
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send telegraf metrics to file(s) # Send telegraf metrics to file(s)
[[outputs.file]] [[outputs.file]]
## Files to write to, "stdout" is a specially handled file. ## Files to write to, "stdout" is a specially handled file.

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package file package file
import ( import (
_ "embed"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -13,6 +15,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type File struct { type File struct {
Files []string `toml:"files"` Files []string `toml:"files"`
RotationInterval config.Duration `toml:"rotation_interval"` RotationInterval config.Duration `toml:"rotation_interval"`
@ -26,6 +32,10 @@ type File struct {
serializer serializers.Serializer serializer serializers.Serializer
} }
func (*File) SampleConfig() string {
return sampleConfig
}
func (f *File) SetSerializer(serializer serializers.Serializer) { func (f *File) SetSerializer(serializer serializers.Serializer) {
f.serializer = serializer f.serializer = serializer
} }

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 file
func (f *File) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -11,7 +11,7 @@ see the [Graphite Data Format][2].
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for Graphite server to send metrics to # Configuration for Graphite server to send metrics to
[[outputs.graphite]] [[outputs.graphite]]
## TCP endpoint for your graphite instance. ## TCP endpoint for your graphite instance.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package graphite package graphite
import ( import (
"crypto/tls" "crypto/tls"
_ "embed"
"errors" "errors"
"io" "io"
"math/rand" "math/rand"
@ -14,6 +16,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type Graphite struct { type Graphite struct {
GraphiteTagSupport bool `toml:"graphite_tag_support"` GraphiteTagSupport bool `toml:"graphite_tag_support"`
GraphiteTagSanitizeMode string `toml:"graphite_tag_sanitize_mode"` GraphiteTagSanitizeMode string `toml:"graphite_tag_sanitize_mode"`
@ -30,6 +36,10 @@ type Graphite struct {
tlsint.ClientConfig tlsint.ClientConfig
} }
func (*Graphite) SampleConfig() string {
return sampleConfig
}
func (g *Graphite) Connect() error { func (g *Graphite) Connect() error {
// Set default values // Set default values
if g.Timeout <= 0 { if g.Timeout <= 0 {

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 graphite
func (g *Graphite) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -23,7 +23,7 @@ the field name.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send telegraf metrics to graylog # Send telegraf metrics to graylog
[[outputs.graylog]] [[outputs.graylog]]
## Endpoints for your graylog instances. ## Endpoints for your graylog instances.

View File

@ -1,3 +1,4 @@
//go:generate ../../../tools/readme_config_includer/generator
package graylog package graylog
import ( import (
@ -5,6 +6,7 @@ import (
"compress/zlib" "compress/zlib"
"crypto/rand" "crypto/rand"
"crypto/tls" "crypto/tls"
_ "embed"
"encoding/binary" "encoding/binary"
ejson "encoding/json" ejson "encoding/json"
"fmt" "fmt"
@ -21,6 +23,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultEndpoint = "127.0.0.1:12201" defaultEndpoint = "127.0.0.1:12201"
defaultConnection = "wan" defaultConnection = "wan"
@ -317,6 +323,10 @@ type Graylog struct {
closers []io.WriteCloser closers []io.WriteCloser
} }
func (*Graylog) SampleConfig() string {
return sampleConfig
}
func (g *Graylog) Connect() error { func (g *Graylog) Connect() error {
var writers []io.Writer var writers []io.Writer
dialer := &net.Dialer{Timeout: time.Duration(g.Timeout)} dialer := &net.Dialer{Timeout: time.Duration(g.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 graylog
func (g *Graylog) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -7,7 +7,7 @@ GW8+
## Configuration ## Configuration
```toml ```toml @sample.conf
# Send telegraf metrics to GroundWork Monitor # Send telegraf metrics to GroundWork Monitor
[[outputs.groundwork]] [[outputs.groundwork]]
## URL of your groundwork instance. ## URL of your groundwork instance.

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package groundwork package groundwork
import ( import (
"bytes" "bytes"
"context" "context"
_ "embed"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
type metricMeta struct { type metricMeta struct {
group string group string
resource string resource string
@ -35,6 +41,10 @@ type Groundwork struct {
client clients.GWClient client clients.GWClient
} }
func (*Groundwork) SampleConfig() string {
return sampleConfig
}
func (g *Groundwork) Init() error { func (g *Groundwork) Init() error {
if g.Server == "" { if g.Server == "" {
return errors.New("no 'url' provided") return errors.New("no 'url' provided")

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 groundwork
func (g *Groundwork) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -9,7 +9,7 @@ must fail in order for the resource to enter the failed state.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configurable HTTP health check resource based on metrics # Configurable HTTP health check resource based on metrics
[[outputs.health]] [[outputs.health]]
## Address and port to listen on. ## Address and port to listen on.

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package health package health
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
_ "embed"
"errors" "errors"
"net" "net"
"net/http" "net/http"
@ -17,6 +19,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultServiceAddress = "tcp://:8080" defaultServiceAddress = "tcp://:8080"
defaultReadTimeout = 5 * time.Second defaultReadTimeout = 5 * time.Second
@ -52,6 +58,10 @@ type Health struct {
healthy bool healthy bool
} }
func (*Health) SampleConfig() string {
return sampleConfig
}
func (h *Health) Init() error { func (h *Health) Init() error {
u, err := url.Parse(h.ServiceAddress) u, err := url.Parse(h.ServiceAddress)
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 health
func (h *Health) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -6,7 +6,7 @@ format by default.
## Configuration ## Configuration
```toml ```toml @sample.conf
# A plugin that can transmit metrics over HTTP # A plugin that can transmit metrics over HTTP
[[outputs.http]] [[outputs.http]]
## URL is the address to send metrics to ## URL is the address to send metrics to

View File

@ -1,3 +1,4 @@
//go:generate ../../../tools/readme_config_includer/generator
package http package http
import ( import (
@ -5,6 +6,7 @@ import (
"bytes" "bytes"
"context" "context"
"crypto/sha256" "crypto/sha256"
_ "embed"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -13,6 +15,7 @@ import (
awsV2 "github.com/aws/aws-sdk-go-v2/aws" awsV2 "github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/config/aws" internalaws "github.com/influxdata/telegraf/config/aws"
"github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/internal"
@ -23,6 +26,10 @@ import (
"google.golang.org/api/idtoken" "google.golang.org/api/idtoken"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
maxErrMsgLen = 1024 maxErrMsgLen = 1024
defaultURL = "http://127.0.0.1:8080/telegraf" defaultURL = "http://127.0.0.1:8080/telegraf"
@ -58,6 +65,10 @@ type HTTP struct {
oauth2Token *oauth2.Token oauth2Token *oauth2.Token
} }
func (*HTTP) SampleConfig() string {
return sampleConfig
}
func (h *HTTP) SetSerializer(serializer serializers.Serializer) { func (h *HTTP) SetSerializer(serializer serializers.Serializer) {
h.serializer = serializer h.serializer = serializer
} }

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 http
func (h *HTTP) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -19,6 +19,9 @@
# token_url = "https://indentityprovider/oauth2/v1/token" # token_url = "https://indentityprovider/oauth2/v1/token"
# scopes = ["urn:opc:idm:__myscopes__"] # scopes = ["urn:opc:idm:__myscopes__"]
## Goole API Auth
# google_application_credentials = "/etc/telegraf/example_secret.json"
## Optional TLS Config ## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem" # tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem" # tls_cert = "/etc/telegraf/cert.pem"

View File

@ -5,7 +5,7 @@ service.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for sending metrics to InfluxDB # Configuration for sending metrics to InfluxDB
[[outputs.influxdb]] [[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance. ## The full HTTP or UDP URL for your InfluxDB instance.

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
//nolint //nolint
package influxdb package influxdb
import ( import (
"context" "context"
_ "embed"
"errors" "errors"
"fmt" "fmt"
"math/rand" "math/rand"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/plugins/serializers/influx"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
var ( var (
defaultURL = "http://localhost:8086" defaultURL = "http://localhost:8086"
@ -63,6 +69,10 @@ type InfluxDB struct {
Log telegraf.Logger Log telegraf.Logger
} }
func (*InfluxDB) SampleConfig() string {
return sampleConfig
}
func (i *InfluxDB) Connect() error { func (i *InfluxDB) Connect() 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 influxdb
func (i *InfluxDB) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -4,7 +4,7 @@ The InfluxDB output plugin writes metrics to the [InfluxDB v2.x] HTTP service.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for sending metrics to InfluxDB 2.0 # Configuration for sending metrics to InfluxDB 2.0
[[outputs.influxdb_v2]] [[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes. ## The URLs of the InfluxDB cluster nodes.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package influxdb_v2 package influxdb_v2
import ( import (
"context" "context"
_ "embed"
"errors" "errors"
"fmt" "fmt"
"math/rand" "math/rand"
@ -15,6 +17,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers/influx" "github.com/influxdata/telegraf/plugins/serializers/influx"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
var ( var (
defaultURL = "http://localhost:8086" defaultURL = "http://localhost:8086"
@ -48,6 +54,10 @@ type InfluxDB struct {
clients []Client clients []Client
} }
func (*InfluxDB) SampleConfig() string {
return sampleConfig
}
func (i *InfluxDB) Connect() error { func (i *InfluxDB) Connect() error {
if len(i.URLs) == 0 { if len(i.URLs) == 0 {
i.URLs = append(i.URLs, defaultURL) i.URLs = append(i.URLs, defaultURL)

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 influxdb_v2
func (i *InfluxDB) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -11,7 +11,7 @@ used if the metric comes in as a counter through `[[input.statsd]]`.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for sending metrics to an Instrumental project # Configuration for sending metrics to an Instrumental project
[[outputs.instrumental]] [[outputs.instrumental]]
## Project API Token (required) ## Project API Token (required)

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package instrumental package instrumental
import ( import (
"bytes" "bytes"
_ "embed"
"fmt" "fmt"
"io" "io"
"net" "net"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers/graphite" "github.com/influxdata/telegraf/plugins/serializers/graphite"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
var ( var (
ValueIncludesBadChar = regexp.MustCompile("[^[:digit:].]") ValueIncludesBadChar = regexp.MustCompile("[^[:digit:].]")
MetricNameReplacer = regexp.MustCompile("[^-[:alnum:]_.]+") MetricNameReplacer = regexp.MustCompile("[^-[:alnum:]_.]+")
@ -43,6 +49,10 @@ const (
HandshakeFormat = HelloMessage + AuthFormat HandshakeFormat = HelloMessage + AuthFormat
) )
func (*Instrumental) SampleConfig() string {
return sampleConfig
}
func (i *Instrumental) Connect() error { func (i *Instrumental) Connect() error {
connection, err := net.DialTimeout("tcp", i.Host+":8000", time.Duration(i.Timeout)) connection, err := net.DialTimeout("tcp", i.Host+":8000", time.Duration(i.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 instrumental
func (i *Instrumental) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -5,7 +5,7 @@ Broker](http://kafka.apache.org/07/quickstart.html) acting a Kafka Producer.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for the Kafka server to send metrics to # Configuration for the Kafka server to send metrics to
[[outputs.kafka]] [[outputs.kafka]]
## URLs of kafka brokers ## URLs of kafka brokers

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package kafka package kafka
import ( import (
_ "embed"
"fmt" "fmt"
"log" "log"
"strings" "strings"
@ -16,6 +18,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
var ValidTopicSuffixMethods = []string{ var ValidTopicSuffixMethods = []string{
"", "",
"measurement", "measurement",
@ -89,6 +95,10 @@ func ValidateTopicSuffixMethod(method string) error {
return fmt.Errorf("unknown topic suffix method provided: %s", method) return fmt.Errorf("unknown topic suffix method provided: %s", method)
} }
func (*Kafka) SampleConfig() string {
return sampleConfig
}
func (k *Kafka) GetTopicName(metric telegraf.Metric) (telegraf.Metric, string) { func (k *Kafka) GetTopicName(metric telegraf.Metric) (telegraf.Metric, string) {
topic := k.Topic topic := k.Topic
if k.TopicTag != "" { if k.TopicTag != "" {

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 kafka
func (k *Kafka) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -36,7 +36,7 @@ will be used.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for the AWS Kinesis output. # Configuration for the AWS Kinesis output.
[[outputs.kinesis]] [[outputs.kinesis]]
## Amazon REGION of kinesis endpoint. ## Amazon REGION of kinesis endpoint.

View File

@ -1,19 +1,26 @@
//go:generate ../../../tools/readme_config_includer/generator
package kinesis package kinesis
import ( import (
"context" "context"
_ "embed"
"time" "time"
"github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/kinesis" "github.com/aws/aws-sdk-go-v2/service/kinesis"
"github.com/aws/aws-sdk-go-v2/service/kinesis/types" "github.com/aws/aws-sdk-go-v2/service/kinesis/types"
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/config/aws" internalaws "github.com/influxdata/telegraf/config/aws"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/plugins/serializers" "github.com/influxdata/telegraf/plugins/serializers"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// Limit set by AWS (https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecords.html) // Limit set by AWS (https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecords.html)
const maxRecordsPerRequest uint32 = 500 const maxRecordsPerRequest uint32 = 500
@ -43,6 +50,10 @@ type kinesisClient interface {
PutRecords(context.Context, *kinesis.PutRecordsInput, ...func(*kinesis.Options)) (*kinesis.PutRecordsOutput, error) PutRecords(context.Context, *kinesis.PutRecordsInput, ...func(*kinesis.Options)) (*kinesis.PutRecordsOutput, error)
} }
func (*KinesisOutput) SampleConfig() string {
return sampleConfig
}
func (k *KinesisOutput) Connect() error { func (k *KinesisOutput) Connect() error {
if k.Partition == nil { if k.Partition == nil {
k.Log.Error("Deprecated partitionkey configuration in use, please consider using outputs.kinesis.partition") k.Log.Error("Deprecated partitionkey configuration in use, please consider using outputs.kinesis.partition")

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 kinesis
func (k *KinesisOutput) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -17,7 +17,7 @@ Currently, the plugin does not send any associated Point Tags.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for Librato API to send metrics to. # Configuration for Librato API to send metrics to.
[[outputs.librato]] [[outputs.librato]]
## Librato API Docs ## Librato API Docs

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package librato package librato
import ( import (
"bytes" "bytes"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@ -15,6 +17,10 @@ import (
"github.com/influxdata/telegraf/plugins/serializers/graphite" "github.com/influxdata/telegraf/plugins/serializers/graphite"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
// Librato structure for configuration and client // Librato structure for configuration and client
type Librato struct { type Librato struct {
APIUser string `toml:"api_user"` APIUser string `toml:"api_user"`
@ -55,6 +61,10 @@ func NewLibrato(apiURL string) *Librato {
} }
} }
func (*Librato) SampleConfig() string {
return sampleConfig
}
// Connect is the default output plugin connection function who make sure it // Connect is the default output plugin connection function who make sure it
// can connect to the endpoint // can connect to the endpoint
func (l *Librato) Connect() error { func (l *Librato) Connect() 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 librato
func (l *Librato) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -4,7 +4,7 @@ This plugin sends metrics to Logz.io over HTTPs.
## Configuration ## Configuration
```toml ```toml @sample.conf
# A plugin that can send metrics over HTTPs to Logz.io # A plugin that can send metrics over HTTPs to Logz.io
[[outputs.logzio]] [[outputs.logzio]]
## Set to true if Logz.io sender checks the disk space before adding metrics to the disk queue. ## Set to true if Logz.io sender checks the disk space before adding metrics to the disk queue.

View File

@ -1,11 +1,12 @@
//go:generate ../../../tools/readme_config_includer/generator
package logzio package logzio
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
@ -15,6 +16,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultLogzioURL = "https://listener.logz.io:8071" defaultLogzioURL = "https://listener.logz.io:8071"
@ -43,6 +48,10 @@ type Metric struct {
Type string `json:"type"` Type string `json:"type"`
} }
func (*Logzio) SampleConfig() string {
return sampleConfig
}
// Connect to the Output // Connect to the Output
func (l *Logzio) Connect() error { func (l *Logzio) Connect() error {
l.Log.Debug("Connecting to logz.io output...") l.Log.Debug("Connecting to logz.io output...")

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 logzio
func (l *Logzio) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -8,7 +8,7 @@ Logs within each stream are sorted by timestamp before being sent to Loki.
## Configuration ## Configuration
```toml ```toml @sample.conf
# A plugin that can transmit logs to Loki # A plugin that can transmit logs to Loki
[[outputs.loki]] [[outputs.loki]]
## The domain of Loki ## The domain of Loki

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package loki package loki
import ( import (
"bytes" "bytes"
"context" "context"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@ -21,6 +23,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
const ( const (
defaultEndpoint = "/loki/api/v1/push" defaultEndpoint = "/loki/api/v1/push"
defaultClientTimeout = 5 * time.Second defaultClientTimeout = 5 * time.Second
@ -72,6 +78,10 @@ func (l *Loki) createClient(ctx context.Context) (*http.Client, error) {
return client, nil return client, nil
} }
func (*Loki) SampleConfig() string {
return sampleConfig
}
func (l *Loki) Connect() (err error) { func (l *Loki) Connect() (err error) {
if l.Domain == "" { if l.Domain == "" {
return fmt.Errorf("domain is required") return fmt.Errorf("domain is required")

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 loki
func (l *Loki) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -6,7 +6,7 @@ Requires MongoDB 5.0+ for Time Series Collections
## Configuration ## Configuration
```toml ```toml @sample.conf
# A plugin that can transmit logs to mongodb # A plugin that can transmit logs to mongodb
[[outputs.mongodb]] [[outputs.mongodb]]
# connection string examples for mongodb # connection string examples for mongodb

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package mongodb package mongodb
import ( import (
"context" "context"
_ "embed"
"fmt" "fmt"
"net/url" "net/url"
"strconv" "strconv"
@ -19,6 +21,10 @@ import (
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
) )
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embedd the sampleConfig data.
//go:embed sample.conf
var sampleConfig string
func (s *MongoDB) getCollections(ctx context.Context) error { func (s *MongoDB) getCollections(ctx context.Context) error {
s.collections = map[string]bson.M{} s.collections = map[string]bson.M{}
collections, err := s.client.Database(s.MetricDatabase).ListCollections(ctx, bson.M{}) collections, err := s.client.Database(s.MetricDatabase).ListCollections(ctx, bson.M{})
@ -61,6 +67,10 @@ type MongoDB struct {
tls.ClientConfig tls.ClientConfig
} }
func (*MongoDB) SampleConfig() string {
return sampleConfig
}
func (s *MongoDB) Init() error { func (s *MongoDB) Init() error {
if s.MetricDatabase == "" { if s.MetricDatabase == "" {
s.MetricDatabase = "telegraf" s.MetricDatabase = "telegraf"

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 mongodb
func (s *MongoDB) SampleConfig() string {
return `{{ .SampleConfig }}`
}

View File

@ -14,7 +14,7 @@ As a reference `eclipse/paho.mqtt.golang` sets the `keep_alive` to 30.
## Configuration ## Configuration
```toml ```toml @sample.conf
# Configuration for MQTT server to send metrics to # Configuration for MQTT server to send metrics to
[[outputs.mqtt]] [[outputs.mqtt]]
## MQTT Brokers ## MQTT Brokers

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