Skip to content

Commit ca48a67

Browse files
committed
Update monitoring tests
1 parent 71ea1ca commit ca48a67

File tree

3 files changed

+34
-172
lines changed

3 files changed

+34
-172
lines changed

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

Lines changed: 31 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ agent:
44
enabled: false
55
metrics: true
66
inputs:
7-
- id: filestream-monitoring-agent
7+
- _runtime_experimental: otel
8+
id: filestream-monitoring-agent
89
name: filestream-monitoring-agent
910
streams:
1011
- close:
@@ -104,7 +105,8 @@ inputs:
104105
type: filestream
105106
type: filestream
106107
use_output: monitoring
107-
- data_stream:
108+
- _runtime_experimental: otel
109+
data_stream:
108110
namespace: default
109111
id: metrics-monitoring-beats
110112
name: metrics-monitoring-beats
@@ -148,6 +150,14 @@ inputs:
148150
binary: metricbeat
149151
id: beat/metrics-monitoring
150152
target: component
153+
- drop_fields:
154+
fields:
155+
- beat.stats.cgroup
156+
- beat.stats.cpu
157+
- beat.stats.handles
158+
- beat.stats.memstats
159+
- beat.stats.runtime
160+
ignore_missing: true
151161
- data_stream:
152162
dataset: elastic_agent.filebeat
153163
namespace: default
@@ -226,6 +236,14 @@ inputs:
226236
binary: filebeat
227237
id: filestream-monitoring
228238
target: component
239+
- drop_fields:
240+
fields:
241+
- beat.stats.cgroup
242+
- beat.stats.cpu
243+
- beat.stats.handles
244+
- beat.stats.memstats
245+
- beat.stats.runtime
246+
ignore_missing: true
229247
- data_stream:
230248
dataset: elastic_agent.filebeat
231249
namespace: default
@@ -312,9 +330,18 @@ inputs:
312330
binary: metricbeat
313331
id: http/metrics-monitoring
314332
target: component
333+
- drop_fields:
334+
fields:
335+
- beat.stats.cgroup
336+
- beat.stats.cpu
337+
- beat.stats.handles
338+
- beat.stats.memstats
339+
- beat.stats.runtime
340+
ignore_missing: true
315341
type: beat/metrics
316342
use_output: monitoring
317-
- data_stream:
343+
- _runtime_experimental: otel
344+
data_stream:
318345
namespace: default
319346
id: metrics-monitoring-agent
320347
name: metrics-monitoring-agent
@@ -380,61 +407,6 @@ inputs:
380407
binary: elastic-agent
381408
id: elastic-agent
382409
target: component
383-
- data_stream:
384-
dataset: elastic_agent.elastic_agent
385-
namespace: default
386-
type: metrics
387-
failure_threshold: 5
388-
hosts:
389-
- placeholder
390-
id: metrics-monitoring-metricbeat-1
391-
index: metrics-elastic_agent.elastic_agent-default
392-
metricsets:
393-
- json
394-
namespace: agent
395-
path: /stats
396-
period: 1m0s
397-
processors:
398-
- add_fields:
399-
fields:
400-
dataset: elastic_agent.elastic_agent
401-
target: event
402-
- add_fields:
403-
fields:
404-
id: ""
405-
process: metricbeat
406-
snapshot: false
407-
version: placeholder
408-
target: elastic_agent
409-
- add_fields:
410-
fields:
411-
id: ""
412-
target: agent
413-
- copy_fields:
414-
fail_on_error: false
415-
fields:
416-
- from: http.agent.beat.cpu
417-
to: system.process.cpu
418-
- from: http.agent.beat.memstats.memory_sys
419-
to: system.process.memory.size
420-
- from: http.agent.beat.handles
421-
to: system.process.fd
422-
- from: http.agent.beat.cgroup
423-
to: system.process.cgroup
424-
- from: http.agent.apm-server
425-
to: apm-server
426-
- from: http.filebeat_input
427-
to: filebeat_input
428-
ignore_missing: true
429-
- drop_fields:
430-
fields:
431-
- http
432-
ignore_missing: true
433-
- add_fields:
434-
fields:
435-
binary: metricbeat
436-
id: beat/metrics-monitoring
437-
target: component
438410
- data_stream:
439411
dataset: elastic_agent.elastic_agent
440412
namespace: default
@@ -546,61 +518,6 @@ inputs:
546518
binary: filebeat
547519
id: filebeat-default
548520
target: component
549-
- data_stream:
550-
dataset: elastic_agent.elastic_agent
551-
namespace: default
552-
type: metrics
553-
failure_threshold: 5
554-
hosts:
555-
- placeholder
556-
id: metrics-monitoring-filebeat-1
557-
index: metrics-elastic_agent.elastic_agent-default
558-
metricsets:
559-
- json
560-
namespace: agent
561-
path: /stats
562-
period: 1m0s
563-
processors:
564-
- add_fields:
565-
fields:
566-
dataset: elastic_agent.elastic_agent
567-
target: event
568-
- add_fields:
569-
fields:
570-
id: ""
571-
process: filebeat
572-
snapshot: false
573-
version: placeholder
574-
target: elastic_agent
575-
- add_fields:
576-
fields:
577-
id: ""
578-
target: agent
579-
- copy_fields:
580-
fail_on_error: false
581-
fields:
582-
- from: http.agent.beat.cpu
583-
to: system.process.cpu
584-
- from: http.agent.beat.memstats.memory_sys
585-
to: system.process.memory.size
586-
- from: http.agent.beat.handles
587-
to: system.process.fd
588-
- from: http.agent.beat.cgroup
589-
to: system.process.cgroup
590-
- from: http.agent.apm-server
591-
to: apm-server
592-
- from: http.filebeat_input
593-
to: filebeat_input
594-
ignore_missing: true
595-
- drop_fields:
596-
fields:
597-
- http
598-
ignore_missing: true
599-
- add_fields:
600-
fields:
601-
binary: filebeat
602-
id: filestream-monitoring
603-
target: component
604521
- data_stream:
605522
dataset: elastic_agent.filebeat_input
606523
namespace: default
@@ -651,6 +568,7 @@ inputs:
651568
- drop_fields:
652569
fields:
653570
- http
571+
- system
654572
ignore_missing: true
655573
- add_fields:
656574
fields:
@@ -714,61 +632,6 @@ inputs:
714632
binary: filebeat
715633
id: filestream-otel
716634
target: component
717-
- data_stream:
718-
dataset: elastic_agent.elastic_agent
719-
namespace: default
720-
type: metrics
721-
failure_threshold: 5
722-
hosts:
723-
- placeholder
724-
id: metrics-monitoring-metricbeat-1
725-
index: metrics-elastic_agent.elastic_agent-default
726-
metricsets:
727-
- json
728-
namespace: agent
729-
path: /stats
730-
period: 1m0s
731-
processors:
732-
- add_fields:
733-
fields:
734-
dataset: elastic_agent.elastic_agent
735-
target: event
736-
- add_fields:
737-
fields:
738-
id: ""
739-
process: metricbeat
740-
snapshot: false
741-
version: placeholder
742-
target: elastic_agent
743-
- add_fields:
744-
fields:
745-
id: ""
746-
target: agent
747-
- copy_fields:
748-
fail_on_error: false
749-
fields:
750-
- from: http.agent.beat.cpu
751-
to: system.process.cpu
752-
- from: http.agent.beat.memstats.memory_sys
753-
to: system.process.memory.size
754-
- from: http.agent.beat.handles
755-
to: system.process.fd
756-
- from: http.agent.beat.cgroup
757-
to: system.process.cgroup
758-
- from: http.agent.apm-server
759-
to: apm-server
760-
- from: http.filebeat_input
761-
to: filebeat_input
762-
ignore_missing: true
763-
- drop_fields:
764-
fields:
765-
- http
766-
ignore_missing: true
767-
- add_fields:
768-
fields:
769-
binary: metricbeat
770-
id: http/metrics-monitoring
771-
target: component
772635
type: http/metrics
773636
use_output: monitoring
774637
- data_stream:

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, componentInfo
471471
"streams": streams,
472472
}
473473

