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/$*/...
.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
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
build:

View File

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

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package amon
import (
"bytes"
_ "embed"
"encoding/json"
"fmt"
"net/http"
@ -13,6 +15,10 @@ import (
"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 {
ServerKey string `toml:"server_key"`
AmonInstance string `toml:"amon_instance"`
@ -33,6 +39,10 @@ type Metric struct {
type Point [2]float64
func (*Amon) SampleConfig() string {
return sampleConfig
}
func (a *Amon) Connect() error {
if a.ServerKey == "" || a.AmonInstance == "" {
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
```toml
```toml @sample.conf
# Publishes metrics to an AMQP broker
[[outputs.amqp]]
## Broker to publish to.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package amqp
import (
"bytes"
_ "embed"
"strings"
"time"
@ -15,6 +17,10 @@ import (
"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 (
DefaultURL = "amqp://localhost:5672/influxdb"
DefaultAuthMethod = "PLAIN"
@ -71,6 +77,10 @@ type Client interface {
Close() error
}
func (*AMQP) SampleConfig() string {
return sampleConfig
}
func (q *AMQP) SetSerializer(serializer serializers.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
```toml
```toml @sample.conf
# Send metrics to Azure Application Insights
[[outputs.application_insights]]
## Instrumentation key of the Application Insights resource.

View File

@ -1,17 +1,24 @@
//go:generate ../../../tools/readme_config_includer/generator
package application_insights
import (
_ "embed"
"fmt"
"math"
"time"
"unsafe"
"github.com/microsoft/ApplicationInsights-Go/appinsights"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
"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 {
Track(appinsights.Telemetry)
Close() <-chan struct{}
@ -39,6 +46,10 @@ var (
is32BitChecked bool
)
func (*ApplicationInsights) SampleConfig() string {
return sampleConfig
}
func (a *ApplicationInsights) Connect() error {
if a.InstrumentationKey == "" {
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
```toml
```toml @sample.conf
# Sends metrics to Azure Data Explorer
[[outputs.azure_data_explorer]]
## 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
import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
"io"
@ -13,6 +15,7 @@ import (
"github.com/Azure/azure-kusto-go/kusto/ingest"
"github.com/Azure/azure-kusto-go/kusto/unsafe"
"github.com/Azure/go-autorest/autorest/azure/auth"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/plugins/outputs"
@ -20,6 +23,10 @@ import (
"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 {
Endpoint string `toml:"endpoint_url"`
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 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 {
authorizer, err := auth.NewAuthorizerFromEnvironmentWithResource(adx.Endpoint)
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
```toml
```toml @sample.conf
# Send aggregate metrics to Azure Monitor
[[outputs.azure_monitor]]
## Timeout for HTTP writes.

View File

@ -1,9 +1,11 @@
//go:generate ../../../tools/readme_config_includer/generator
package azure_monitor
import (
"bytes"
"compress/gzip"
"context"
_ "embed"
"encoding/binary"
"encoding/json"
"fmt"
@ -25,6 +27,10 @@ import (
"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
// service
type AzureMonitor struct {
@ -103,6 +109,10 @@ const (
maxRequestBodySize = 4000000
)
func (*AzureMonitor) SampleConfig() string {
return sampleConfig
}
// Connect initializes the plugin and validates connectivity
func (a *AzureMonitor) Connect() error {
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
```toml
```toml @sample.conf
# Configuration for Google Cloud BigQuery to send entries
[[outputs.bigquery]]
## Credentials File

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package bigquery
import (
"context"
_ "embed"
"fmt"
"reflect"
"strings"
@ -17,6 +19,10 @@ import (
"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"
var defaultTimeout = config.Duration(5 * time.Second)
@ -36,6 +42,10 @@ type BigQuery struct {
warnedOnHyphens map[string]bool
}
func (*BigQuery) SampleConfig() string {
return sampleConfig
}
func (s *BigQuery) Connect() error {
if s.Project == "" {
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
```toml
```toml @sample.conf
# Publish Telegraf metrics to a Google Cloud PubSub topic
[[outputs.cloud_pubsub]]
## 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
import (
"context"
_ "embed"
"encoding/base64"
"fmt"
"sync"
"time"
"cloud.google.com/go/pubsub"
"golang.org/x/oauth2/google"
"google.golang.org/api/option"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/outputs"
"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 {
CredentialsFile string `toml:"credentials_file"`
Project string `toml:"project"`
@ -41,6 +48,10 @@ type PubSub struct {
publishResults []publishResult
}
func (*PubSub) SampleConfig() string {
return sampleConfig
}
func (ps *PubSub) SetSerializer(serializer serializers.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
```toml
```toml @sample.conf
# Configuration for AWS CloudWatch output.
[[outputs.cloudwatch]]
## Amazon REGION

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package cloudwatch
import (
"context"
_ "embed"
"math"
"sort"
"strings"
@ -16,6 +18,10 @@ import (
"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 {
Namespace string `toml:"namespace"` // CloudWatch Metrics Namespace
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 {
cfg, err := c.CredentialConfig.Credentials()
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
```toml
```toml @sample.conf
# Configuration for AWS CloudWatchLogs output.
[[outputs.cloudwatch_logs]]
## 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
import (
"context"
_ "embed"
"fmt"
"sort"
"strings"
@ -9,11 +11,16 @@ import (
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"
"github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/config/aws"
"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 {
logEvents []types.InputLogEvent
messageCount int
@ -73,6 +80,10 @@ const (
// Otherwise, the operation fails.
)
func (*CloudWatchLogs) SampleConfig() string {
return sampleConfig
}
// Init initialize plugin with checking configuration parameters
func (c *CloudWatchLogs) Init() error {
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
```toml
```toml @sample.conf
# Configuration for CrateDB to send metrics to.
[[outputs.cratedb]]
# A github.com/jackc/pgx/v4 connection string.

View File

@ -1,9 +1,11 @@
//go:generate ../../../tools/readme_config_includer/generator
package cratedb
import (
"context"
"crypto/sha512"
"database/sql"
_ "embed"
"encoding/binary"
"fmt"
"sort"
@ -18,6 +20,10 @@ import (
"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)
type CrateDB struct {
@ -29,6 +35,10 @@ type CrateDB struct {
DB *sql.DB
}
func (*CrateDB) SampleConfig() string {
return sampleConfig
}
func (c *CrateDB) Connect() error {
db, err := sql.Open("pgx", c.URL)
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
```toml
```toml @sample.conf
# Configuration for DataDog API to send metrics to.
[[outputs.datadog]]
## Datadog API key

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package datadog
import (
"bytes"
_ "embed"
"encoding/json"
"fmt"
"math"
@ -17,6 +19,10 @@ import (
"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 {
Apikey string `toml:"apikey"`
Timeout config.Duration `toml:"timeout"`
@ -45,6 +51,10 @@ type Point [2]float64
const datadogAPI = "https://app.datadoghq.com/api/v1/series"
func (*Datadog) SampleConfig() string {
return sampleConfig
}
func (d *Datadog) Connect() error {
if d.Apikey == "" {
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
```toml
```toml @sample.conf
# Send metrics to nowhere at all
[[outputs.discard]]
# no configuration

View File

@ -1,12 +1,23 @@
//go:generate ../../../tools/readme_config_includer/generator
package discard
import (
_ "embed"
"github.com/influxdata/telegraf"
"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{}
func (*Discard) SampleConfig() string {
return sampleConfig
}
func (d *Discard) Connect() error { return nil }
func (d *Discard) Close() error { return nil }
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
```toml
```toml @sample.conf
# Send telegraf metrics to a Dynatrace environment
[[outputs.dynatrace]]
## 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
import (
"bytes"
_ "embed"
"fmt"
"io"
"net/http"
"strings"
"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/config"
"github.com/influxdata/telegraf/plugins/common/tls"
"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
type Dynatrace struct {
URL string `toml:"url"`
@ -38,6 +44,10 @@ type Dynatrace struct {
loggedMetrics map[string]bool // New empty set
}
func (*Dynatrace) SampleConfig() string {
return sampleConfig
}
// Connect Connects the Dynatrace output plugin to the Telegraf stream
func (d *Dynatrace) Connect() error {
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
```toml
```toml @sample.conf
# Configuration for Elasticsearch to send metrics to.
[[outputs.elasticsearch]]
## The full HTTP endpoint URL for your Elasticsearch instance

View File

@ -1,8 +1,11 @@
//go:generate ../../../tools/readme_config_includer/generator
package elasticsearch
import (
"bytes"
"context"
"crypto/sha256"
_ "embed"
"fmt"
"math"
"net/http"
@ -12,8 +15,6 @@ import (
"text/template"
"time"
"crypto/sha256"
"github.com/olivere/elastic"
"github.com/influxdata/telegraf"
@ -22,6 +23,10 @@ import (
"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 {
AuthBearerToken string `toml:"auth_bearer_token"`
DefaultPipeline string `toml:"default_pipeline"`
@ -127,6 +132,10 @@ type templatePart struct {
Version int
}
func (*Elasticsearch) SampleConfig() string {
return sampleConfig
}
func (a *Elasticsearch) Connect() error {
if a.URLs == nil || a.IndexName == "" {
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
```toml
```toml @sample.conf
# Configuration for Event Hubs output plugin
[[outputs.event_hubs]]
## 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
import (
"context"
_ "embed"
"time"
eventhub "github.com/Azure/azure-event-hubs-go/v3"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
"github.com/influxdata/telegraf/plugins/outputs"
"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
*/
@ -61,6 +68,10 @@ const (
defaultRequestTimeout = time.Second * 30
)
func (*EventHubs) SampleConfig() string {
return sampleConfig
}
func (e *EventHubs) Init() error {
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 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"
## Client timeout (defaults to 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.
## Each data format has its own unique set of configuration options, read
## more about them here:

View File

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

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package exec
import (
"bytes"
_ "embed"
"fmt"
"io"
"os"
@ -16,6 +18,10 @@ import (
"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
// Exec defines the exec output plugin.
@ -29,6 +35,10 @@ type Exec struct {
serializer serializers.Serializer
}
func (*Exec) SampleConfig() string {
return sampleConfig
}
func (e *Exec) Init() error {
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
```toml
```toml @sample.conf
# Run executable as long-running output plugin
[[outputs.execd]]
## One program to run as daemon.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package execd
import (
"bufio"
_ "embed"
"fmt"
"io"
"strings"
@ -14,6 +16,10 @@ import (
"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 {
Command []string `toml:"command"`
Environment []string `toml:"environment"`
@ -24,6 +30,10 @@ type Execd struct {
serializer serializers.Serializer
}
func (*Execd) SampleConfig() string {
return sampleConfig
}
func (e *Execd) SetSerializer(s serializers.Serializer) {
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
```toml
```toml @sample.conf
# Send telegraf metrics to file(s)
[[outputs.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
import (
_ "embed"
"fmt"
"io"
"os"
@ -13,6 +15,10 @@ import (
"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 {
Files []string `toml:"files"`
RotationInterval config.Duration `toml:"rotation_interval"`
@ -26,6 +32,10 @@ type File struct {
serializer serializers.Serializer
}
func (*File) SampleConfig() string {
return sampleConfig
}
func (f *File) SetSerializer(serializer serializers.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
```toml
```toml @sample.conf
# Configuration for Graphite server to send metrics to
[[outputs.graphite]]
## TCP endpoint for your graphite instance.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package graphite
import (
"crypto/tls"
_ "embed"
"errors"
"io"
"math/rand"
@ -14,6 +16,10 @@ import (
"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 {
GraphiteTagSupport bool `toml:"graphite_tag_support"`
GraphiteTagSanitizeMode string `toml:"graphite_tag_sanitize_mode"`
@ -30,6 +36,10 @@ type Graphite struct {
tlsint.ClientConfig
}
func (*Graphite) SampleConfig() string {
return sampleConfig
}
func (g *Graphite) Connect() error {
// Set default values
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
```toml
```toml @sample.conf
# Send telegraf metrics to graylog
[[outputs.graylog]]
## Endpoints for your graylog instances.

View File

@ -1,3 +1,4 @@
//go:generate ../../../tools/readme_config_includer/generator
package graylog
import (
@ -5,6 +6,7 @@ import (
"compress/zlib"
"crypto/rand"
"crypto/tls"
_ "embed"
"encoding/binary"
ejson "encoding/json"
"fmt"
@ -21,6 +23,10 @@ import (
"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 (
defaultEndpoint = "127.0.0.1:12201"
defaultConnection = "wan"
@ -317,6 +323,10 @@ type Graylog struct {
closers []io.WriteCloser
}
func (*Graylog) SampleConfig() string {
return sampleConfig
}
func (g *Graylog) Connect() error {
var writers []io.Writer
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
```toml
```toml @sample.conf
# Send telegraf metrics to GroundWork Monitor
[[outputs.groundwork]]
## URL of your groundwork instance.

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package groundwork
import (
"bytes"
"context"
_ "embed"
"encoding/json"
"errors"
"fmt"
@ -17,6 +19,10 @@ import (
"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 {
group string
resource string
@ -35,6 +41,10 @@ type Groundwork struct {
client clients.GWClient
}
func (*Groundwork) SampleConfig() string {
return sampleConfig
}
func (g *Groundwork) Init() error {
if g.Server == "" {
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
```toml
```toml @sample.conf
# Configurable HTTP health check resource based on metrics
[[outputs.health]]
## Address and port to listen on.

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package health
import (
"context"
"crypto/tls"
_ "embed"
"errors"
"net"
"net/http"
@ -17,6 +19,10 @@ import (
"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 (
defaultServiceAddress = "tcp://:8080"
defaultReadTimeout = 5 * time.Second
@ -52,6 +58,10 @@ type Health struct {
healthy bool
}
func (*Health) SampleConfig() string {
return sampleConfig
}
func (h *Health) Init() error {
u, err := url.Parse(h.ServiceAddress)
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
```toml
```toml @sample.conf
# A plugin that can transmit metrics over HTTP
[[outputs.http]]
## URL is the address to send metrics to

View File

@ -1,3 +1,4 @@
//go:generate ../../../tools/readme_config_includer/generator
package http
import (
@ -5,6 +6,7 @@ import (
"bytes"
"context"
"crypto/sha256"
_ "embed"
"fmt"
"io"
"net/http"
@ -13,6 +15,7 @@ import (
awsV2 "github.com/aws/aws-sdk-go-v2/aws"
v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/config/aws"
"github.com/influxdata/telegraf/internal"
@ -23,6 +26,10 @@ import (
"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 (
maxErrMsgLen = 1024
defaultURL = "http://127.0.0.1:8080/telegraf"
@ -58,6 +65,10 @@ type HTTP struct {
oauth2Token *oauth2.Token
}
func (*HTTP) SampleConfig() string {
return sampleConfig
}
func (h *HTTP) SetSerializer(serializer serializers.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"
# scopes = ["urn:opc:idm:__myscopes__"]
## Goole API Auth
# google_application_credentials = "/etc/telegraf/example_secret.json"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"

View File

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

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
//nolint
package influxdb
import (
"context"
_ "embed"
"errors"
"fmt"
"math/rand"
@ -16,6 +18,10 @@ import (
"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 (
defaultURL = "http://localhost:8086"
@ -63,6 +69,10 @@ type InfluxDB struct {
Log telegraf.Logger
}
func (*InfluxDB) SampleConfig() string {
return sampleConfig
}
func (i *InfluxDB) Connect() error {
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
```toml
```toml @sample.conf
# Configuration for sending metrics to InfluxDB 2.0
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes.

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package influxdb_v2
import (
"context"
_ "embed"
"errors"
"fmt"
"math/rand"
@ -15,6 +17,10 @@ import (
"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 (
defaultURL = "http://localhost:8086"
@ -48,6 +54,10 @@ type InfluxDB struct {
clients []Client
}
func (*InfluxDB) SampleConfig() string {
return sampleConfig
}
func (i *InfluxDB) Connect() error {
if len(i.URLs) == 0 {
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
```toml
```toml @sample.conf
# Configuration for sending metrics to an Instrumental project
[[outputs.instrumental]]
## Project API Token (required)

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package instrumental
import (
"bytes"
_ "embed"
"fmt"
"io"
"net"
@ -16,6 +18,10 @@ import (
"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 (
ValueIncludesBadChar = regexp.MustCompile("[^[:digit:].]")
MetricNameReplacer = regexp.MustCompile("[^-[:alnum:]_.]+")
@ -43,6 +49,10 @@ const (
HandshakeFormat = HelloMessage + AuthFormat
)
func (*Instrumental) SampleConfig() string {
return sampleConfig
}
func (i *Instrumental) Connect() error {
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
```toml
```toml @sample.conf
# Configuration for the Kafka server to send metrics to
[[outputs.kafka]]
## URLs of kafka brokers

View File

@ -1,6 +1,8 @@
//go:generate ../../../tools/readme_config_includer/generator
package kafka
import (
_ "embed"
"fmt"
"log"
"strings"
@ -16,6 +18,10 @@ import (
"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{
"",
"measurement",
@ -89,6 +95,10 @@ func ValidateTopicSuffixMethod(method string) error {
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) {
topic := k.Topic
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
```toml
```toml @sample.conf
# Configuration for the AWS Kinesis output.
[[outputs.kinesis]]
## Amazon REGION of kinesis endpoint.

View File

@ -1,19 +1,26 @@
//go:generate ../../../tools/readme_config_includer/generator
package kinesis
import (
"context"
_ "embed"
"time"
"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/types"
"github.com/gofrs/uuid"
"github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/config/aws"
"github.com/influxdata/telegraf/plugins/outputs"
"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)
const maxRecordsPerRequest uint32 = 500
@ -43,6 +50,10 @@ type kinesisClient interface {
PutRecords(context.Context, *kinesis.PutRecordsInput, ...func(*kinesis.Options)) (*kinesis.PutRecordsOutput, error)
}
func (*KinesisOutput) SampleConfig() string {
return sampleConfig
}
func (k *KinesisOutput) Connect() error {
if k.Partition == nil {
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
```toml
```toml @sample.conf
# Configuration for Librato API to send metrics to.
[[outputs.librato]]
## Librato API Docs

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package librato
import (
"bytes"
_ "embed"
"encoding/json"
"fmt"
"io"
@ -15,6 +17,10 @@ import (
"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
type Librato struct {
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
// can connect to the endpoint
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
```toml
```toml @sample.conf
# A plugin that can send metrics over HTTPs to Logz.io
[[outputs.logzio]]
## 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
import (
"bytes"
"compress/gzip"
_ "embed"
"encoding/json"
"fmt"
"net/http"
"time"
@ -15,6 +16,10 @@ import (
"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 (
defaultLogzioURL = "https://listener.logz.io:8071"
@ -43,6 +48,10 @@ type Metric struct {
Type string `json:"type"`
}
func (*Logzio) SampleConfig() string {
return sampleConfig
}
// Connect to the Output
func (l *Logzio) Connect() error {
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
```toml
```toml @sample.conf
# A plugin that can transmit logs to Loki
[[outputs.loki]]
## The domain of Loki

View File

@ -1,8 +1,10 @@
//go:generate ../../../tools/readme_config_includer/generator
package loki
import (
"bytes"
"context"
_ "embed"
"encoding/json"
"fmt"
"io"
@ -21,6 +23,10 @@ import (
"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 (
defaultEndpoint = "/loki/api/v1/push"
defaultClientTimeout = 5 * time.Second
@ -72,6 +78,10 @@ func (l *Loki) createClient(ctx context.Context) (*http.Client, error) {
return client, nil
}
func (*Loki) SampleConfig() string {
return sampleConfig
}
func (l *Loki) Connect() (err error) {
if l.Domain == "" {
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
```toml
```toml @sample.conf
# A plugin that can transmit logs to mongodb
[[outputs.mongodb]]
# connection string examples for mongodb

View File

@ -1,7 +1,9 @@
//go:generate ../../../tools/readme_config_includer/generator
package mongodb
import (
"context"
_ "embed"
"fmt"
"net/url"
"strconv"
@ -19,6 +21,10 @@ import (
"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 {
s.collections = map[string]bson.M{}
collections, err := s.client.Database(s.MetricDatabase).ListCollections(ctx, bson.M{})
@ -61,6 +67,10 @@ type MongoDB struct {
tls.ClientConfig
}
func (*MongoDB) SampleConfig() string {
return sampleConfig
}
func (s *MongoDB) Init() error {
if s.MetricDatabase == "" {
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
```toml
```toml @sample.conf
# Configuration for MQTT server to send metrics to
[[outputs.mqtt]]
## MQTT Brokers

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