forked from openshift/cluster-logging-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoutput_forward.go
More file actions
83 lines (72 loc) · 1.83 KB
/
output_forward.go
File metadata and controls
83 lines (72 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package functional
import (
"fmt"
"strings"
"github.com/ViaQ/logerr/log"
logging "github.com/openshift/cluster-logging-operator/pkg/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/pkg/constants"
"github.com/openshift/cluster-logging-operator/pkg/utils"
"github.com/openshift/cluster-logging-operator/test/runtime"
)
const (
unsecureFluentConf = `
<system>
log_level trace
</system>
<source>
@type forward
</source>
<filter **>
@type stdout
include_time_key true
</filter>
<match kubernetes.**>
@type file
append true
path /tmp/app.logs
symlink_path /tmp/app-logs
<format>
@type json
</format>
</match>
<filter linux-audit.log**>
@type parser
key_name @timestamp
reserve_data true
<parse>
@type regexp
expression (?<time>[^\]]*)
time_type string
time_key time
time_format %Y-%m-%dT%H:%M:%S.%N%z
</parse>
</filter>
<match linux-audit.log** k8s-audit.log** openshift-audit.log**>
@type file
path /tmp/audit.logs
append true
symlink_path /tmp/audit-logs
<format>
@type json
</format>
</match>`
)
func (f *FluentdFunctionalFramework) addForwardOutput(b *runtime.PodBuilder, output logging.OutputSpec) error {
log.V(2).Info("Adding forward output", "name", output.Name)
name := strings.ToLower(output.Name)
configName := fmt.Sprintf("%s-config", name)
log.V(2).Info("Creating configmap", "name", configName)
config := runtime.NewConfigMap(b.Pod.Namespace, configName, map[string]string{
"fluent.conf": unsecureFluentConf,
})
if err := f.Test.Client.Create(config); err != nil {
return err
}
log.V(2).Info("Adding container", "name", name)
b.AddContainer(name, utils.GetComponentImage(constants.FluentdName)).
AddVolumeMount(config.Name, "/tmp/config", "", true).
WithCmd("fluentd -c /tmp/config/fluent.conf").
End().
AddConfigMapVolume(config.Name, config.Name)
return nil
}