Skip to content

Commit c653ee5

Browse files
mergify[bot]leehinmanswiatekm
authored
[8.19] (backport #8338) Add filebeat_input to beat receiver agent monitoring integration test (#8473)
* Add filebeat_input to beat receiver agent monitoring integration test (#8338) (cherry picked from commit b8882aa) # Conflicts: # testing/integration/beat_receivers_test.go * Fix conflicts --------- Co-authored-by: Lee E Hinman <57081003+leehinman@users.noreply.github.com> Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
1 parent 3c1a6dd commit c653ee5

File tree

5 files changed

+153
-66
lines changed

5 files changed

+153
-66
lines changed

internal/pkg/agent/application/monitoring/testdata/monitoring_config_full.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,63 @@ inputs:
653653
binary: filebeat
654654
id: filestream-monitoring
655655
target: component
656+
- data_stream:
657+
dataset: elastic_agent.filebeat_input
658+
namespace: default
659+
type: metrics
660+
failure_threshold: 5
661+
hosts:
662+
- placeholder
663+
id: metrics-monitoring-filebeat-1
664+
index: metrics-elastic_agent.filebeat_input-default
665+
json.is_array: true
666+
metricsets:
667+
- json
668+
namespace: filebeat_input
669+
path: /inputs/
670+
period: 1m0s
671+
processors:
672+
- add_fields:
673+
fields:
674+
dataset: elastic_agent.filebeat_input
675+
target: event
676+
- add_fields:
677+
fields:
678+
id: ""
679+
process: filebeat
680+
snapshot: false
681+
version: placeholder
682+
target: elastic_agent
683+
- add_fields:
684+
fields:
685+
id: ""
686+
target: agent
687+
- copy_fields:
688+
fail_on_error: false
689+
fields:
690+
- from: http.agent.beat.cpu
691+
to: system.process.cpu
692+
- from: http.agent.beat.memstats.memory_sys
693+
to: system.process.memory.size
694+
- from: http.agent.beat.handles
695+
to: system.process.fd
696+
- from: http.agent.beat.cgroup
697+
to: system.process.cgroup
698+
- from: http.agent.apm-server
699+
to: apm-server
700+
- from: http.filebeat_input
701+
to: filebeat_input
702+
ignore_missing: true
703+
- drop_fields:
704+
fields:
705+
- http
706+
- system
707+
ignore_missing: true
708+
- add_fields:
709+
fields:
710+
binary: filebeat
711+
id: filestream-otel
712+
target: component
656713
- data_stream:
657714
dataset: elastic_agent.elastic_agent
658715
namespace: default

internal/pkg/agent/application/monitoring/v1_monitor.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,7 @@ func (b *BeatsMonitor) getHttpStreams(
700700
httpStreams = append(httpStreams, httpStream)
701701
}
702702
// specifically for filebeat, we include input metrics
703-
// disabled for filebeat receiver until https://github.com/elastic/beats/issues/43418 is resolved
704-
if strings.EqualFold(name, "filebeat") && compInfo.RuntimeManager != component.OtelRuntimeManager {
703+
if strings.EqualFold(name, "filebeat") {
705704
fbDataStreamName := "filebeat_input"
706705
fbDataset := fmt.Sprintf("elastic_agent.%s", fbDataStreamName)
707706
fbIndexName := fmt.Sprintf("metrics-elastic_agent.%s-%s", fbDataStreamName, monitoringNamespace)
@@ -842,7 +841,6 @@ func processorsForAgentFilestream() []any {
842841
addFormattedIndexProcessor(),
843842
)
844843
return processors
845-
846844
}
847845

848846
// processorsForServiceComponentFilestream returns processors used for filestream streams for components running as

internal/pkg/agent/application/monitoring/v1_monitor_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ func TestMonitoringWithEndpoint(t *testing.T) {
141141
Enabled: true,
142142
MonitorMetrics: true,
143143
HTTP: &monitoringcfg.MonitoringHTTPConfig{
144-
145144
Enabled: true,
146145
},
147146
},
@@ -213,7 +212,6 @@ func TestMonitoringWithEndpoint(t *testing.T) {
213212
require.Equal(t, uint64(1234), streamValues["process.pid"])
214213
}
215214
}
216-
217215
}
218216
}
219217
}
@@ -222,7 +220,6 @@ func TestMonitoringWithEndpoint(t *testing.T) {
222220
}
223221

224222
func TestMonitoringConfigMetricsInterval(t *testing.T) {
225-
226223
agentInfo, err := info.NewAgentInfo(context.Background(), false)
227224
require.NoError(t, err, "Error creating agent info")
228225
components := []component.Component{{ID: "foobeat", InputSpec: &component.InputRuntimeSpec{BinaryName: "filebeat"}}}
@@ -317,7 +314,6 @@ func TestMonitoringConfigMetricsInterval(t *testing.T) {
317314
}
318315

319316
for _, tc := range tcs {
320-
321317
t.Run(tc.name, func(t *testing.T) {
322318
b := &BeatsMonitor{
323319
enabled: true,
@@ -370,7 +366,6 @@ func TestMonitoringConfigMetricsInterval(t *testing.T) {
370366
}
371367

372368
func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
373-
374369
agentInfo, err := info.NewAgentInfo(context.Background(), false)
375370
require.NoError(t, err, "Error creating agent info")
376371
components := []component.Component{{ID: "foobeat", InputSpec: &component.InputRuntimeSpec{BinaryName: "filebeat"}}}
@@ -552,7 +547,6 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
552547
}
553548

554549
for _, tc := range tcs {
555-
556550
t.Run(tc.name, func(t *testing.T) {
557551
b := &BeatsMonitor{
558552
enabled: true,
@@ -603,7 +597,6 @@ func TestMonitoringConfigMetricsFailureThreshold(t *testing.T) {
603597
}
604598

605599
func TestErrorMonitoringConfigMetricsFailureThreshold(t *testing.T) {
606-
607600
agentInfo, err := info.NewAgentInfo(context.Background(), false)
608601
components := []component.Component{{ID: "foobeat", InputSpec: &component.InputRuntimeSpec{BinaryName: "filebeat"}}}
609602
require.NoError(t, err, "Error creating agent info")
@@ -729,7 +722,6 @@ func TestErrorMonitoringConfigMetricsFailureThreshold(t *testing.T) {
729722
}
730723

731724
for _, tc := range tcs {
732-
733725
t.Run(tc.name, func(t *testing.T) {
734726
b := &BeatsMonitor{
735727
enabled: true,
@@ -936,7 +928,7 @@ func TestMonitoringConfigForBeatsReceivers(t *testing.T) {
936928
}
937929
}
938930
}
939-
assert.Len(t, streamsForInputMetrics, 2)
931+
assert.Len(t, streamsForInputMetrics, 3)
940932
}
941933

942934
func TestMonitoringWithOtelRuntime(t *testing.T) {

0 commit comments

Comments
 (0)