Skip to content

Commit

Permalink
Merge pull request #1740 from davide-rossi-ce/forward-output-time-as-…
Browse files Browse the repository at this point in the history
…integer

Forward output time_as_integer
  • Loading branch information
pepov authored May 21, 2024
2 parents ee668e7 + 6515926 commit 017e076
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down Expand Up @@ -9405,6 +9407,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down Expand Up @@ -8693,6 +8695,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down Expand Up @@ -9405,6 +9407,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down Expand Up @@ -8693,6 +8695,8 @@ spec:
type: array
slow_flush_log_threshold:
type: string
time_as_integer:
type: boolean
tls_allow_self_signed_cert:
type: boolean
tls_cert_logical_store_name:
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration/plugins/outputs/forward.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ Default: 60
The threshold for chunk flush performance check. Parameter type is float, not time, default: 20.0 (seconds) If chunk flush takes longer time than this threshold, fluentd logs warning message and increases metric fluentd_output_status_slow_flush_count.


### time_as_integer (bool, optional) {#forwardoutput-time_as_integer}

Format forwarded events time as an epoch Integer with second resolution. Useful when forwarding to old ( <= 0.12 ) Fluentd servers.


### tls_allow_self_signed_cert (bool, optional) {#forwardoutput-tls_allow_self_signed_cert}

Allow self signed certificates or not.
Expand Down
2 changes: 2 additions & 0 deletions pkg/sdk/logging/model/output/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ type ForwardOutput struct {
// Parameter type is float, not time, default: 20.0 (seconds)
// If chunk flush takes longer time than this threshold, fluentd logs warning message and increases metric fluentd_output_status_slow_flush_count.
SlowFlushLogThreshold string `json:"slow_flush_log_threshold,omitempty"`
// Format forwarded events time as an epoch Integer with second resolution. Useful when forwarding to old ( <= 0.12 ) Fluentd servers.
TimeAsInteger bool `json:"time_as_integer,omitempty"`
}

func (f *ForwardOutput) ToDirective(secretLoader secret.SecretLoader, id string) (types.Directive, error) {
Expand Down
80 changes: 80 additions & 0 deletions pkg/sdk/logging/model/output/forward_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright © 2019 Banzai Cloud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package output_test

import (
"testing"

"github.com/ghodss/yaml"
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/output"
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/render"
"github.com/stretchr/testify/require"
)

func TestForward(t *testing.T) {
CONFIG := []byte(`
servers:
- host: 192.168.1.3
name: myserver1
port: 24224
weight: 60
- host: 192.168.1.4
name: myserver2
port: 24223
weight: 40
buffer:
timekey: 1m
timekey_wait: 30s
timekey_use_utc: true
keepalive: true
keepalive_timeout: 20
time_as_integer: true
send_timeout: 60
`)
expected := `
<match **>
@type forward
@id test
keepalive true
keepalive_timeout 20
send_timeout 60
time_as_integer true
<buffer tag,time>
@type file
path /buffers/test.*.buffer
retry_forever true
timekey 1m
timekey_use_utc true
timekey_wait 30s
</buffer>
<server>
host 192.168.1.3
name myserver1
port 24224
weight 60
</server>
<server>
host 192.168.1.4
name myserver2
port 24223
weight 40
</server>
</match>
`
g := &output.ForwardOutput{}
require.NoError(t, yaml.Unmarshal(CONFIG, g))
test := render.NewOutputPluginTest(t, g)
test.DiffResult(expected)
}

0 comments on commit 017e076

Please sign in to comment.