Skip to content

Commit

Permalink
Change the default value of disable_high_cardinality_metrics to "true…
Browse files Browse the repository at this point in the history
…". (#6255)
  • Loading branch information
ptodev authored Jan 30, 2024
1 parent 5089e60 commit 088b74d
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Main (unreleased)

- Prohibit the configuration of services within modules. (@wildum)

- For `otelcol.exporter` components, change the default value of `disable_high_cardinality_metrics` to `true`. (@ptodev)

### Features

- A new `discovery.process` component for discovering Linux OS processes on the current host. (@korniltsev)
Expand Down
2 changes: 1 addition & 1 deletion component/otelcol/config_debug_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type DebugMetricsArguments struct {

// DefaultDebugMetricsArguments holds default settings for DebugMetricsArguments.
var DefaultDebugMetricsArguments = DebugMetricsArguments{
DisableHighCardinalityMetrics: false,
DisableHighCardinalityMetrics: true,
}

// SetToDefault implements river.Defaulter.
Expand Down
3 changes: 2 additions & 1 deletion component/otelcol/exporter/loadbalancing/loadbalancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ var (
Protocol: Protocol{
OTLP: DefaultOTLPConfig,
},
RoutingKey: "traceID",
RoutingKey: "traceID",
DebugMetrics: otelcol.DefaultDebugMetricsArguments,
}

DefaultOTLPConfig = OtlpConfig{
Expand Down
81 changes: 81 additions & 0 deletions component/otelcol/exporter/loadbalancing/loadbalancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"
"time"

"github.com/grafana/agent/component/otelcol"
"github.com/grafana/agent/component/otelcol/exporter/loadbalancing"
"github.com/grafana/river"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter"
Expand Down Expand Up @@ -268,3 +269,83 @@ func TestConfigConversion(t *testing.T) {
})
}
}

func TestDebugMetricsConfig(t *testing.T) {
tests := []struct {
testName string
agentCfg string
expected otelcol.DebugMetricsArguments
}{
{
testName: "default",
agentCfg: `
resolver {
static {
hostnames = ["endpoint-1"]
}
}
protocol {
otlp {
client {}
}
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: true,
},
},
{
testName: "explicit_false",
agentCfg: `
resolver {
static {
hostnames = ["endpoint-1"]
}
}
protocol {
otlp {
client {}
}
}
debug_metrics {
disable_high_cardinality_metrics = false
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: false,
},
},
{
testName: "explicit_true",
agentCfg: `
resolver {
static {
hostnames = ["endpoint-1"]
}
}
protocol {
otlp {
client {}
}
}
debug_metrics {
disable_high_cardinality_metrics = true
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: true,
},
},
}

for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
var args loadbalancing.Arguments
require.NoError(t, river.Unmarshal([]byte(tc.agentCfg), &args))
_, err := args.Convert()
require.NoError(t, err)

require.Equal(t, tc.expected, args.DebugMetricsConfig())
})
}
}
1 change: 1 addition & 0 deletions component/otelcol/exporter/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var DefaultArguments = Arguments{
Verbosity: configtelemetry.LevelNormal,
SamplingInitial: 2,
SamplingThereafter: 500,
DebugMetrics: otelcol.DefaultDebugMetricsArguments,
}

// SetToDefault implements river.Defaulter.
Expand Down
9 changes: 5 additions & 4 deletions component/otelcol/exporter/otlp/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ var _ exporter.Arguments = Arguments{}

// DefaultArguments holds default values for Arguments.
var DefaultArguments = Arguments{
Timeout: otelcol.DefaultTimeout,
Queue: otelcol.DefaultQueueArguments,
Retry: otelcol.DefaultRetryArguments,
Client: DefaultGRPCClientArguments,
Timeout: otelcol.DefaultTimeout,
Queue: otelcol.DefaultQueueArguments,
Retry: otelcol.DefaultRetryArguments,
Client: DefaultGRPCClientArguments,
DebugMetrics: otelcol.DefaultDebugMetricsArguments,
}

// SetToDefault implements river.Defaulter.
Expand Down
59 changes: 59 additions & 0 deletions component/otelcol/exporter/otlp/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,62 @@ func createTestTraces() ptrace.Traces {
}
return data
}

func TestDebugMetricsConfig(t *testing.T) {
tests := []struct {
testName string
agentCfg string
expected otelcol.DebugMetricsArguments
}{
{
testName: "default",
agentCfg: `
client {
endpoint = "tempo-xxx.grafana.net/tempo:443"
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: true,
},
},
{
testName: "explicit_false",
agentCfg: `
client {
endpoint = "tempo-xxx.grafana.net/tempo:443"
}
debug_metrics {
disable_high_cardinality_metrics = false
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: false,
},
},
{
testName: "explicit_true",
agentCfg: `
client {
endpoint = "tempo-xxx.grafana.net/tempo:443"
}
debug_metrics {
disable_high_cardinality_metrics = true
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: true,
},
},
}

for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
var args otlp.Arguments
require.NoError(t, river.Unmarshal([]byte(tc.agentCfg), &args))
_, err := args.Convert()
require.NoError(t, err)

require.Equal(t, tc.expected, args.DebugMetricsConfig())
})
}
}
7 changes: 4 additions & 3 deletions component/otelcol/exporter/otlphttp/otlphttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ var _ exporter.Arguments = Arguments{}

