Skip to content

Commit

Permalink
Corrects the telemetry config comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Eclion committed Aug 19, 2022
1 parent f972276 commit 5baf864
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{"+<expr>", "+<expr>", ...} }
// hcl: telemetry { allowed_prefixes = ["<expr>", "<expr>", ...] }
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{"-<expr>", "-<expr>", ...} }
// hcl: telemetry { blocked_prefixes = ["<expr>", "<expr>", ...] }
BlockedPrefixes []string `json:"blocked_prefixes,omitempty" mapstructure:"blocked_prefixes"`

// MetricsPrefix is the prefix used to write stats values to.
Expand Down
7 changes: 7 additions & 0 deletions config/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ 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)
require.NoError(t, err)

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)
Expand Down

0 comments on commit 5baf864

Please sign in to comment.