fix: input plugin statsd bug (#10116)
This commit is contained in:
parent
9480e49eee
commit
cd0a7cd52f
|
|
@ -165,7 +165,8 @@ type AgentConfig struct {
|
|||
// TODO(cam): Remove UTC and parameter, they are no longer
|
||||
// valid for the agent config. Leaving them here for now for backwards-
|
||||
// compatibility
|
||||
UTC bool `toml:"utc"` // deprecated in 1.0.0; has no effect
|
||||
// Deprecated: 1.0.0 after, has no effect
|
||||
UTC bool `toml:"utc"`
|
||||
|
||||
// Debug is the option for running in debug mode
|
||||
Debug bool `toml:"debug"`
|
||||
|
|
|
|||
|
|
@ -797,6 +797,12 @@ func parseKeyValue(keyValue string) (key string, val string) {
|
|||
val = split[1]
|
||||
} else if len(split) == 1 {
|
||||
val = split[0]
|
||||
} else if len(split) > 2 {
|
||||
// fix: https://github.com/influxdata/telegraf/issues/10113
|
||||
// fix: value has "=" parse error
|
||||
// uri=/service/endpoint?sampleParam={paramValue} parse value key="uri", val="/service/endpoint?sampleParam\={paramValue}"
|
||||
key = split[0]
|
||||
val = strings.Join(split[1:], "=")
|
||||
}
|
||||
|
||||
return key, val
|
||||
|
|
|
|||
|
|
@ -1674,3 +1674,30 @@ func TestParse_Ints(t *testing.T) {
|
|||
require.NoError(t, s.Gather(acc))
|
||||
require.Equal(t, s.Percentiles, []Number{90.0})
|
||||
}
|
||||
|
||||
func TestParse_KeyValue(t *testing.T) {
|
||||
type output struct {
|
||||
key string
|
||||
val string
|
||||
}
|
||||
|
||||
validLines := []struct {
|
||||
input string
|
||||
output output
|
||||
}{
|
||||
{"", output{"", ""}},
|
||||
{"only value", output{"", "only value"}},
|
||||
{"key=value", output{"key", "value"}},
|
||||
{"url=/api/querystring?key1=val1&key2=value", output{"url", "/api/querystring?key1=val1&key2=value"}},
|
||||
}
|
||||
|
||||
for _, line := range validLines {
|
||||
key, val := parseKeyValue(line.input)
|
||||
if key != line.output.key {
|
||||
t.Errorf("line: %s, key expected %s, actual %s", line, line.output.key, key)
|
||||
}
|
||||
if val != line.output.val {
|
||||
t.Errorf("line: %s, val expected %s, actual %s", line, line.output.val, val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue