Skip to content

Commit 0b48117

Browse files
committed
Update monitoring tests
1 parent 6c4ed98 commit 0b48117

File tree

3 files changed

+34
-171
lines changed

3 files changed

+34
-171
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,6 +330,14 @@ 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
- data_stream:
316342
dataset: elastic_agent.metricbeat
317343
namespace: default
@@ -353,7 +379,8 @@ inputs:
353379
target: component
354380
type: beat/metrics
355381
use_output: monitoring
356-
- data_stream:
382+
- _runtime_experimental: otel
383+
data_stream:
357384
namespace: default
358385
id: metrics-monitoring-agent
359386
name: metrics-monitoring-agent
@@ -419,61 +446,6 @@ inputs:
419446
binary: elastic-agent
420447
id: elastic-agent
421448
target: component
422-
- data_stream:
423-
dataset: elastic_agent.elastic_agent
424-
namespace: default
425-
type: metrics
426-
failure_threshold: 5
427-
hosts:
428-
- placeholder
429-
id: metrics-monitoring-metricbeat-1
430-
index: metrics-elastic_agent.elastic_agent-default
431-
metricsets:
432-
- json
433-
namespace: agent
434-
path: /stats
435-
period: 1m0s
436-
processors:
437-
- add_fields:
438-
fields:
439-
dataset: elastic_agent.elastic_agent
440-
target: event
441-
- add_fields:
442-
fields:
443-
id: ""
444-
process: metricbeat
445-
snapshot: false
446-
version: placeholder
447-
target: elastic_agent
448-
- add_fields:
449-
fields:
450-
id: ""
451-
target: agent
452-
- copy_fields:
453-
fail_on_error: false
454-
fields:
455-
- from: http.agent.beat.cpu
456-
to: system.process.cpu
457-
- from: http.agent.beat.memstats.memory_sys
458-
to: system.process.memory.size
459-
- from: http.agent.beat.handles
460-
to: system.process.fd
461-
- from: http.agent.beat.cgroup
462-
to: system.process.cgroup
463-
- from: http.agent.apm-server
464-
to: apm-server
465-
- from: http.filebeat_input
466-
to: filebeat_input
467-
ignore_missing: true
468-
- drop_fields:
469-
fields:
470-
- http
471-
ignore_missing: true
472-
- add_fields:
473-
fields:
474-
binary: metricbeat
475-
id: beat/metrics-monitoring
476-
target: component
477449
- data_stream:
478450
dataset: elastic_agent.elastic_agent
479451
namespace: default
@@ -585,61 +557,6 @@ inputs:
585557
binary: filebeat
586558
id: filebeat-default
587559
target: component
588-
- data_stream:
589-
dataset: elastic_agent.elastic_agent
590-
namespace: default
591-
type: metrics
592-
failure_threshold: 5
593-
hosts:
594-
- placeholder
595-
id: metrics-monitoring-filebeat-1
596-
index: metrics-elastic_agent.elastic_agent-default
597-
metricsets:
598-
- json
599-
namespace: agent
600-
path: /stats
601-
period: 1m0s
602-
processors:
603-
- add_fields:
604-
fields:
605-
dataset: elastic_agent.elastic_agent
606-
target: event
607-
- add_fields:
608-
fields:
609-
id: ""
610-
process: filebeat
611-
snapshot: false
612-
version: placeholder
613-
target: elastic_agent
614-
- add_fields:
615-
fields:
616-
id: ""
617-
target: agent
618-
- copy_fields:
619-
fail_on_error: false
620-
fields:
621-
- from: http.agent.beat.cpu
622-
to: system.process.cpu
623-
- from: http.agent.beat.memstats.memory_sys
624-
to: system.process.memory.size
625-
- from: http.agent.beat.handles
626-
to: system.process.fd
627-
- from: http.agent.beat.cgroup
628-
to: system.process.cgroup
629-
- from: http.agent.apm-server
630-
to: apm-server
631-
- from: http.filebeat_input
632-
to: filebeat_input
633-
ignore_missing: true
634-
- drop_fields:
635-
fields:
636-
- http
637-
ignore_missing: true
638-
- add_fields:
639-
fields:
640-
binary: filebeat
641-
id: filestream-monitoring
642-
target: component
643560
- data_stream:
644561
dataset: elastic_agent.filebeat_input
645562
namespace: default
@@ -690,6 +607,7 @@ inputs:
690607
- drop_fields:
691608
fields:
692609
- http
610+
- system
693611
ignore_missing: true
694612
- add_fields:
695613
fields:
@@ -753,61 +671,6 @@ inputs:
753671
binary: filebeat
754672
id: filestream-otel
755673
target: component
756-
- data_stream:
757-
dataset: elastic_agent.elastic_agent
758-
namespace: default
759-
type: metrics
760-
failure_threshold: 5
761-
hosts:
762-
- placeholder
763-
id: metrics-monitoring-metricbeat-1
764-
index: metrics-elastic_agent.elastic_agent-default
765-
metricsets:
766-
- json
767-
namespace: agent
768-
path: /stats
769-
period: 1m0s
770-
processors:
771-
- add_fields:
772-
fields:
773-
dataset: elastic_agent.elastic_agent
774-
target: event
775-
- add_fields:
776-
fields:
777-
id: ""
778-
process: metricbeat
779-
snapshot: false
780-
version: placeholder
781-
target: elastic_agent
782-
- add_fields:
783-
fields:
784-
id: ""
785-
target: agent
786-
- copy_fields:
787-
fail_on_error: false
788-
fields:
789-
- from: http.agent.beat.cpu
790-
to: system.process.cpu
791-
- from: http.agent.beat.memstats.memory_sys
792-
to: system.process.memory.size
793-
- from: http.agent.beat.handles
794-
to: system.process.fd
795-
- from: http.agent.beat.cgroup
796-
to: system.process.cgroup
797-
- from: http.agent.apm-server
798-
to: apm-server
799-
- from: http.filebeat_input
800-
to: filebeat_input
801-
ignore_missing: true
802-
- drop_fields:
803-
fields:
804-
- http
805-
ignore_missing: true
806-
- add_fields:
807-
fields:
808-
binary: metricbeat
809-
id: http/metrics-monitoring
810-
target: component
811674
- data_stream:
812675
dataset: elastic_agent.elastic_agent
813676
namespace: default

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,7 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, componentInfo
490490
"streams": streams,
491491
}
492492

493-
// Make sure we don't set anything until the configuration is stable if the otel manager isn't enabled
494-
if b.config.C.RuntimeManager != monitoringCfg.DefaultRuntimeManager {
493+
if b.config.C.RuntimeManager == monitoringCfg.OtelRuntimeManager {
495494
input["_runtime_experimental"] = b.config.C.RuntimeManager
496495
}
497496

@@ -607,7 +606,7 @@ func (b *BeatsMonitor) injectMetricsInput(
607606
}
608607

609608
// Make sure we don't set anything until the configuration is stable if the otel manager isn't enabled
610-
if b.config.C.RuntimeManager != monitoringCfg.DefaultRuntimeManager {
609+
if b.config.C.RuntimeManager == monitoringCfg.OtelRuntimeManager {
611610
for _, input := range inputs {
612611
inputMap := input.(map[string]interface{})
613612
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)