Skip to content

Commit 59ddb28

Browse files
authored
Merge branch 'main' into cache-processor-set-paths
2 parents 91d1850 + ca1c17b commit 59ddb28

File tree

15 files changed

+151
-153
lines changed

15 files changed

+151
-153
lines changed

NOTICE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28749,11 +28749,11 @@ THE SOFTWARE.
2874928749

2875028750
--------------------------------------------------------------------------------
2875128751
Dependency : golang.org/x/crypto
28752-
Version: v0.44.0
28752+
Version: v0.45.0
2875328753
Licence type (autodetected): BSD-3-Clause
2875428754
--------------------------------------------------------------------------------
2875528755

28756-
Contents of probable licence file $GOMODCACHE/golang.org/x/crypto@v0.44.0/LICENSE:
28756+
Contents of probable licence file $GOMODCACHE/golang.org/x/crypto@v0.45.0/LICENSE:
2875728757

2875828758
Copyright 2009 The Go Authors.
2875928759

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# REQUIRED
2+
# Kind can be one of:
3+
# - breaking-change: a change to previously-documented behavior
4+
# - deprecation: functionality that is being removed in a later release
5+
# - bug-fix: fixes a problem in a previous version
6+
# - enhancement: extends functionality but does not break or fix existing behavior
7+
# - feature: new functionality
8+
# - known-issue: problems that we are aware of in a given version
9+
# - security: impacts on the security of a product or a user’s deployment.
10+
# - upgrade: important information for someone upgrading from a prior version
11+
# - other: does not fit into any of the other categories
12+
kind: breaking-change
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: remove otel.component.id and otel.component.kind from beat receiver events
17+
18+
# REQUIRED for breaking-change, deprecation, known-issue
19+
# Long description; in case the summary is not enough to describe the change
20+
# this field accommodate a description without length limits.
21+
# description:
22+
23+
# REQUIRED for breaking-change, deprecation, known-issue
24+
# impact:
25+
26+
# REQUIRED for breaking-change, deprecation, known-issue
27+
# action:
28+
29+
# REQUIRED for all kinds
30+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
31+
component: all
32+
33+
# AUTOMATED
34+
# OPTIONAL to manually add other PR URLs
35+
# PR URL: A link the PR that added the changeset.
36+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
37+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
38+
# Please provide it if you are adding a fragment for a different PR.
39+
pr: https://github.com/elastic/beats/pull/47729
40+
41+
# AUTOMATED
42+
# OPTIONAL to manually add other issue URLs
43+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
44+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
45+
issue: https://github.com/elastic/beats/issues/47600
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# REQUIRED
2+
# Kind can be one of:
3+
# - breaking-change: a change to previously-documented behavior
4+
# - deprecation: functionality that is being removed in a later release
5+
# - bug-fix: fixes a problem in a previous version
6+
# - enhancement: extends functionality but does not break or fix existing behavior
7+
# - feature: new functionality
8+
# - known-issue: problems that we are aware of in a given version
9+
# - security: impacts on the security of a product or a user’s deployment.
10+
# - upgrade: important information for someone upgrading from a prior version
11+
# - other: does not fit into any of the other categories
12+
kind: bug-fix
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: Not being able to start the add_docker_metadata processor is now consistently a non-fatal error when Docker is not available.
17+
18+
# REQUIRED for breaking-change, deprecation, known-issue
19+
# Long description; in case the summary is not enough to describe the change
20+
# this field accommodate a description without length limits.
21+
# description:
22+
23+
# REQUIRED for breaking-change, deprecation, known-issue
24+
# impact:
25+
26+
# REQUIRED for breaking-change, deprecation, known-issue
27+
# action:
28+
29+
# REQUIRED for all kinds
30+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
31+
component: all
32+
33+
# AUTOMATED
34+
# OPTIONAL to manually add other PR URLs
35+
# PR URL: A link the PR that added the changeset.
36+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
37+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
38+
# Please provide it if you are adding a fragment for a different PR.
39+
# pr: https://github.com/owner/repo/1234
40+
41+
# AUTOMATED
42+
# OPTIONAL to manually add other issue URLs
43+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
44+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
45+
# issue: https://github.com/owner/repo/1234

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ require (
122122
go.etcd.io/bbolt v1.4.0
123123
go.uber.org/multierr v1.11.0 // indirect
124124
go.uber.org/zap v1.27.0
125-
golang.org/x/crypto v0.44.0
125+
golang.org/x/crypto v0.45.0
126126
golang.org/x/mod v0.29.0
127127
golang.org/x/net v0.47.0
128128
golang.org/x/oauth2 v0.31.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,8 +1260,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
12601260
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
12611261
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
12621262
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
1263-
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
1264-
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
1263+
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
1264+
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
12651265
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12661266
golang.org/x/exp v0.0.0-20250911091902-df9299821621 h1:2id6c1/gto0kaHYyrixvknJ8tUK/Qs5IsmBtrc+FtgU=
12671267
golang.org/x/exp v0.0.0-20250911091902-df9299821621/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk=

libbeat/processors/add_docker_metadata/add_docker_metadata.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ func buildDockerMetadataProcessor(log *logp.Logger, cfg *conf.C, watcherConstruc
9393
dockerAvailable = true
9494
log.Debugf("%v: docker environment detected", processorName)
9595
if err = watcher.Start(); err != nil {
96-
return nil, fmt.Errorf("failed to start watcher: %w", err)
96+
// mark dockerAvailable as false because watcher creation failed
97+
dockerAvailable = false
98+
log.Infof("unable to start the docker watcher: %v", err)
9799
}
98100
}
99101

libbeat/processors/add_docker_metadata/add_docker_metadata_test.go

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package add_docker_metadata
2121

2222
import (
23+
"errors"
2324
"fmt"
2425
"os"
2526
"runtime"
@@ -34,6 +35,7 @@ import (
3435
"github.com/elastic/elastic-agent-autodiscover/docker"
3536
"github.com/elastic/elastic-agent-libs/config"
3637
"github.com/elastic/elastic-agent-libs/logp"
38+
"github.com/elastic/elastic-agent-libs/logp/logptest"
3739
"github.com/elastic/elastic-agent-libs/mapstr"
3840
"github.com/elastic/elastic-agent-system-metrics/metric/system/cgroup"
3941
"github.com/elastic/elastic-agent-system-metrics/metric/system/resolve"
@@ -114,7 +116,7 @@ func TestInitializationNoDocker(t *testing.T) {
114116
func TestInitialization(t *testing.T) {
115117
var testConfig = config.NewConfig()
116118

117-
p, err := buildDockerMetadataProcessor(logp.L(), testConfig, MockWatcherFactory(nil))
119+
p, err := buildDockerMetadataProcessor(logp.L(), testConfig, MockWatcherFactory(nil, nil))
118120
assert.NoError(t, err, "initializing add_docker_metadata processor")
119121

120122
input := mapstr.M{}
@@ -130,7 +132,7 @@ func TestNoMatch(t *testing.T) {
130132
})
131133
assert.NoError(t, err)
132134

133-
p, err := buildDockerMetadataProcessor(logp.L(), testConfig, MockWatcherFactory(nil))
135+
p, err := buildDockerMetadataProcessor(logp.L(), testConfig, MockWatcherFactory(nil, nil))
134136
assert.NoError(t, err, "initializing add_docker_metadata processor")
135137

136138
input := mapstr.M{
@@ -148,7 +150,7 @@ func TestMatchNoContainer(t *testing.T) {
148150
})
149151
assert.NoError(t, err)
150152

151-
p, err := buildDockerMetadataProcessor(logp.L(), testConfig, MockWatcherFactory(nil))
153+
p, err := buildDockerMetadataProcessor(logp.L(), testConfig, MockWatcherFactory(nil, nil))
152154
assert.NoError(t, err, "initializing add_docker_metadata processor")
153155

154156
input := mapstr.M{
@@ -179,7 +181,7 @@ func TestMatchContainer(t *testing.T) {
179181
"b.foo": "3",
180182
},
181183
},
182-
}))
184+
}, nil))
183185
assert.NoError(t, err, "initializing add_docker_metadata processor")
184186

