Fix telemetry default prefix filter

If telemetry metrics contain a hostname starting with
'consul', the metrics will be filtered out the same way
as the deprecated metrics.
pull/4077/head
Dino Lukman 2018-05-02 16:56:29 +02:00
parent 2e2cf8df34
commit d538b5666c
2 changed files with 5 additions and 5 deletions

View File

@ -514,9 +514,9 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
// Add a filter rule if needed for enabling the deprecated metric names // Add a filter rule if needed for enabling the deprecated metric names
enableDeprecatedNames := b.boolVal(c.Telemetry.EnableDeprecatedNames) enableDeprecatedNames := b.boolVal(c.Telemetry.EnableDeprecatedNames)
if enableDeprecatedNames { if enableDeprecatedNames {
telemetryAllowedPrefixes = append(telemetryAllowedPrefixes, "consul.consul") telemetryAllowedPrefixes = append(telemetryAllowedPrefixes, "consul.consul.")
} else { } else {
telemetryBlockedPrefixes = append(telemetryBlockedPrefixes, "consul.consul") telemetryBlockedPrefixes = append(telemetryBlockedPrefixes, "consul.consul.")
} }
// raft performance scaling // raft performance scaling

View File

@ -1811,7 +1811,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
rt.DataDir = dataDir rt.DataDir = dataDir
rt.TelemetryAllowedPrefixes = []string{"foo"} rt.TelemetryAllowedPrefixes = []string{"foo"}
rt.TelemetryBlockedPrefixes = []string{"bar", "consul.consul"} rt.TelemetryBlockedPrefixes = []string{"bar", "consul.consul."}
}, },
warns: []string{`Filter rule must begin with either '+' or '-': "nix"`}, warns: []string{`Filter rule must begin with either '+' or '-': "nix"`},
}, },
@ -1829,7 +1829,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
patch: func(rt *RuntimeConfig) { patch: func(rt *RuntimeConfig) {
rt.DataDir = dataDir rt.DataDir = dataDir
rt.TelemetryFilterDefault = false rt.TelemetryFilterDefault = false
rt.TelemetryAllowedPrefixes = []string{"consul.consul"} rt.TelemetryAllowedPrefixes = []string{"consul.consul."}
rt.TelemetryBlockedPrefixes = []string{} rt.TelemetryBlockedPrefixes = []string{}
}, },
}, },
@ -3633,7 +3633,7 @@ func TestFullConfig(t *testing.T) {
TelemetryDogstatsdAddr: "0wSndumK", TelemetryDogstatsdAddr: "0wSndumK",
TelemetryDogstatsdTags: []string{"3N81zSUB", "Xtj8AnXZ"}, TelemetryDogstatsdTags: []string{"3N81zSUB", "Xtj8AnXZ"},
TelemetryFilterDefault: true, TelemetryFilterDefault: true,
TelemetryAllowedPrefixes: []string{"oJotS8XJ", "consul.consul"}, TelemetryAllowedPrefixes: []string{"oJotS8XJ", "consul.consul."},
TelemetryBlockedPrefixes: []string{"cazlEhGn"}, TelemetryBlockedPrefixes: []string{"cazlEhGn"},
TelemetryMetricsPrefix: "ftO6DySn", TelemetryMetricsPrefix: "ftO6DySn",
TelemetryPrometheusRetentionTime: 15 * time.Second, TelemetryPrometheusRetentionTime: 15 * time.Second,