forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_template.go
159 lines (137 loc) · 4.89 KB
/
project_template.go
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package generator
var ProjectTemplate = `{{range $i, $store := .projectTargets -}}
{{ if $store.CurrentTarget }}
<source>
@type tail
path /var/log/containers/*.log
pos_file /fluentd/log/fluentd-project-{{$store.ProjectName}}-logging.pos
time_format %Y-%m-%dT%H:%M:%S
tag {{$store.ProjectName}}.*
format json
read_from_head true
</source>
<filter {{$store.ProjectName}}.**>
@type kubernetes_metadata
merge_json_log true
preserve_json_log true
</filter>
<filter {{$store.ProjectName}}.**>
@type record_transformer
enable_ruby true
<record>
tag ${tag}
namespace ${record["kubernetes"]["namespace_name"]}
{{range $k, $val := $store.OutputTags -}}
{{$k}} {{$val}}
{{end -}}
projectID {{$store.ProjectName}}
</record>
</filter>
<filter {{$store.ProjectName}}.**>
@type grep
<regexp>
key namespace
pattern {{$store.GrepNamespace}}
</regexp>
</filter>
<filter {{$store.ProjectName}}.**>
@type record_transformer
remove_keys namespace
</filter>
<match {{$store.ProjectName}}.** project-custom.{{$store.ProjectName}}.**>
{{ if eq $store.CurrentTarget "elasticsearch"}}
@type elasticsearch
include_tag_key true
{{ if and $store.ElasticsearchConfig.AuthUserName $store.ElasticsearchConfig.AuthPassword}}
hosts {{$store.WrapElasticsearch.Scheme}}://{{$store.ElasticsearchConfig.AuthUserName}}:{{$store.ElasticsearchConfig.AuthPassword}}@{{$store.WrapElasticsearch.Host}}
{{else -}}
hosts {{$store.ElasticsearchConfig.Endpoint}}
{{end -}}
logstash_prefix "{{$store.ElasticsearchConfig.IndexPrefix}}"
logstash_format true
logstash_dateformat {{$store.WrapElasticsearch.DateFormat}}
type_name "container_log"
{{ if eq $store.WrapElasticsearch.Scheme "https"}}
ssl_verify {{$store.ElasticsearchConfig.SSLVerify}}
{{ if $store.ElasticsearchConfig.Certificate }}
ca_file /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_ca.pem
{{end -}}
{{ if and $store.ElasticsearchConfig.ClientCert $store.ElasticsearchConfig.ClientKey}}
client_cert /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_client-cert.pem
client_key /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_client-key.pem
{{end -}}
{{ if $store.ElasticsearchConfig.ClientKeyPass}}
client_key_pass {{$store.ElasticsearchConfig.ClientKeyPass}}
{{end -}}
{{end -}}
{{end -}}
{{ if eq $store.CurrentTarget "splunk"}}
@type splunk_hec
host {{$store.WrapSplunk.Host}}
port {{$store.WrapSplunk.Port}}
token {{$store.SplunkConfig.Token}}
{{ if $store.SplunkConfig.Source}}
sourcetype {{$store.SplunkConfig.Source}}
{{end -}}
{{ if $store.SplunkConfig.Index}}
default_index {{ $store.SplunkConfig.Index }}
{{end -}}
{{ if eq $store.WrapSplunk.Scheme "https"}}
use_ssl true
ssl_verify {{$store.SplunkConfig.SSLVerify}}
{{ if $store.SplunkConfig.Certificate }}
ca_file /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_ca.pem
{{end -}}
{{ if and $store.SplunkConfig.ClientCert $store.SplunkConfig.ClientKey}}
client_cert /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_client-cert.pem
client_key /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_client-key.pem
{{end -}}
{{ if $store.SplunkConfig.ClientKeyPass}}
client_key_pass {{ $store.SplunkConfig.ClientKeyPass }}
{{end -}}
{{end -}}
{{end -}}
{{ if eq $store.CurrentTarget "kafka"}}
@type kafka_buffered
{{ if $store.KafkaConfig.ZookeeperEndpoint }}
zookeeper {{$store.WrapKafka.Zookeeper}}
{{else}}
brokers {{$store.WrapKafka.Brokers}}
{{end}}
default_topic {{$store.KafkaConfig.Topic}}
output_data_type "json"
output_include_tag true
output_include_time true
# get_kafka_client_log true
max_send_retries 3
{{ if $store.KafkaConfig.Certificate }}
ssl_ca_cert /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_ca.pem
{{end}}
{{ if and $store.KafkaConfig.ClientCert $store.KafkaConfig.ClientKey}}
ssl_client_cert /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_client-cert.pem
ssl_client_cert_key /fluentd/etc/ssl/project_{{$store.WrapProjectName}}_client-key.pem
{{ end -}}
{{end -}}
{{ if eq $store.CurrentTarget "syslog"}}
@type remote_syslog
host {{$store.WrapSyslog.Host}}
port {{$store.WrapSyslog.Port}}
severity {{$store.SyslogConfig.Severity}}
program {{$store.SyslogConfig.Program}}
protocol {{$store.SyslogConfig.Protocol}}
{{end}}
<buffer>
@type file
path /fluentd/etc/buffer/project.{{$store.WrapProjectName}}.buffer
flush_interval {{$store.OutputFlushInterval}}s
{{ if eq $store.CurrentTarget "splunk"}}
buffer_chunk_limit 8m
{{end -}}
</buffer>
disable_retry_limit
num_threads 8
slow_flush_log_threshold 40.0
</match>
{{end -}}
{{end -}}
`