diff --git a/config/telemetry.go b/config/telemetry.go index af666d161..527cd0a4d 100644 --- a/config/telemetry.go +++ b/config/telemetry.go @@ -163,14 +163,14 @@ type TelemetryConfig struct { // by prefix. Use the 'prefix_filter' option and prefix rules with '+' to be // included. // - // hcl: telemetry { prefix_filter = []string{"+", "+", ...} } + // hcl: telemetry { allowed_prefixes = ["", "", ...] } AllowedPrefixes []string `json:"allowed_prefixes,omitempty" mapstructure:"allowed_prefixes"` // BlockedPrefixes is a list of filter rules to apply for blocking metrics // by prefix. Use the 'prefix_filter' option and prefix rules with '-' to be // excluded. // - // hcl: telemetry { prefix_filter = []string{"-", "-", ...} } + // hcl: telemetry { blocked_prefixes = ["", "", ...] } BlockedPrefixes []string `json:"blocked_prefixes,omitempty" mapstructure:"blocked_prefixes"` // MetricsPrefix is the prefix used to write stats values to. diff --git a/config/telemetry_test.go b/config/telemetry_test.go index fecaae746..8256cd2e2 100644 --- a/config/telemetry_test.go +++ b/config/telemetry_test.go @@ -11,6 +11,9 @@ func TestPromConfigParsing(t *testing.T) { configStr := "telemetry {" + "prometheus_port = 9110" + "prometheus_retention_time = \"120s\"" + + "allowed_prefixes = [\"keep\"]" + + "blocked_prefixes = [\"dont_keep\"]" + + "metrics_prefix = \"consul_template\"" + "}" config, err := Parse(configStr) @@ -18,6 +21,10 @@ func TestPromConfigParsing(t *testing.T) { require.Equal(t, 9110, config.Telemetry.PrometheusPort) require.Equal(t, 120*time.Second, config.Telemetry.PrometheusRetentionTime) + require.Equal(t, "consul_template", config.Telemetry.MetricsPrefix) + require.Equal(t, "consul_template", config.Telemetry.MetricsPrefix) + require.ElementsMatch(t, []string{"keep"}, config.Telemetry.AllowedPrefixes) + require.ElementsMatch(t, []string{"dont_keep"}, config.Telemetry.BlockedPrefixes) config.Finalize() require.Equal(t, 9110, config.Telemetry.PrometheusPort)