185187
input := mapstr.M{
@@ -227,7 +229,7 @@ func TestMatchContainerWithDedot(t *testing.T) {
227229
"b.foo": "3",
228230
},
229231
},
230-
}))
232+
}, nil))
231233
assert.NoError(t, err, "initializing add_docker_metadata processor")
232234

233235
input := mapstr.M{
@@ -269,7 +271,7 @@ func TestMatchSource(t *testing.T) {
269271
"b": "2",
270272
},
271273
},
272-
}))
274+
}, nil))
273275
assert.NoError(t, err, "initializing add_docker_metadata processor")
274276

275277
var inputSource string
@@ -328,7 +330,7 @@ func TestDisableSource(t *testing.T) {
328330
"b": "2",
329331
},
330332
},
331-
}))
333+
}, nil))
332334
assert.NoError(t, err, "initializing add_docker_metadata processor")
333335

334336
input := mapstr.M{
@@ -354,6 +356,7 @@ func TestMatchPIDs(t *testing.T) {
354356
},
355357
},
356358
},
359+
nil,
357360
))
358361
assert.NoError(t, err, "initializing add_docker_metadata processor")
359362

@@ -436,22 +439,45 @@ func TestMatchPIDs(t *testing.T) {
436439
})
437440
}
438441

442+
func TestWatcherError(t *testing.T) {
443+
logger, observedLogs := logptest.NewTestingLoggerWithObserver(t, "")
444+
testConfig, err := config.NewConfigFrom(map[string]interface{}{
445+
"match_fields": []string{"foo"},
446+
})
447+
assert.NoError(t, err)
448+
449+
p, err := buildDockerMetadataProcessor(logger, testConfig, MockWatcherFactory(nil, errors.New("mock error")))
450+
assert.NoError(t, err, "initializing add_docker_metadata processor")
451+
assert.Len(t, observedLogs.FilterMessageSnippet("unable to start the docker watcher").TakeAll(), 1)
452+
453+
input := mapstr.M{
454+
"field": "value",
455+
}
456+
result, err := p.Run(&beat.Event{Fields: input})
457+
assert.NoError(t, err, "processing an event")
458+
assert.Equal(t, mapstr.M{"field": "value"}, result.Fields)
459+
}
460+
439461
// Mock container watcher
440462

