Skip to content

Commit 017e076

Browse files
authored
Merge pull request #1740 from davide-rossi-ce/forward-output-time-as-integer
Forward output time_as_integer
2 parents ee668e7 + 6515926 commit 017e076

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,8 @@ spec:
22062206
type: array
22072207
slow_flush_log_threshold:
22082208
type: string
2209+
time_as_integer:
2210+
type: boolean
22092211
tls_allow_self_signed_cert:
22102212
type: boolean
22112213
tls_cert_logical_store_name:
@@ -9405,6 +9407,8 @@ spec:
94059407
type: array
94069408
slow_flush_log_threshold:
94079409
type: string
9410+
time_as_integer:
9411+
type: boolean
94089412
tls_allow_self_signed_cert:
94099413
type: boolean
94109414
tls_cert_logical_store_name:

charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,8 @@ spec:
22022202
type: array
22032203
slow_flush_log_threshold:
22042204
type: string
2205+
time_as_integer:
2206+
type: boolean
22052207
tls_allow_self_signed_cert:
22062208
type: boolean
22072209
tls_cert_logical_store_name:
@@ -8693,6 +8695,8 @@ spec:
86938695
type: array
86948696
slow_flush_log_threshold:
86958697
type: string
8698+
time_as_integer:
8699+
type: boolean
86968700
tls_allow_self_signed_cert:
86978701
type: boolean
86988702
tls_cert_logical_store_name:

config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,8 @@ spec:
22062206
type: array
22072207
slow_flush_log_threshold:
22082208
type: string
2209+
time_as_integer:
2210+
type: boolean
22092211
tls_allow_self_signed_cert:
22102212
type: boolean
22112213
tls_cert_logical_store_name:
@@ -9405,6 +9407,8 @@ spec:
94059407
type: array
94069408
slow_flush_log_threshold:
94079409
type: string
9410+
time_as_integer:
9411+
type: boolean
94089412
tls_allow_self_signed_cert:
94099413
type: boolean
94109414
tls_cert_logical_store_name:

config/crd/bases/logging.banzaicloud.io_outputs.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,8 @@ spec:
22022202
type: array
22032203
slow_flush_log_threshold:
22042204
type: string
2205+
time_as_integer:
2206+
type: boolean
22052207
tls_allow_self_signed_cert:
22062208
type: boolean
22072209
tls_cert_logical_store_name:
@@ -8693,6 +8695,8 @@ spec:
86938695
type: array
86948696
slow_flush_log_threshold:
86958697
type: string
8698+
time_as_integer:
8699+
type: boolean
86968700
tls_allow_self_signed_cert:
86978701
type: boolean
86988702
tls_cert_logical_store_name:

docs/configuration/plugins/outputs/forward.md

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Default: 60
111111
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.
112112

113113

114+
### time_as_integer (bool, optional) {#forwardoutput-time_as_integer}
115+
116+
Format forwarded events time as an epoch Integer with second resolution. Useful when forwarding to old ( <= 0.12 ) Fluentd servers.
117+
118+
114119
### tls_allow_self_signed_cert (bool, optional) {#forwardoutput-tls_allow_self_signed_cert}
115120

116121
Allow self signed certificates or not.

pkg/sdk/logging/model/output/forward.go

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ type ForwardOutput struct {
104104
// Parameter type is float, not time, default: 20.0 (seconds)
105105
// If chunk flush takes longer time than this threshold, fluentd logs warning message and increases metric fluentd_output_status_slow_flush_count.
106106
SlowFlushLogThreshold string `json:"slow_flush_log_threshold,omitempty"`
107+
// Format forwarded events time as an epoch Integer with second resolution. Useful when forwarding to old ( <= 0.12 ) Fluentd servers.
108+
TimeAsInteger bool `json:"time_as_integer,omitempty"`
107109
}
108110

109111
func (f *ForwardOutput) ToDirective(secretLoader secret.SecretLoader, id string) (types.Directive, error) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright © 2019 Banzai Cloud
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package output_test
16+
17+
import (
18+
"testing"
19+
20+
"github.com/ghodss/yaml"
21+
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/output"
22+
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/render"
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func TestForward(t *testing.T) {
27+
CONFIG := []byte(`
28+
servers:
29+
- host: 192.168.1.3
30+
name: myserver1
31+
port: 24224
32+
weight: 60
33+
- host: 192.168.1.4
34+
name: myserver2
35+
port: 24223
36+
weight: 40
37+
buffer:
38+
timekey: 1m
39+
timekey_wait: 30s
40+
timekey_use_utc: true
41+
keepalive: true
42+
keepalive_timeout: 20
43+
time_as_integer: true
44+
send_timeout: 60
45+
`)
46+
expected := `
47+
<match **>
48+
@type forward
49+
@id test
50+
keepalive true
51+
keepalive_timeout 20
52+
send_timeout 60
53+
time_as_integer true
54+
<buffer tag,time>
55+
@type file
56+
path /buffers/test.*.buffer
57+
retry_forever true
58+
timekey 1m
59+
timekey_use_utc true
60+
timekey_wait 30s
61+
</buffer>
62+
<server>
63+
host 192.168.1.3
64+
name myserver1
65+
port 24224
66+
weight 60
67+
</server>
68+
<server>
69+
host 192.168.1.4
70+
name myserver2
71+
port 24223
72+
weight 40
73+
</server>
74+
</match>
75+
`
76+
g := &output.ForwardOutput{}
77+
require.NoError(t, yaml.Unmarshal(CONFIG, g))
78+
test := render.NewOutputPluginTest(t, g)
79+
test.DiffResult(expected)
80+
}

0 commit comments

Comments
 (0)