Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions pkg/resources/fluentbit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import (
)

func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, error) {
objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-metrics")

if r.fluentbitSpec.Metrics != nil && r.fluentbitSpec.Metrics.IsEnabled() {
return &corev1.Service{
ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-metrics"),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -45,19 +47,19 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState,
}, reconciler.StatePresent, nil
}
return &corev1.Service{
ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-monitor"),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil
}

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 {
objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-metrics")
if r.fluentbitSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil {
for k, v := range r.fluentbitSpec.Metrics.ServiceMonitorConfig.AdditionalLabels {
objectMetadata.Labels[k] = v
Expand Down Expand Up @@ -89,21 +91,22 @@ func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.Desired
}, reconciler.StatePresent, nil
}
return &v1.ServiceMonitor{
ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-metrics"),
ObjectMeta: objectMetadata,
Spec: v1.ServiceMonitorSpec{},
}, reconciler.StateAbsent, nil
}

func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredState, error) {
objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics")

if r.fluentbitSpec.BufferVolumeMetrics != nil && r.fluentbitSpec.BufferVolumeMetrics.IsEnabled() {
port := int32(defaultBufferVolumeMetricsPort)
if r.fluentbitSpec.BufferVolumeMetrics.Port != 0 {
port = r.fluentbitSpec.BufferVolumeMetrics.Port
}

return &corev1.Service{
ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics"),

ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -120,20 +123,19 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS
}, reconciler.StatePresent, nil
}
return &corev1.Service{
ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-monitor"),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil
}

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 {
objectMetadata := r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics")

objectMetadata.Labels = util.MergeLabels(objectMetadata.Labels, r.fluentbitSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels)
return &v1.ServiceMonitor{
ObjectMeta: objectMetadata,
Expand All @@ -159,7 +161,7 @@ func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.D
}, reconciler.StatePresent, nil
}
return &v1.ServiceMonitor{
ObjectMeta: r.FluentbitObjectMeta(fluentbitServiceName + "-buffer-metrics"),
ObjectMeta: objectMetadata,
Spec: v1.ServiceMonitorSpec{},
}, reconciler.StateAbsent, nil
}
20 changes: 12 additions & 8 deletions pkg/resources/fluentd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ func (r *Reconciler) service() (runtime.Object, reconciler.DesiredState, error)
}

func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, error) {
objectMetadata := r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd)

if r.fluentdSpec.Metrics != nil && r.fluentdSpec.Metrics.IsEnabled() {
desired := &corev1.Service{
ObjectMeta: r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -95,19 +97,19 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState,
return desired, reconciler.StatePresent, nil
}
return &corev1.Service{
ObjectMeta: r.FluentdObjectMeta(ServiceName+"-monitor", ComponentFluentd),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil
}

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 {
objectMetadata := r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd)
if r.fluentdSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil {
for k, v := range r.fluentdSpec.Metrics.ServiceMonitorConfig.AdditionalLabels {
objectMetadata.Labels[k] = v
Expand Down Expand Up @@ -138,20 +140,22 @@ func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.Desired
}, reconciler.StatePresent, nil
}
return &v1.ServiceMonitor{
ObjectMeta: r.FluentdObjectMeta(ServiceName+"-metrics", ComponentFluentd),
ObjectMeta: objectMetadata,
Spec: v1.ServiceMonitorSpec{},
}, reconciler.StateAbsent, nil
}

func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredState, error) {
objectMetadata := r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd)

if r.fluentdSpec.BufferVolumeMetrics != nil && r.fluentdSpec.BufferVolumeMetrics.IsEnabled() {
port := int32(defaultBufferVolumeMetricsPort)
if r.fluentdSpec.BufferVolumeMetrics.Port != 0 {
port = r.fluentdSpec.BufferVolumeMetrics.Port
}

desired := &corev1.Service{
ObjectMeta: r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -174,19 +178,19 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS
return desired, reconciler.StatePresent, nil
}
return &corev1.Service{
ObjectMeta: r.FluentdObjectMeta(ServiceName+"-buffer-monitor", ComponentFluentd),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil
}

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 {
objectMetadata := r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd)
if r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels != nil {
for k, v := range r.fluentdSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels {
objectMetadata.Labels[k] = v
Expand Down Expand Up @@ -216,7 +220,7 @@ func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.D
}, reconciler.StatePresent, nil
}
return &v1.ServiceMonitor{
ObjectMeta: r.FluentdObjectMeta(ServiceName+"-buffer-metrics", ComponentFluentd),
ObjectMeta: objectMetadata,
Spec: v1.ServiceMonitorSpec{},
}, reconciler.StateAbsent, nil
}
Expand Down
20 changes: 12 additions & 8 deletions pkg/resources/syslogng/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ func (r *Reconciler) service() (runtime.Object, reconciler.DesiredState, error)
}

func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState, error) {
objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG)

if r.syslogNGSpec.Metrics != nil && r.syslogNGSpec.Metrics.IsEnabled() {
desired := &corev1.Service{
ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -95,19 +97,19 @@ func (r *Reconciler) serviceMetrics() (runtime.Object, reconciler.DesiredState,
return desired, reconciler.StatePresent, nil
}
return &corev1.Service{
ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-monitor", ComponentSyslogNG),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil
}

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 {
objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG)
if r.syslogNGSpec.Metrics.ServiceMonitorConfig.AdditionalLabels != nil {
for k, v := range r.syslogNGSpec.Metrics.ServiceMonitorConfig.AdditionalLabels {
objectMetadata.Labels[k] = v
Expand Down Expand Up @@ -138,20 +140,22 @@ func (r *Reconciler) monitorServiceMetrics() (runtime.Object, reconciler.Desired
}, reconciler.StatePresent, nil
}
return &v1.ServiceMonitor{
ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-metrics", ComponentSyslogNG),
ObjectMeta: objectMetadata,
Spec: v1.ServiceMonitorSpec{},
}, reconciler.StateAbsent, nil
}

func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredState, error) {
objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG)

if r.syslogNGSpec.BufferVolumeMetrics != nil && r.syslogNGSpec.BufferVolumeMetrics.IsEnabled() {
port := int32(defaultBufferVolumeMetricsPort)
if r.syslogNGSpec.BufferVolumeMetrics.Port != 0 {
port = r.syslogNGSpec.BufferVolumeMetrics.Port
}

desired := &corev1.Service{
ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -174,19 +178,19 @@ func (r *Reconciler) serviceBufferMetrics() (runtime.Object, reconciler.DesiredS
return desired, reconciler.StatePresent, nil
}
return &corev1.Service{
ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-buffer-monitor", ComponentSyslogNG),
ObjectMeta: objectMetadata,
Spec: corev1.ServiceSpec{}}, reconciler.StateAbsent, nil
}

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 {
objectMetadata := r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG)
if r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels != nil {
for k, v := range r.syslogNGSpec.BufferVolumeMetrics.ServiceMonitorConfig.AdditionalLabels {
objectMetadata.Labels[k] = v
Expand Down Expand Up @@ -216,7 +220,7 @@ func (r *Reconciler) monitorBufferServiceMetrics() (runtime.Object, reconciler.D
}, reconciler.StatePresent, nil
}
return &v1.ServiceMonitor{
ObjectMeta: r.SyslogNGObjectMeta(ServiceName+"-buffer-metrics", ComponentSyslogNG),
ObjectMeta: objectMetadata,
Spec: v1.ServiceMonitorSpec{},
}, reconciler.StateAbsent, nil
}
Expand Down