forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster_template.go
106 lines (95 loc) · 3.15 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
package generator
var ClusterTemplate = `{{ if ne .clusterTarget.CurrentTarget "none" }}
<source>
@type tail
path /var/log/containers/*.log
pos_file /fluentd/etc/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}
{{range $k, $val := .clusterTarget.OutputTags -}}
{{$k}} {{$val}}
{{end -}}
</record>
</filter>
<match cluster.**>
{{ if eq .clusterTarget.CurrentTarget "embedded"}}
@type elasticsearch
include_tag_key true
hosts "elasticsearch.cattle-logging:9200"
reload_connections "true"
logstash_prefix {{.clusterTarget.ClusterName}}
logstash_format true
logstash_dateformat {{.clusterTarget.WrapEmbedded.DateFormat}}
type_name "container_log"
reload_connections false
{{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_prefix "{{.clusterTarget.ElasticsearchConfig.IndexPrefix}}"
logstash_format true
logstash_dateformat {{.clusterTarget.WrapElasticsearch.DateFormat}}
type_name "container_log"
reload_connections false
{{end -}}
{{ if eq .clusterTarget.CurrentTarget "splunk"}}
@type splunk-http-eventcollector
server {{.clusterTarget.WrapSplunk.Server}}
all_items true
protocol {{.clusterTarget.WrapSplunk.Scheme}}
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}}
{{end -}}
flush_interval 2s
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 -}}
`