441-
func MockWatcherFactory(containers map[string]*docker.Container) docker.WatcherConstructor {
463+
func MockWatcherFactory(containers map[string]*docker.Container, startErr error) docker.WatcherConstructor {
442464
if containers == nil {
443465
containers = make(map[string]*docker.Container)
444466
}
445467
return func(_ *logp.Logger, host string, tls *docker.TLSConfig, shortID bool) (docker.Watcher, error) {
446-
return &mockWatcher{containers: containers}, nil
468+
return &mockWatcher{containers: containers, startErr: startErr}, nil
447469
}
448470
}
449471

450472
type mockWatcher struct {
451473
containers map[string]*docker.Container
474+
startErr error
452475
}
453476

454477
func (m *mockWatcher) Start() error {
478+
if m.startErr != nil {
479+
return m.startErr
480+
}
455481
return nil
456482
}
457483

x-pack/filebeat/fbreceiver/receiver_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ func TestNewReceiver(t *testing.T) {
9090
AssertFunc: func(c *assert.CollectT, logs map[string][]mapstr.M, zapLogs *observer.ObservedLogs) {
9191
_ = zapLogs
9292
require.Lenf(c, logs["r1"], 1, "expected 1 log, got %d", len(logs["r1"]))
93-
assert.Equal(c, "filebeatreceiver/r1", logs["r1"][0].Flatten()["agent.otelcol.component.id"], "expected agent.otelcol.component.id field in log record")
94-
assert.Equal(c, "receiver", logs["r1"][0].Flatten()["agent.otelcol.component.kind"], "expected agent.otelcol.component.kind field in log record")
93+
assert.Equal(c, "test", logs["r1"][0].Flatten()["message"], "expected message field to contain string 'test'")
9594
var lastError strings.Builder
9695
assert.Conditionf(c, func() bool {
9796
return getFromSocket(t, &lastError, monitorSocket, "stats")
@@ -250,10 +249,8 @@ func TestMultipleReceivers(t *testing.T) {
250249
require.Greater(c, len(logs["r1"]), 0, "receiver r1 does not have any logs")
251250
require.Greater(c, len(logs["r2"]), 0, "receiver r2 does not have any logs")
252251

253-
assert.Equal(c, "filebeatreceiver/r1", logs["r1"][0].Flatten()["agent.otelcol.component.id"], "expected agent.otelcol.component.id field in r1 log record")
254-
assert.Equal(c, "receiver", logs["r1"][0].Flatten()["agent.otelcol.component.kind"], "expected agent.otelcol.component.kind field in r1 log record")
255-
assert.Equal(c, "filebeatreceiver/r2", logs["r2"][0].Flatten()["agent.otelcol.component.id"], "expected agent.otelcol.component.id field in r2 log record")
256-
assert.Equal(c, "receiver", logs["r2"][0].Flatten()["agent.otelcol.component.kind"], "expected agent.otelcol.component.kind field in r2 log record")
252+
assert.Equal(c, "test", logs["r1"][0].Flatten()["message"], "expected r1 message field to be 'test'")
253+
assert.Equal(c, "test", logs["r2"][0].Flatten()["message"], "expected r2 message field to be 'test'")
257254

258255
// Make sure that each receiver has a separate logger
259256
// instance and does not interfere with others. Previously, the

x-pack/filebeat/input/gcppubsub/otel_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,7 @@ processors:
175175
"agent.ephemeral_id",
176176
"agent.id",
177177
"event.created",
178-
// only present in beats receivers
179-
"agent.otelcol.component.id",
180-
"agent.otelcol.component.kind",
181178
}
182179

183180
oteltest.AssertMapsEqual(t, filebeatDoc, otelDoc, ignoredFields, "expected documents to be equal")
184-
185181
}

x-pack/filebeat/tests/integration/otel_lsexporter_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestDataShapeOTelVSClassicE2E(t *testing.T) {
6565

6666
// Agent does not support `index` setting, while beats does.
6767
// Our focus is on agent classic vs otel mode comparison, so we do not test `index` for filebeat
68-
var beatsCfgFile = `
68+
beatsCfgFile := `
6969
filebeat.inputs:
7070
- type: filestream
7171
id: filestream-input-id
@@ -173,8 +173,6 @@ service:
173173
"log.file.inode",
174174
"log.file.path",
175175
// only present in beats receivers
176-
"agent.otelcol.component.id",
177-
"agent.otelcol.component.kind",
178176
"log.file.device_id",
179177
"log.file.fingerprint",
180178
}
@@ -268,7 +266,6 @@ service:
268266
require.NoError(t, err, "failed to read otel events")
269267
require.Equal(t, numEvents, len(otelEvents),
270268
"different number of events: sent=%d, get=%d", numEvents, len(otelEvents))
271-
272269
}
273270

274271
func generateEvents(numEvents int) []string {
@@ -377,10 +374,8 @@ func compareOutputFiles(t *testing.T, fbFilePath, otelFilePath string, ignoredFi
377374
oteltest.AssertMapsEqual(t, fbEvent.data, otelEvent.data, ignoredFields,
378375
fmt.Sprintf("event comparison failed for ID %s (line %d)", fbEvent.id, i))
379376

380-
assert.Equal(t, "filebeatreceiver", otelEvent.data.Flatten()["agent.otelcol.component.id"], "expected agent.otelcol.component.id field in log record")
381-
assert.Equal(t, "receiver", otelEvent.data.Flatten()["agent.otelcol.component.kind"], "expected agent.otelcol.component.kind field in log record")
382-
assert.NotContains(t, fbEvent.data.Flatten(), "agent.otelcol.component.id", "expected agent.otelcol.component.id field not to be present in filebeat log record")
383-
assert.NotContains(t, fbEvent.data.Flatten(), "agent.otelcol.component.kind", "expected agent.otelcol.component.kind field not to be present in filebeat log record")
377+
assert.Equal(t, "filebeat", otelEvent.data.Flatten()["agent.type"], "expected agent.type to be 'filebeat' in otel data")
378+
assert.Equal(t, "filebeat", fbEvent.data.Flatten()["agent.type"], "expected agent.type to be 'filebeat' in filebeat data")
384379
}
385380
}
386381

0 commit comments

Comments
 (0)