Skip to content

Commit 58c6ae1

Browse files
committed
Update monitoring tests
1 parent 6c4ed98 commit 58c6ae1

File tree

3 files changed

+44
-227
lines changed

3 files changed

+44
-227
lines changed

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

Lines changed: 41 additions & 224 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
@@ -351,9 +377,18 @@ inputs:
351377
binary: metricbeat
352378
id: prometheus/metrics-monitoring
353379
target: component
380+
- drop_fields:
381+
fields:
382+
- beat.stats.cgroup
383+
- beat.stats.cpu
384+
- beat.stats.handles
385+
- beat.stats.memstats
386+
- beat.stats.runtime
387+
ignore_missing: true
354388
type: beat/metrics
355389
use_output: monitoring
356-
- data_stream:
390+
- _runtime_experimental: otel
391+
data_stream:
357392
namespace: default
358393
id: metrics-monitoring-agent
359394
name: metrics-monitoring-agent
@@ -419,61 +454,6 @@ inputs:
419454
binary: elastic-agent
420455
id: elastic-agent
421456
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
477457
- data_stream:
478458
dataset: elastic_agent.elastic_agent
479459
namespace: default
@@ -585,61 +565,6 @@ inputs:
585565
binary: filebeat
586566
id: filebeat-default
587567
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
643568
- data_stream:
644569
dataset: elastic_agent.filebeat_input
645570
namespace: default
@@ -690,6 +615,7 @@ inputs:
690615
- drop_fields:
691616
fields:
692617
- http
618+
- system
693619
ignore_missing: true
694620
- add_fields:
695621
fields:
@@ -753,119 +679,10 @@ inputs:
753679
binary: filebeat
754680
id: filestream-otel
755681
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
811-
- data_stream:
812-
dataset: elastic_agent.elastic_agent
813-
namespace: default
814-
type: metrics
815-
failure_threshold: 5
816-
hosts:
817-
- placeholder
818-
id: metrics-monitoring-metricbeat-1
819-
index: metrics-elastic_agent.elastic_agent-default
820-
metricsets:
821-
- json
822-
namespace: agent
823-
path: /stats
824-
period: 1m0s
825-
processors:
826-
- add_fields:
827-
fields:
828-
dataset: elastic_agent.elastic_agent
829-
target: event
830-
- add_fields:
831-
fields:
832-
id: ""
833-
process: metricbeat
834-
snapshot: false
835-
version: placeholder
836-
target: elastic_agent
837-
- add_fields:
838-
fields:
839-
id: ""
840-
target: agent
841-
- copy_fields:
842-
fail_on_error: false
843-
fields:
844-
- from: http.agent.beat.cpu
845-
to: system.process.cpu
846-
- from: http.agent.beat.memstats.memory_sys
847-
to: system.process.memory.size
848-
- from: http.agent.beat.handles
849-
to: system.process.fd
850-
- from: http.agent.beat.cgroup
851-
to: system.process.cgroup
852-
- from: http.agent.apm-server
853-
to: apm-server
854-
- from: http.filebeat_input
855-
to: filebeat_input
856-
ignore_missing: true
857-
- drop_fields:
858-
fields:
859-
- http
860-
ignore_missing: true
861-
- add_fields:
862-
fields:
863-
binary: metricbeat
864-
id: prometheus/metrics-monitoring
865-
target: component
866682
type: http/metrics
867683
use_output: monitoring
868-
- data_stream:
684+
- _runtime_experimental: otel
685+
data_stream:
869686
namespace: default
870687
id: metrics-monitoring-collector
871688
name: metrics-monitoring-collector

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)