@@ -47,6 +47,7 @@ const (
47
47
agentKey = "agent"
48
48
monitoringKey = "monitoring"
49
49
useOutputKey = "use_output"
50
+ monitoringMetricsPeriodKey = "metrics_period"
50
51
monitoringOutput = "monitoring"
51
52
defaultMonitoringNamespace = "default"
52
53
agentName = "elastic-agent"
@@ -58,7 +59,7 @@ const (
58
59
59
60
// metricset execution period used for the monitoring metrics inputs
60
61
// we set this to 60s to reduce the load/data volume on the monitoring cluster
61
- metricsCollectionInterval = 60 * time .Second
62
+ defaultMetricsCollectionInterval = 60 * time .Second
62
63
)
63
64
64
65
var (
@@ -129,6 +130,7 @@ func (b *BeatsMonitor) MonitoringConfig(
129
130
cfg := make (map [string ]interface {})
130
131
131
132
monitoringOutputName := defaultOutputName
133
+ metricsCollectionIntervalString := b .config .C .MetricsPeriod
132
134
if agentCfg , found := policy [agentKey ]; found {
133
135
// The agent section is required for feature flags
134
136
cfg [agentKey ] = agentCfg
@@ -143,6 +145,12 @@ func (b *BeatsMonitor) MonitoringConfig(
143
145
monitoringOutputName = useStr
144
146
}
145
147
}
148
+
149
+ if metricsPeriod , found := monitoringMap [monitoringMetricsPeriodKey ]; found {
150
+ if metricsPeriodStr , ok := metricsPeriod .(string ); ok {
151
+ metricsCollectionIntervalString = metricsPeriodStr
152
+ }
153
+ }
146
154
}
147
155
}
148
156
}
@@ -165,7 +173,7 @@ func (b *BeatsMonitor) MonitoringConfig(
165
173
}
166
174
167
175
if b .config .C .MonitorMetrics {
168
- if err := b .injectMetricsInput (cfg , componentIDToBinary , components , componentIDPidMap ); err != nil {
176
+ if err := b .injectMetricsInput (cfg , componentIDToBinary , components , componentIDPidMap , metricsCollectionIntervalString ); err != nil {
169
177
return nil , errors .New (err , "failed to inject monitoring output" )
170
178
}
171
179
}
@@ -542,8 +550,16 @@ func (b *BeatsMonitor) monitoringNamespace() string {
542
550
}
543
551
544
552
// injectMetricsInput injects monitoring config for agent monitoring to the `cfg` object.
545
- func (b * BeatsMonitor ) injectMetricsInput (cfg map [string ]interface {}, componentIDToBinary map [string ]string , componentList []component.Component , existingStateServicePids map [string ]uint64 ) error {
546
- metricsCollectionIntervalString := metricsCollectionInterval .String ()
553
+ func (b * BeatsMonitor ) injectMetricsInput (
554
+ cfg map [string ]interface {},
555
+ componentIDToBinary map [string ]string ,
556
+ componentList []component.Component ,
557
+ existingStateServicePids map [string ]uint64 ,
558
+ metricsCollectionIntervalString string ,
559
+ ) error {
560
+ if metricsCollectionIntervalString == "" {
561
+ metricsCollectionIntervalString = defaultMetricsCollectionInterval .String ()
562
+ }
547
563
monitoringNamespace := b .monitoringNamespace ()
548
564
fixedAgentName := strings .ReplaceAll (agentName , "-" , "_" )
549
565
beatsStreams := make ([]interface {}, 0 , len (componentIDToBinary ))
0 commit comments