diff --git a/go.mod b/go.mod index d12829324550e..707f53472a0c3 100644 --- a/go.mod +++ b/go.mod @@ -181,7 +181,7 @@ require ( github.com/vapourismo/knx-go v0.0.0-20220829185957-fb5458a5389d github.com/vjeantet/grok v1.0.1 github.com/vmware/govmomi v0.32.0 - github.com/wavefronthq/wavefront-sdk-go v0.14.0 + github.com/wavefronthq/wavefront-sdk-go v0.15.0 github.com/wvanbergen/kafka v0.0.0-20171203153745-e2edea948ddf github.com/x448/float16 v0.8.4 github.com/xdg/scram v1.0.5 diff --git a/go.sum b/go.sum index db5a25c4fab32..e541ff6e98922 100644 --- a/go.sum +++ b/go.sum @@ -1511,8 +1511,8 @@ github.com/vjeantet/grok v1.0.1 h1:2rhIR7J4gThTgcZ1m2JY4TrJZNgjn985U28kT2wQrJ4= github.com/vjeantet/grok v1.0.1/go.mod h1:ax1aAchzC6/QMXMcyzHQGZWaW1l195+uMYIkCWPCNIo= github.com/vmware/govmomi v0.32.0 h1:Rsdi/HAX5Ebf9Byp/FvBir4sfM7yP5DBUeRlbC6vLBo= github.com/vmware/govmomi v0.32.0/go.mod h1:JA63Pg0SgQcSjk+LuPzjh3rJdcWBo/ZNCIwbb1qf2/0= -github.com/wavefronthq/wavefront-sdk-go v0.14.0 h1:Nq+yobFZrVw3bfXh+EsWmWDtwMHYRKLRVXgnB1S0j34= -github.com/wavefronthq/wavefront-sdk-go v0.14.0/go.mod h1:V72c8e+bXuLK8HpA6ioW0ll5mK9IPD+4IHNNDY75ksA= +github.com/wavefronthq/wavefront-sdk-go v0.15.0 h1:po9E3vh/0y7kOx8D9EtFp7kbSLLLKbmu/w/s1xGJAQU= +github.com/wavefronthq/wavefront-sdk-go v0.15.0/go.mod h1:V72c8e+bXuLK8HpA6ioW0ll5mK9IPD+4IHNNDY75ksA= github.com/wvanbergen/kafka v0.0.0-20171203153745-e2edea948ddf h1:TOV5PC6fIWwFOFra9xJfRXZcL2pLhMI8oNuDugNxg9Q= github.com/wvanbergen/kafka v0.0.0-20171203153745-e2edea948ddf/go.mod h1:nxx7XRXbR9ykhnC8lXqQyJS0rfvJGxKyKw/sT1YOttg= github.com/wvanbergen/kazoo-go v0.0.0-20180202103751-f72d8611297a h1:ILoU84rj4AQ3q6cjQvtb9jBjx4xzR/Riq/zYhmDQiOk= diff --git a/plugins/outputs/wavefront/README.md b/plugins/outputs/wavefront/README.md index 43369b4ad3569..cabd389943fa2 100644 --- a/plugins/outputs/wavefront/README.md +++ b/plugins/outputs/wavefront/README.md @@ -89,6 +89,20 @@ to use them. ## HTTP Timeout # timeout="10s" + ## MaxIdleConns controls the maximum number of idle (keep-alive) + ## connections across all hosts. Zero means no limit. + # max_idle_conn = 0 + + ## MaxIdleConnsPerHost, if non-zero, controls the maximum idle + ## (keep-alive) connections to keep per-host. If zero, + ## DefaultMaxIdleConnsPerHost is used(2). + # max_idle_conn_per_host = 2 + + ## Idle (keep-alive) connection timeout. + ## Maximum amount of time before idle connection is closed. + ## Zero means no limit. + # idle_conn_timeout = 0 + ## Authentication for Direct Ingestion. ## Direct Ingestion requires one of: `token`,`auth_csp_api_token`, or `auth_csp_client_credentials` ## See https://docs.wavefront.com/csp_getting_started.html to learn more about using CSP credentials with Wavefront. diff --git a/plugins/outputs/wavefront/sample.conf b/plugins/outputs/wavefront/sample.conf index 3433644e6895b..a45558e952912 100644 --- a/plugins/outputs/wavefront/sample.conf +++ b/plugins/outputs/wavefront/sample.conf @@ -64,6 +64,20 @@ ## HTTP Timeout # timeout="10s" + ## MaxIdleConns controls the maximum number of idle (keep-alive) + ## connections across all hosts. Zero means no limit. + # max_idle_conn = 0 + + ## MaxIdleConnsPerHost, if non-zero, controls the maximum idle + ## (keep-alive) connections to keep per-host. If zero, + ## DefaultMaxIdleConnsPerHost is used(2). + # max_idle_conn_per_host = 2 + + ## Idle (keep-alive) connection timeout. + ## Maximum amount of time before idle connection is closed. + ## Zero means no limit. + # idle_conn_timeout = 0 + ## Authentication for Direct Ingestion. ## Direct Ingestion requires one of: `token`,`auth_csp_api_token`, or `auth_csp_client_credentials` ## See https://docs.wavefront.com/csp_getting_started.html to learn more about using CSP credentials with Wavefront. diff --git a/plugins/outputs/wavefront/wavefront.go b/plugins/outputs/wavefront/wavefront.go index 98a06349005e6..5c978925c588b 100644 --- a/plugins/outputs/wavefront/wavefront.go +++ b/plugins/outputs/wavefront/wavefront.go @@ -2,7 +2,7 @@ package wavefront import ( - cryptoTls "crypto/tls" + "context" _ "embed" "errors" "fmt" @@ -15,7 +15,7 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/config" - "github.com/influxdata/telegraf/plugins/common/tls" + httpconfig "github.com/influxdata/telegraf/plugins/common/http" "github.com/influxdata/telegraf/plugins/outputs" serializer "github.com/influxdata/telegraf/plugins/serializers/wavefront" ) @@ -45,7 +45,6 @@ type Wavefront struct { ConvertPaths bool `toml:"convert_paths"` ConvertBool bool `toml:"convert_bool"` HTTPMaximumBatchSize int `toml:"http_maximum_batch_size"` - Timeout config.Duration `toml:"timeout"` UseRegex bool `toml:"use_regex"` UseStrict bool `toml:"use_strict"` TruncateTags bool `toml:"truncate_tags"` @@ -53,7 +52,9 @@ type Wavefront struct { SendInternalMetrics bool `toml:"send_internal_metrics"` SourceOverride []string `toml:"source_override"` StringToNumber map[string][]map[string]float64 `toml:"string_to_number" deprecated:"1.9.0;use the enum processor instead"` - tls.ClientConfig + + httpconfig.HTTPClientConfig + sender wavefront.Sender Log telegraf.Logger `toml:"-"` } @@ -87,13 +88,15 @@ func (w *Wavefront) parseConnectionURL() (string, error) { return u.String(), nil } -func (w *Wavefront) createSender(connectionURL string, flushSeconds int, tlsConfig *cryptoTls.Config) (wavefront.Sender, error) { - timeout := time.Duration(w.Timeout) +func (w *Wavefront) createSender(connectionURL string, flushSeconds int) (wavefront.Sender, error) { + client, err := w.CreateClient(context.Background(), w.Log) + if err != nil { + return nil, err + } options := []wavefront.Option{ wavefront.BatchSize(w.HTTPMaximumBatchSize), wavefront.FlushIntervalSeconds(flushSeconds), - wavefront.TLSConfigOptions(tlsConfig), - wavefront.Timeout(timeout), + wavefront.HTTPClient(client), wavefront.SendInternalMetrics(w.SendInternalMetrics), } @@ -116,12 +119,7 @@ func (w *Wavefront) Connect() error { return err } - tlsConfig, err := w.TLSConfig() - if err != nil { - return err - } - - sender, err := w.createSender(connectionURL, flushSeconds, tlsConfig) + sender, err := w.createSender(connectionURL, flushSeconds) if err != nil { return fmt.Errorf("could not create Wavefront Sender for the provided url") @@ -384,7 +382,7 @@ func init() { ImmediateFlush: true, SendInternalMetrics: true, HTTPMaximumBatchSize: 10000, - Timeout: config.Duration(10 * time.Second), + HTTPClientConfig: httpconfig.HTTPClientConfig{Timeout: config.Duration(10 * time.Second)}, CSPBaseURL: "https://console.cloud.vmware.com", } })