474-
// Make sure we don't set anything until the configuration is stable if the otel manager isn't enabled
475-
if b.config.C.RuntimeManager != monitoringCfg.DefaultRuntimeManager {
474+
if b.config.C.RuntimeManager == monitoringCfg.OtelRuntimeManager {
476475
input["_runtime_experimental"] = b.config.C.RuntimeManager
477476
}
478477

@@ -542,8 +541,7 @@ func (b *BeatsMonitor) injectMetricsInput(
542541
},
543542
}
544543

545-
// Make sure we don't set anything until the configuration is stable if the otel manager isn't enabled
546-
if b.config.C.RuntimeManager != monitoringCfg.DefaultRuntimeManager {
544+
if b.config.C.RuntimeManager == monitoringCfg.OtelRuntimeManager {
547545
for _, input := range inputs {
548546
inputMap := input.(map[string]interface{})
549547
inputMap["_runtime_experimental"] = b.config.C.RuntimeManager

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func TestMonitoringFull(t *testing.T) {
128128
outCfgString := string(outCfgBytes)
129129
// replace the version with a placeholder
130130
outCfgString = strings.ReplaceAll(outCfgString, agentInfo.Version(), "placeholder")
131+
//os.WriteFile(expectedConfigFilePath, []byte(outCfgString), 0644)
131132
assert.Equal(t, string(expectedConfigBytes), outCfgString)
132133
}
133134

0 commit comments

Comments
 (0)