diff --git a/pkg/resources/fluentbit/service.go b/pkg/resources/fluentbit/service.go index 5633866f6..80bc3ee67 100644 --- a/pkg/resources/fluentbit/service.go +++ b/pkg/resources/fluentbit/service.go @@ -52,19 +52,20 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, } func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { - var SampleLimit uint64 = 0 objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-metrics") - if r.fluentbitSpec.Metrics.ServiceMonitorConfig.Scheme == "" { - r.fluentbitSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() - } - if r.fluentbitSpec.Metrics != nil && r.fluentbitSpec.Metrics.IsEnabled() && r.fluentbitSpec.Metrics.ServiceMonitor { + if r.fluentbitSpec.Metrics.ServiceMonitorConfig.Scheme == "" { + r.fluentbitSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() + } + if r.fluentbitSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.fluentbitSpec.Metrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v } } + + var SampleLimit uint64 = 0 return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{ @@ -128,15 +129,16 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS } func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { - var SampleLimit uint64 = 0 objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics") - if r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { - r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() - } - if r.fluentbitSpec.BufferVolumeMetrics != nil && r.fluentbitSpec.BufferVolumeMetrics.IsEnabled() && r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitor { + if r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { + r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() + } + objectMetadata.Labels = util.MergeLabels(objectMetadata.Labels, r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels) + + var SampleLimit uint64 = 0 return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{ diff --git a/pkg/resources/fluentd/service.go b/pkg/resources/fluentd/service.go index 5428ed265..018e80865 100644 --- a/pkg/resources/fluentd/service.go +++ b/pkg/resources/fluentd/service.go @@ -102,20 +102,20 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, } func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { - var SampleLimit uint64 = 0 objectMetadata := r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd) - if r.fluentdSpec.Metrics.ServiceMonitorConfig.Scheme == "" { - r.fluentdSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() - } - if r.fluentdSpec.Metrics != nil && r.fluentdSpec.Metrics.IsEnabled() && r.fluentdSpec.Metrics.ServiceMonitor { + if r.fluentdSpec.Metrics.ServiceMonitorConfig.Scheme == "" { + r.fluentdSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() + } + if r.fluentdSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.fluentdSpec.Metrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v } } + var SampleLimit uint64 = 0 return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{ @@ -183,19 +183,20 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS } func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { - var SampleLimit uint64 = 0 objectMetadata := r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd) - if r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { - r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() - } - if r.fluentdSpec.BufferVolumeMetrics != nil && r.fluentdSpec.BufferVolumeMetrics.IsEnabled() && r.fluentdSpec.BufferVolumeMetrics.ServiceMonitor { + if r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { + r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() + } + if r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v } } + + var SampleLimit uint64 = 0 return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{ diff --git a/pkg/resources/syslogng/service.go b/pkg/resources/syslogng/service.go index 695628fed..d8e14b8c2 100644 --- a/pkg/resources/syslogng/service.go +++ b/pkg/resources/syslogng/service.go @@ -102,20 +102,20 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, } func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { - var SampleLimit uint64 = 0 objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG) - if r.syslogNGSpec.Metrics.ServiceMonitorConfig.Scheme == "" { - r.syslogNGSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() - } - if r.syslogNGSpec.Metrics != nil && r.syslogNGSpec.Metrics.IsEnabled() && r.syslogNGSpec.Metrics.ServiceMonitor { + if r.syslogNGSpec.Metrics.ServiceMonitorConfig.Scheme == "" { + r.syslogNGSpec.Metrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() + } + if r.syslogNGSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.syslogNGSpec.Metrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v } } + var SampleLimit uint64 = 0 return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{ @@ -183,19 +183,20 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS } func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.DesiredState, error) { - var SampleLimit uint64 = 0 objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG) - if r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { - r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() - } - if r.syslogNGSpec.BufferVolumeMetrics != nil && r.syslogNGSpec.BufferVolumeMetrics.IsEnabled() && r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitor { + if r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme == "" { + r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.Scheme = kubetool.To(v1.SchemeHTTP).String() + } + if r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels != nil { for k, v := range r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels { objectMetadata.Labels[k] = v } } + + var SampleLimit uint64 = 0 return &v1.ServiceMonitor{ ObjectMeta: objectMetadata, Spec: v1.ServiceMonitorSpec{