forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_template.go
107 lines (97 loc) · 2.83 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
package generator
var ProjectTemplate = `{{range $i, $store := .projectTargets -}}
<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>
{{ if $store.CurrentTarget }}
<match {{$store.ProjectName}}.** project-custom.{{$store.ProjectName}}.**>
{{ if eq $store.CurrentTarget "elasticsearch"}}
@type elasticsearch
include_tag_key true
hosts {{$store.ElasticsearchConfig.Endpoint}}
reload_connections "true"
logstash_prefix "{{$store.ElasticsearchConfig.IndexPrefix}}"
logstash_format true
logstash_dateformat {{$store.WrapElasticsearch.DateFormat}}
type_name "container_log"
{{end -}}
{{ if eq $store.CurrentTarget "splunk"}}
@type splunk-http-eventcollector
server {{$store.WrapSplunk.Server}}
all_items true
protocol {{$store.WrapSplunk.Scheme}}
verify false
sourcetype {{$store.SplunkConfig.Source}}
format json
token {{$store.SplunkConfig.Token}}
reload_connections "true"
{{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
{{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}}
flush_interval {{$store.OutputFlushInterval}}s
max_retry_wait 30
disable_retry_limit
num_threads 8
buffer_type file
buffer_path /fluentd/etc/buffer/project.{{$store.ProjectName}}.buffer
buffer_queue_limit 128
buffer_chunk_limit 256m
slow_flush_log_threshold 40.0
</match>
{{end -}}
{{end -}}
`