feat(outputs/wavefront): make maximum http batch size configurable (#11201)

This commit is contained in:
Luke Winikates 2022-06-29 12:27:56 -07:00 committed by GitHub
parent b638c5353f
commit 6e6fba77bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 21 deletions

View File

@ -15,6 +15,9 @@ Wavefront data format over TCP.
## Authentication Token for Wavefront. Only required if using Direct Ingestion ## Authentication Token for Wavefront. Only required if using Direct Ingestion
#token = "DUMMY_TOKEN" #token = "DUMMY_TOKEN"
## Maximum number of metrics to send per batch for Direct Ingestion. Ignored unless 'url' is set. This value should be higher than the `metric_batch_size`. Default is 10,000. Values higher than 40,000 are not recommended.
# http_maximum_batch_size = 10000
## DNS name of the wavefront proxy server. Do not use if url is specified ## DNS name of the wavefront proxy server. Do not use if url is specified
#host = "wavefront.example.com" #host = "wavefront.example.com"

View File

@ -7,6 +7,9 @@
## Authentication Token for Wavefront. Only required if using Direct Ingestion ## Authentication Token for Wavefront. Only required if using Direct Ingestion
#token = "DUMMY_TOKEN" #token = "DUMMY_TOKEN"
## Maximum number of metrics to send per batch for Direct Ingestion. Ignored unless 'url' is set. This value should be higher than the `metric_batch_size`. Default is 10,000. Values higher than 40,000 are not recommended.
# http_maximum_batch_size = 10000
## DNS name of the wavefront proxy server. Do not use if url is specified ## DNS name of the wavefront proxy server. Do not use if url is specified
#host = "wavefront.example.com" #host = "wavefront.example.com"

View File

@ -20,21 +20,22 @@ var sampleConfig string
const maxTagLength = 254 const maxTagLength = 254
type Wavefront struct { type Wavefront struct {
URL string `toml:"url"` URL string `toml:"url"`
Token string `toml:"token"` Token string `toml:"token"`
Host string `toml:"host"` Host string `toml:"host"`
Port int `toml:"port"` Port int `toml:"port"`
Prefix string `toml:"prefix"` Prefix string `toml:"prefix"`
SimpleFields bool `toml:"simple_fields"` SimpleFields bool `toml:"simple_fields"`
MetricSeparator string `toml:"metric_separator"` MetricSeparator string `toml:"metric_separator"`
ConvertPaths bool `toml:"convert_paths"` ConvertPaths bool `toml:"convert_paths"`
ConvertBool bool `toml:"convert_bool"` ConvertBool bool `toml:"convert_bool"`
UseRegex bool `toml:"use_regex"` HTTPMaximumBatchSize int `toml:"http_maximum_batch_size"`
UseStrict bool `toml:"use_strict"` UseRegex bool `toml:"use_regex"`
TruncateTags bool `toml:"truncate_tags"` UseStrict bool `toml:"use_strict"`
ImmediateFlush bool `toml:"immediate_flush"` TruncateTags bool `toml:"truncate_tags"`
SourceOverride []string `toml:"source_override"` ImmediateFlush bool `toml:"immediate_flush"`
StringToNumber map[string][]map[string]float64 `toml:"string_to_number" deprecated:"1.9.0;use the enum processor instead"` SourceOverride []string `toml:"source_override"`
StringToNumber map[string][]map[string]float64 `toml:"string_to_number" deprecated:"1.9.0;use the enum processor instead"`
sender wavefront.Sender sender wavefront.Sender
Log telegraf.Logger `toml:"-"` Log telegraf.Logger `toml:"-"`
@ -87,6 +88,7 @@ func (w *Wavefront) Connect() error {
Server: w.URL, Server: w.URL,
Token: w.Token, Token: w.Token,
FlushIntervalSeconds: flushSeconds, FlushIntervalSeconds: flushSeconds,
BatchSize: w.HTTPMaximumBatchSize,
}) })
if err != nil { if err != nil {
return fmt.Errorf("could not create Wavefront Sender for Url: %s", w.URL) return fmt.Errorf("could not create Wavefront Sender for Url: %s", w.URL)
@ -292,12 +294,13 @@ func (w *Wavefront) Close() error {
func init() { func init() {
outputs.Add("wavefront", func() telegraf.Output { outputs.Add("wavefront", func() telegraf.Output {
return &Wavefront{ return &Wavefront{
Token: "DUMMY_TOKEN", Token: "DUMMY_TOKEN",
MetricSeparator: ".", MetricSeparator: ".",
ConvertPaths: true, ConvertPaths: true,
ConvertBool: true, ConvertBool: true,
TruncateTags: false, TruncateTags: false,
ImmediateFlush: true, ImmediateFlush: true,
HTTPMaximumBatchSize: 10000,
} }
}) })
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/testutil" "github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -354,6 +355,11 @@ func TestTagLimits(t *testing.T) {
require.Equal(t, longKey, tags[longKey]) require.Equal(t, longKey, tags[longKey])
} }
func TestDefaults(t *testing.T) {
defaultWavefront := outputs.Outputs["wavefront"]().(*Wavefront)
require.Equal(t, 10000, defaultWavefront.HTTPMaximumBatchSize)
}
// Benchmarks to test performance of string replacement via Regex and Replacer // Benchmarks to test performance of string replacement via Regex and Replacer
var testString = "this_is*my!test/string\\for=replacement" var testString = "this_is*my!test/string\\for=replacement"