forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster_template.go
130 lines (117 loc) · 3.81 KB
/
cluster_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
package generator
var ClusterTemplate = `{{ if .clusterTarget.CurrentTarget }}
<source>
@type tail
path /var/lib/rancher/rke/log/*.log
pos_file /fluentd/log/fluentd-rke-logging.pos
time_format %Y-%m-%dT%H:%M:%S
tag rke.*
format json
read_from_head true
</source>
<filter rke.**>
@type record_transformer
enable_ruby true
<record>
tag ${tag}
log_type k8s_infrastructure_container
driver rke
component ${tag_suffix[6].split("_")[0]}
container_id ${tag_suffix[6].split(".")[0]}
</record>
</filter>
<source>
@type tail
path /var/log/containers/*.log
pos_file /fluentd/log/fluentd-cluster-logging.pos
time_format %Y-%m-%dT%H:%M:%S
tag cluster.*
format json
read_from_head true
</source>
<filter cluster.**>
@type kubernetes_metadata
merge_json_log true
preserve_json_log true
</filter>
<filter cluster.**>
@type record_transformer
<record>
tag ${tag}
log_type k8s_normal_container
{{range $k, $val := .clusterTarget.OutputTags -}}
{{$k}} {{$val}}
{{end -}}
</record>
</filter>
<match cluster.** rke.** cluster-custom.**>
{{ if eq .clusterTarget.CurrentTarget "embedded"}}
@type elasticsearch
include_tag_key true
hosts "elasticsearch.cattle-logging:9200"
reload_connections "true"
logstash_prefix {{.clusterTarget.EmbeddedConfig.IndexPrefix}}
logstash_format true
logstash_dateformat {{.clusterTarget.WrapEmbedded.DateFormat}}
type_name "container_log"
{{end -}}
{{ if eq .clusterTarget.CurrentTarget "elasticsearch"}}
@type elasticsearch
include_tag_key true
{{ if and .clusterTarget.ElasticsearchConfig.AuthUserName .clusterTarget.ElasticsearchConfig.AuthPassword}}
hosts {{.clusterTarget.WrapElasticsearch.Scheme}}://{{.clusterTarget.ElasticsearchConfig.AuthUserName}}:{{.clusterTarget.ElasticsearchConfig.AuthPassword}}@{{.clusterTarget.WrapElasticsearch.Host}}
{{else -}}
hosts {{.clusterTarget.ElasticsearchConfig.Endpoint}}
{{end -}}
reload_connections "true"
logstash_format true
logstash_prefix "{{.clusterTarget.ElasticsearchConfig.IndexPrefix}}"
logstash_dateformat {{.clusterTarget.WrapElasticsearch.DateFormat}}
ssl_verify {{.clusterTarget.ElasticsearchConfig.SSLVerify}}
type_name "container_log"
{{end -}}
{{ if eq .clusterTarget.CurrentTarget "splunk"}}
@type splunk-http-eventcollector
server {{.clusterTarget.WrapSplunk.Server}}
all_items true
protocol {{.clusterTarget.WrapSplunk.Scheme}}
verify {{.clusterTarget.SplunkConfig.SSLVerify}}
sourcetype {{.clusterTarget.SplunkConfig.Source}}
token {{.clusterTarget.SplunkConfig.Token}}
format json
reload_connections "true"
{{end -}}
{{ if eq .clusterTarget.CurrentTarget "kafka"}}
@type kafka_buffered
{{ if .clusterTarget.KafkaConfig.ZookeeperEndpoint }}
zookeeper {{.clusterTarget.WrapKafka.Zookeeper}}
{{else}}
brokers {{.clusterTarget.WrapKafka.Brokers}}
{{end}}
default_topic {{.clusterTarget.KafkaConfig.Topic}}
output_data_type "json"
output_include_tag true
output_include_time true
# get_kafka_client_log true
max_send_retries 3
{{end -}}
{{ if eq .clusterTarget.CurrentTarget "syslog"}}
@type remote_syslog
host {{.clusterTarget.WrapSyslog.Host}}
port {{.clusterTarget.WrapSyslog.Port}}
severity {{.clusterTarget.SyslogConfig.Severity}}
program {{.clusterTarget.SyslogConfig.Program}}
protocol {{.clusterTarget.SyslogConfig.Protocol}}
{{end -}}
flush_interval {{.clusterTarget.OutputFlushInterval}}s
buffer_type file
buffer_path /fluentd/etc/buffer/cluster.buffer
buffer_queue_limit 128
buffer_chunk_limit 256m
max_retry_wait 30
disable_retry_limit
num_threads 8
slow_flush_log_threshold 40.0
</match>
{{end -}}
`