Skip to content

Commit a39fce2

Browse files
authored
Remove Grafana Cloud endpoint configuration (#32)
* Remove Grafana Cloud endpoint configuration * Fix sdk_inject after merge * Fix linter
1 parent 8638e7d commit a39fce2

File tree

14 files changed

+22
-276
lines changed

14 files changed

+22
-276
lines changed

contrib/example-service.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ trace_printer: text
55
ebpf:
66
wakeup_len: 100
77

8-
grafana:
9-
otlp:
10-
cloud_zone: <my-cloud-zone>
11-
cloud_instance_id: <my-instance-id>
12-
cloud_submit:
13-
- metrics
14-
- traces
158
routes:
169
unmatched: heuristic
1710

pkg/beyla/config.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ var DefaultConfig = Config{
5353
ContextPropagationEnabled: false,
5454
ContextPropagation: config.ContextPropagationDisabled,
5555
},
56-
Grafana: otel.GrafanaConfig{
57-
OTLP: otel.GrafanaOTLP{
58-
// by default we will only submit traces, assuming span2metrics will do the metrics conversion
59-
Submit: []string{"traces"},
60-
},
61-
},
6256
NameResolver: &transform.NameResolverConfig{
6357
Sources: []string{"k8s"},
6458
CacheLen: 1024,
@@ -142,10 +136,6 @@ type Config struct {
142136
// NetworkFlows configuration for Network Observability feature
143137
NetworkFlows NetworkConfig `yaml:"network"`
144138

145-
// Grafana overrides some values of the otel.MetricsConfig and otel.TracesConfig below
146-
// for a simpler submission of OTEL metrics to Grafana Cloud
147-
Grafana otel.GrafanaConfig `yaml:"grafana"`
148-
149139
Filters filter.AttributesConfig `yaml:"filter"`
150140

151141
Attributes Attributes `yaml:"attributes"`
@@ -270,10 +260,10 @@ func (c *Config) Validate() error {
270260
return ConfigError("OTEL_EBPF_KUBE_INFORMERS_SYNC_TIMEOUT duration must be greater than 0s")
271261
}
272262

273-
if c.Enabled(FeatureNetO11y) && !c.Grafana.OTLP.MetricsEnabled() && !c.Metrics.Enabled() &&
263+
if c.Enabled(FeatureNetO11y) && !c.Metrics.Enabled() &&
274264
!c.Prometheus.Enabled() && !c.NetworkFlows.Print {
275265
return ConfigError("enabling network metrics requires to enable at least the OpenTelemetry" +
276-
" metrics exporter: grafana, otel_metrics_export or prometheus_export sections in the YAML configuration file; or the" +
266+
" metrics exporter: otel_metrics_export or prometheus_export sections in the YAML configuration file; or the" +
277267
" OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT or OTEL_EBPF_PROMETHEUS_PORT environment variables. For debugging" +
278268
" purposes, you can also set OTEL_EBPF_NETWORK_PRINT_FLOWS=true")
279269
}
@@ -283,11 +273,10 @@ func (c *Config) Validate() error {
283273
}
284274

285275
if c.Enabled(FeatureAppO11y) && !c.TracePrinter.Enabled() &&
286-
!c.Grafana.OTLP.MetricsEnabled() && !c.Grafana.OTLP.TracesEnabled() &&
287276
!c.Metrics.Enabled() && !c.Traces.Enabled() &&
288277
!c.Prometheus.Enabled() && !c.TracePrinter.Enabled() {
289278
return ConfigError("you need to define at least one exporter: trace_printer," +
290-
" grafana, otel_metrics_export, otel_traces_export or prometheus_export")
279+
" otel_metrics_export, otel_traces_export or prometheus_export")
291280
}
292281

293282
if len(c.Routes.WildcardChar) > 1 {
@@ -297,7 +286,7 @@ func (c *Config) Validate() error {
297286
if c.InternalMetrics.Exporter == imetrics.InternalMetricsExporterOTEL && c.InternalMetrics.Prometheus.Port != 0 {
298287
return ConfigError("you can't enable both OTEL and Prometheus internal metrics")
299288
}
300-
if c.InternalMetrics.Exporter == imetrics.InternalMetricsExporterOTEL && !c.Metrics.Enabled() && !c.Grafana.OTLP.MetricsEnabled() {
289+
if c.InternalMetrics.Exporter == imetrics.InternalMetricsExporterOTEL && !c.Metrics.Enabled() {
301290
return ConfigError("you can't enable OTEL internal metrics without enabling OTEL metrics")
302291
}
303292

@@ -309,7 +298,7 @@ func (c *Config) promNetO11yEnabled() bool {
309298
}
310299

311300
func (c *Config) otelNetO11yEnabled() bool {
312-
return (c.Metrics.Enabled() || c.Grafana.OTLP.MetricsEnabled()) && c.Metrics.NetworkMetricsEnabled()
301+
return c.Metrics.Enabled() && c.Metrics.NetworkMetricsEnabled()
313302
}
314303

315304
func (c *Config) willUseTC() bool {

pkg/beyla/config_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ discovery:
8383
t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "localhost:3131")
8484
t.Setenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", "localhost:3232")
8585
t.Setenv("OTEL_EBPF_INTERNAL_METRICS_PROMETHEUS_PORT", "3210")
86-
t.Setenv("GRAFANA_CLOUD_SUBMIT", "metrics,traces")
8786
t.Setenv("KUBECONFIG", "/foo/bar")
8887
t.Setenv("OTEL_EBPF_NAME_RESOLVER_SOURCES", "k8s,dns")
8988

@@ -125,11 +124,6 @@ discovery:
125124
ContextPropagationEnabled: false,
126125
ContextPropagation: config.ContextPropagationDisabled,
127126
},
128-
Grafana: otel.GrafanaConfig{
129-
OTLP: otel.GrafanaOTLP{
130-
Submit: []string{"metrics", "traces"},
131-
},
132-
},
133127
NetworkFlows: nc,
134128
Metrics: otel.MetricsConfig{
135129
OTELIntervalMS: 60_000,
@@ -340,7 +334,7 @@ func TestConfigValidate_TracePrinter(t *testing.T) {
340334
},
341335
{
342336
env: envMap{"OTEL_EBPF_EXECUTABLE_PATH": "foo"},
343-
errorMsg: "you need to define at least one exporter: trace_printer, grafana, otel_metrics_export, otel_traces_export or prometheus_export",
337+
errorMsg: "you need to define at least one exporter: trace_printer, otel_metrics_export, otel_traces_export or prometheus_export",
344338
},
345339
}
346340

pkg/components/beyla.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ func buildCommonContextInfo(
159159
switch {
160160
case config.InternalMetrics.Exporter == imetrics.InternalMetricsExporterOTEL:
161161
var err error
162-
config.Metrics.Grafana = &config.Grafana.OTLP
163162
slog.Debug("reporting internal metrics as OpenTelemetry")
164163
ctxInfo.Metrics, err = otel.NewInternalMetricsReporter(ctx, ctxInfo, &config.Metrics)
165164
if err != nil {

pkg/export/otel/common.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func ResourceAttrsFromEnv(svc *svc.Attrs) []attribute.KeyValue {
489489
return otelResourceAttrs
490490
}
491491

492-
func ResolveOTLPEndpoint(endpoint, common string, grafana *GrafanaOTLP) (string, bool) {
492+
func ResolveOTLPEndpoint(endpoint, common string) (string, bool) {
493493
if endpoint != "" {
494494
return endpoint, false
495495
}
@@ -498,10 +498,6 @@ func ResolveOTLPEndpoint(endpoint, common string, grafana *GrafanaOTLP) (string,
498498
return common, true
499499
}
500500

501-
if grafana != nil && grafana.CloudZone != "" && grafana.Endpoint() != "" {
502-
return grafana.Endpoint(), true
503-
}
504-
505501
return "", false
506502
}
507503

pkg/export/otel/common_test.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ func TestParseOTELEnvVar_nil(t *testing.T) {
183183
}
184184

185185
func TestResolveOTLPEndpoint(t *testing.T) {
186-
grafana1 := GrafanaOTLP{
187-
CloudZone: "foo",
188-
}
189-
190-
const grafanaEndpoint = "https://otlp-gateway-foo.grafana.net/otlp"
191-
192-
grafana2 := GrafanaOTLP{}
193-
194186
type expected struct {
195187
e string
196188
common bool
@@ -199,24 +191,19 @@ func TestResolveOTLPEndpoint(t *testing.T) {
199191
type testCase struct {
200192
endpoint string
201193
common string
202-
grafana *GrafanaOTLP
203194
expected expected
204195
}
205196

206197
testCases := []testCase{
207-
{endpoint: "e1", common: "c1", grafana: nil, expected: expected{e: "e1", common: false}},
208-
{endpoint: "e1", common: "", grafana: nil, expected: expected{e: "e1", common: false}},
209-
{endpoint: "", common: "c1", grafana: nil, expected: expected{e: "c1", common: true}},
210-
{endpoint: "", common: "", grafana: nil, expected: expected{e: "", common: false}},
211-
{endpoint: "e1", common: "c1", grafana: &grafana1, expected: expected{e: "e1", common: false}},
212-
{endpoint: "", common: "c1", grafana: &grafana1, expected: expected{e: "c1", common: true}},
213-
{endpoint: "", common: "", grafana: &grafana1, expected: expected{e: grafanaEndpoint, common: true}},
214-
{endpoint: "", common: "", grafana: &grafana2, expected: expected{e: "", common: false}},
198+
{endpoint: "e1", common: "c1", expected: expected{e: "e1", common: false}},
199+
{endpoint: "e1", common: "", expected: expected{e: "e1", common: false}},
200+
{endpoint: "", common: "c1", expected: expected{e: "c1", common: true}},
201+
{endpoint: "", common: "", expected: expected{e: "", common: false}},
215202
}
216203

217204
for _, tc := range testCases {
218205
t.Run(fmt.Sprint(tc), func(t *testing.T) {
219-
ep, common := ResolveOTLPEndpoint(tc.endpoint, tc.common, tc.grafana)
206+
ep, common := ResolveOTLPEndpoint(tc.endpoint, tc.common)
220207

221208
assert.Equal(t, ep, tc.expected.e)
222209
assert.Equal(t, common, tc.expected.common)

pkg/export/otel/grafana.go

Lines changed: 0 additions & 94 deletions
This file was deleted.

pkg/export/otel/metrics.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ type MetricsConfig struct {
120120
TTL time.Duration `yaml:"ttl" env:"OTEL_EBPF_OTEL_METRICS_TTL"`
121121

122122
AllowServiceGraphSelfReferences bool `yaml:"allow_service_graph_self_references" env:"OTEL_EBPF_OTEL_ALLOW_SERVICE_GRAPH_SELF_REFERENCES"`
123-
124-
// Grafana configuration needs to be explicitly set up before building the graph
125-
Grafana *GrafanaOTLP `yaml:"-"`
126123
}
127124

128125
func (m *MetricsConfig) GetProtocol() Protocol {
@@ -159,7 +156,7 @@ func (m *MetricsConfig) GuessProtocol() Protocol {
159156
}
160157

161158
func (m *MetricsConfig) OTLPMetricsEndpoint() (string, bool) {
162-
return ResolveOTLPEndpoint(m.MetricsEndpoint, m.CommonEndpoint, m.Grafana)
159+
return ResolveOTLPEndpoint(m.MetricsEndpoint, m.CommonEndpoint)
163160
}
164161

165162
// EndpointEnabled specifies that the OTEL metrics node is enabled if and only if
@@ -168,7 +165,7 @@ func (m *MetricsConfig) OTLPMetricsEndpoint() (string, bool) {
168165
// Reason to disable linting: it requires to be a value despite it is considered a "heavy struct".
169166
// This method is invoked only once during startup time so it doesn't have a noticeable performance impact.
170167
func (m *MetricsConfig) EndpointEnabled() bool {
171-
return m.CommonEndpoint != "" || m.MetricsEndpoint != "" || m.Grafana.MetricsEnabled()
168+
return m.CommonEndpoint != "" || m.MetricsEndpoint != ""
172169
}
173170

174171
func (m *MetricsConfig) SpanMetricsEnabled() bool {
@@ -1085,7 +1082,6 @@ func getHTTPMetricEndpointOptions(cfg *MetricsConfig) (otlpOptions, error) {
10851082
opts.SkipTLSVerify = cfg.InsecureSkipVerify
10861083
}
10871084

1088-
cfg.Grafana.setupOptions(&opts)
10891085
maps.Copy(opts.Headers, HeadersFromEnv(envHeaders))
10901086
maps.Copy(opts.Headers, HeadersFromEnv(envMetricsHeaders))
10911087

@@ -1113,7 +1109,6 @@ func getGRPCMetricEndpointOptions(cfg *MetricsConfig) (otlpOptions, error) {
11131109
opts.SkipTLSVerify = true
11141110
}
11151111

1116-
cfg.Grafana.setupOptions(&opts)
11171112
maps.Copy(opts.Headers, HeadersFromEnv(envHeaders))
11181113
maps.Copy(opts.Headers, HeadersFromEnv(envMetricsHeaders))
11191114

pkg/export/otel/metrics_net_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,18 @@ func TestNetMetricsConfig_Enabled(t *testing.T) {
138138
assert.True(t, NetMetricsConfig{Metrics: &MetricsConfig{
139139
Features: []string{FeatureNetwork, FeatureApplication}, MetricsEndpoint: "foo",
140140
}}.Enabled())
141-
assert.True(t, NetMetricsConfig{Metrics: &MetricsConfig{
142-
Features: []string{FeatureNetwork}, Grafana: &GrafanaOTLP{Submit: []string{"traces", "metrics"}, InstanceID: "33221"},
143-
}}.Enabled())
144141
}
145142

146143
func TestNetMetricsConfig_Disabled(t *testing.T) {
147144
fa := []string{FeatureApplication}
148145
fn := []string{FeatureNetwork}
149146
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{Features: fn}}.Enabled())
150-
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{Features: fn, Grafana: &GrafanaOTLP{Submit: []string{"traces"}, InstanceID: "33221"}}}.Enabled())
151-
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{Features: fn, Grafana: &GrafanaOTLP{Submit: []string{"metrics"}}}}.Enabled())
147+
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{Features: fn}}.Enabled())
148+
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{Features: fn}}.Enabled())
152149
// network feature is not enabled
153150
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{CommonEndpoint: "foo"}}.Enabled())
154151
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{MetricsEndpoint: "foo", Features: fa}}.Enabled())
155-
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{Grafana: &GrafanaOTLP{Submit: []string{"traces", "metrics"}, InstanceID: "33221"}}}.Enabled())
152+
assert.False(t, NetMetricsConfig{Metrics: &MetricsConfig{}}.Enabled())
156153
}
157154

158155
func TestGetFilteredNetworkResourceAttrs(t *testing.T) {

0 commit comments

Comments
 (0)