// DefaultArguments holds default values for Arguments.
var DefaultArguments = Arguments{
Queue: otelcol.DefaultQueueArguments,
Retry: otelcol.DefaultRetryArguments,
Client: DefaultHTTPClientArguments,
Queue: otelcol.DefaultQueueArguments,
Retry: otelcol.DefaultRetryArguments,
Client: DefaultHTTPClientArguments,
DebugMetrics: otelcol.DefaultDebugMetricsArguments,
}

// SetToDefault implements river.Defaulter.
Expand Down
59 changes: 59 additions & 0 deletions component/otelcol/exporter/otlphttp/otlphttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,62 @@ func createTestTraces() ptrace.Traces {
}
return data
}

func TestDebugMetricsConfig(t *testing.T) {
tests := []struct {
testName string
agentCfg string
expected otelcol.DebugMetricsArguments
}{
{
testName: "default",
agentCfg: `
client {
endpoint = "http://tempo:4317"
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: true,
},
},
{
testName: "explicit_false",
agentCfg: `
client {
endpoint = "http://tempo:4317"
}
debug_metrics {
disable_high_cardinality_metrics = false
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: false,
},
},
{
testName: "explicit_true",
agentCfg: `
client {
endpoint = "http://tempo:4317"
}
debug_metrics {
disable_high_cardinality_metrics = true
}
`,
expected: otelcol.DebugMetricsArguments{
DisableHighCardinalityMetrics: true,
},
},
}

for _, tc := range tests {
t.Run(tc.testName, func(t *testing.T) {
var args otlphttp.Arguments
require.NoError(t, river.Unmarshal([]byte(tc.agentCfg), &args))
_, err := args.Convert()
require.NoError(t, err)

require.Equal(t, tc.expected, args.DebugMetricsConfig())
})
}
}
5 changes: 5 additions & 0 deletions docs/sources/flow/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Other release notes for the different {{< param "PRODUCT_ROOT_NAME" >}} variants
Previously it was possible to configure the HTTP service via the [HTTP config block](https://grafana.com/docs/agent/v0.39/flow/reference/config-blocks/http/) inside of a module.
This functionality is now only available in the main configuration.

### Breaking change: Change the default value of `disable_high_cardinality_metrics` to `true`.

The `disable_high_cardinality_metrics` configuration argument is used by `otelcol.exporter` components such as `otelcol.exporter.otlp`.
If you need to see high cardinality metrics containing labels such as IP addresses and port numbers, you now have to explicitly set `disable_high_cardinality_metrics` to `false`.

## v0.39

### Breaking change: `otelcol.receiver.prometheus` will drop all `otel_scope_info` metrics when converting them to OTLP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following arguments are supported:

Name | Type | Description | Default | Required
-----------------------------------|-----------|------------------------------------------------------|---------|---------
`disable_high_cardinality_metrics` | `boolean` | Whether to disable certain high cardinality metrics. | `false` | no
`disable_high_cardinality_metrics` | `boolean` | Whether to disable certain high cardinality metrics. | `true` | no

`disable_high_cardinality_metrics` is the Grafana Agent equivalent to the `telemetry.disableHighCardinalityMetrics` feature gate in the OpenTelemetry Collector.
It removes attributes that could cause high cardinality metrics.
Expand Down

0 comments on commit 088b74d

Please sign in to comment.