Skip to content
Open
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
15 changes: 15 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ type LogToMetrics struct {
// Flag that defines if logs should be discarded after processing. This applies
// for all logs, no matter if they have emitted metrics or not.
DiscardLogs *bool `json:"discardLogs,omitempty"`
// The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
// unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
// this interval, which lowers resource usage under high load.
// +kubebuilder:validation:Minimum:=0
FlushIntervalSec *int32 `json:"flushIntervalSec,omitempty"`
// The interval for metrics emission, in nanoseconds. Works together with flushIntervalSec.
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Maximum:=999999999
FlushIntervalNsec *int32 `json:"flushIntervalNsec,omitempty"`
}

func (*LogToMetrics) Name() string {
Expand Down Expand Up @@ -109,5 +118,11 @@ func (l *LogToMetrics) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if l.DiscardLogs != nil {
kvs.Insert("Discard_logs", fmt.Sprintf("%t", *l.DiscardLogs))
}
if l.FlushIntervalSec != nil {
kvs.Insert("Flush_Interval_Sec", fmt.Sprintf("%d", *l.FlushIntervalSec))
}
if l.FlushIntervalNsec != nil {
kvs.Insert("Flush_Interval_Nsec", fmt.Sprintf("%d", *l.FlushIntervalNsec))
}
return kvs, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package filter

import (
"testing"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params"
. "github.com/onsi/gomega"
)

func TestFilter_LogToMetrics_FlushInterval(t *testing.T) {
g := NewGomegaWithT(t)

sl := plugins.NewSecretLoader(nil, "test namespace")

l := LogToMetrics{
Tag: "metrics",
MetricMode: "counter",
MetricName: "count_all",
FlushIntervalSec: new(int32(30)),
FlushIntervalNsec: new(int32(500000000)),
}

expected := params.NewKVs()
expected.Insert("Tag", "metrics")
expected.Insert("Metric_mode", "counter")
expected.Insert("Metric_name", "count_all")
expected.Insert("Flush_Interval_Sec", "30")
expected.Insert("Flush_Interval_Nsec", "500000000")

kvs, err := l.Params(sl)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(kvs).To(Equal(expected))
}

func TestFilter_LogToMetrics_NoFlushInterval(t *testing.T) {
g := NewGomegaWithT(t)

sl := plugins.NewSecretLoader(nil, "test namespace")

l := LogToMetrics{Tag: "metrics"}

expected := params.NewKVs()
expected.Insert("Tag", "metrics")

kvs, err := l.Params(sl)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(kvs).To(Equal(expected))
}
10 changes: 10 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/filter/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
15 changes: 15 additions & 0 deletions charts/fluent-operator/crds/fluentbit.fluent.io_filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterfilters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
2 changes: 2 additions & 0 deletions docs/plugins/fluentbit/filter/log_to_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ The Log To Metrics Filter plugin allows you to generate log-derived metrics. <br
| emitterName | Name of the emitter (advanced users) | string |
| emitterMemBufLimit | set a buffer limit to restrict memory usage of metrics emitter | string |
| discardLogs | Flag that defines if logs should be discarded after processing. This applies for all logs, no matter if they have emitted metrics or not. | *bool |
| flushIntervalSec | The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at this interval, which lowers resource usage under high load. | *int32 |
| flushIntervalNsec | The interval for metrics emission, in nanoseconds. Works together with flushIntervalSec. | *int32 |
30 changes: 30 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down Expand Up @@ -16444,6 +16459,21 @@ spec:
items:
type: string
type: array
flushIntervalNsec:
description: The interval for metrics emission, in nanoseconds.
Works together with flushIntervalSec.
format: int32
maximum: 999999999
minimum: 0
type: integer
flushIntervalSec:
description: |-
The interval for metrics emission, in seconds. If flushIntervalSec and flushIntervalNsec are both
unset or 0, metrics are emitted right after each filter match. Otherwise they are emitted at
this interval, which lowers resource usage under high load.
format: int32
minimum: 0
type: integer
kubernetesMode:
description: |-
If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name
Expand Down
Loading