-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
loggers.go
353 lines (345 loc) · 19.4 KB
/
loggers.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
package pkgconfig
import (
"reflect"
"github.com/creasty/defaults"
"github.com/prometheus/prometheus/model/relabel"
)
type ConfigLoggers struct {
DevNull struct {
Enable bool `yaml:"enable" default:"false"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"devnull"`
Stdout struct {
Enable bool `yaml:"enable" default:"false"`
Mode string `yaml:"mode" default:"text"`
TextFormat string `yaml:"text-format" default:""`
JinjaFormat string `yaml:"jinja-format" default:""`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"stdout"`
Prometheus struct {
Enable bool `yaml:"enable" default:"false"`
ListenIP string `yaml:"listen-ip" default:"127.0.0.1"`
ListenPort int `yaml:"listen-port" default:"8081"`
TLSSupport bool `yaml:"tls-support" default:"false"`
TLSMutual bool `yaml:"tls-mutual" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
PromPrefix string `yaml:"prometheus-prefix" default:"dnscollector"`
LabelsList []string `yaml:"prometheus-labels" default:"[]"`
TopN int `yaml:"top-n" default:"10"`
BasicAuthLogin string `yaml:"basic-auth-login" default:"admin"`
BasicAuthPwd string `yaml:"basic-auth-pwd" default:"changeme"`
BasicAuthEnabled bool `yaml:"basic-auth-enable" default:"true"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
RequestersMetricsEnabled bool `yaml:"requesters-metrics-enabled" default:"true"`
DomainsMetricsEnabled bool `yaml:"domains-metrics-enabled" default:"true"`
NoErrorMetricsEnabled bool `yaml:"noerror-metrics-enabled" default:"true"`
ServfailMetricsEnabled bool `yaml:"servfail-metrics-enabled" default:"true"`
NonExistentMetricsEnabled bool `yaml:"nonexistent-metrics-enabled" default:"true"`
TimeoutMetricsEnabled bool `yaml:"timeout-metrics-enabled" default:"false"`
HistogramMetricsEnabled bool `yaml:"histogram-metrics-enabled" default:"false"`
RequestersCacheTTL int `yaml:"requesters-cache-ttl" default:"250000"`
RequestersCacheSize int `yaml:"requesters-cache-size" default:"3600"`
DomainsCacheTTL int `yaml:"domains-cache-ttl" default:"500000"`
DomainsCacheSize int `yaml:"domains-cache-size" default:"3600"`
NoErrorDomainsCacheTTL int `yaml:"noerror-domains-cache-ttl" default:"100000"`
NoErrorDomainsCacheSize int `yaml:"noerror-domains-cache-size" default:"3600"`
ServfailDomainsCacheTTL int `yaml:"servfail-domains-cache-ttl" default:"10000"`
ServfailDomainsCacheSize int `yaml:"servfail-domains-cache-size" default:"3600"`
NXDomainsCacheTTL int `yaml:"nonexistent-domains-cache-ttl" default:"10000"`
NXDomainsCacheSize int `yaml:"nonexistent-domains-cache-size" default:"3600"`
DefaultDomainsCacheTTL int `yaml:"default-domains-cache-ttl" default:"1000"`
DefaultDomainsCacheSize int `yaml:"default-domains-cache-size" default:"3600"`
} `yaml:"prometheus"`
RestAPI struct {
Enable bool `yaml:"enable" default:"false"`
ListenIP string `yaml:"listen-ip" default:"127.0.0.1"`
ListenPort int `yaml:"listen-port" default:"8080"`
BasicAuthLogin string `yaml:"basic-auth-login" default:"admin"`
BasicAuthPwd string `yaml:"basic-auth-pwd" default:"changeme"`
TLSSupport bool `yaml:"tls-support" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
TopN int `yaml:"top-n" default:"100"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"restapi"`
LogFile struct {
Enable bool `yaml:"enable" default:"false"`
FilePath string `yaml:"file-path" default:""`
MaxSize int `yaml:"max-size" default:"100"`
MaxFiles int `yaml:"max-files" default:"10"`
MaxBatchSize int `yaml:"max-batch-size" default:"65536"`
FlushInterval int `yaml:"flush-interval" default:"1"`
Compress bool `yaml:"compress" default:"false"`
Mode string `yaml:"mode" default:"text"`
PostRotateCommand string `yaml:"postrotate-command" default:""`
PostRotateDelete bool `yaml:"postrotate-delete-success" default:"false"`
TextFormat string `yaml:"text-format" default:""`
JinjaFormat string `yaml:"jinja-format" default:""`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
ExtendedSupport bool `yaml:"extended-support" default:"false"`
} `yaml:"logfile"`
DNSTap struct {
Enable bool `yaml:"enable" default:"false"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1"`
RemotePort int `yaml:"remote-port" default:"6000"`
Transport string `yaml:"transport" default:"tcp"`
SockPath string `yaml:"sock-path" default:""`
ConnectTimeout int `yaml:"connect-timeout" default:"5"`
RetryInterval int `yaml:"retry-interval" default:"10"`
FlushInterval int `yaml:"flush-interval" default:"30"`
TLSSupport bool `yaml:"tls-support" default:"false"`
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
ServerID string `yaml:"server-id" default:""`
OverwriteIdentity bool `yaml:"overwrite-identity" default:"false"`
BufferSize int `yaml:"buffer-size" default:"100"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
ExtendedSupport bool `yaml:"extended-support" default:"false"`
Compression string `yaml:"compression" default:"none"`
} `yaml:"dnstapclient"`
TCPClient struct {
Enable bool `yaml:"enable" default:"false"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1"`
RemotePort int `yaml:"remote-port" default:"9999"`
SockPath string `yaml:"sock-path" default:""` // deprecated
RetryInterval int `yaml:"retry-interval" default:"10"`
Transport string `yaml:"transport" default:"tcp"`
TLSSupport bool `yaml:"tls-support" default:"false"` // deprecated
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
Mode string `yaml:"mode" default:"flat-json"`
TextFormat string `yaml:"text-format" default:""`
PayloadDelimiter string `yaml:"delimiter" default:"\n"`
BufferSize int `yaml:"buffer-size" default:"100"`
FlushInterval int `yaml:"flush-interval" default:"30"`
ConnectTimeout int `yaml:"connect-timeout" default:"5"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"tcpclient"`
Syslog struct {
Enable bool `yaml:"enable" default:"false"`
Severity string `yaml:"severity" default:"INFO"`
Facility string `yaml:"facility" default:"DAEMON"`
Transport string `yaml:"transport" default:"local"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1:514"`
RetryInterval int `yaml:"retry-interval" default:"10"`
TextFormat string `yaml:"text-format" default:""`
Mode string `yaml:"mode" default:"text"`
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
Formatter string `yaml:"formatter" default:"rfc5424"`
Framer string `yaml:"framer" default:""`
Hostname string `yaml:"hostname" default:""`
AppName string `yaml:"app-name" default:"DNScollector"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
Tag string `yaml:"tag" default:""`
ReplaceNullChar string `yaml:"replace-null-char" default:"�"`
FlushInterval int `yaml:"flush-interval" default:"30"`
BufferSize int `yaml:"buffer-size" default:"100"`
} `yaml:"syslog"`
Fluentd struct {
Enable bool `yaml:"enable" default:"false"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1"`
RemotePort int `yaml:"remote-port" default:"24224"`
SockPath string `yaml:"sock-path" default:""` // deprecated
ConnectTimeout int `yaml:"connect-timeout" default:"5"`
RetryInterval int `yaml:"retry-interval" default:"10"`
FlushInterval int `yaml:"flush-interval" default:"30"`
Transport string `yaml:"transport" default:"tcp"`
TLSSupport bool `yaml:"tls-support" default:"false"` // deprecated
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
Tag string `yaml:"tag" default:"dns.collector"`
BufferSize int `yaml:"buffer-size" default:"100"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"4096"`
} `yaml:"fluentd"`
InfluxDB struct {
Enable bool `yaml:"enable" default:"false"`
ServerURL string `yaml:"server-url" default:"http://localhost:8086"`
AuthToken string `yaml:"auth-token" default:""`
TLSSupport bool `yaml:"tls-support" default:"false"`
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
Bucket string `yaml:"bucket" default:""`
Organization string `yaml:"organization" default:""`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"influxdb"`
LokiClient struct {
Enable bool `yaml:"enable" default:"false"`
ServerURL string `yaml:"server-url" default:"http://localhost:3100/loki/api/v1/push"`
JobName string `yaml:"job-name" default:"dnscollector"`
Mode string `yaml:"mode" default:"text"`
FlushInterval int `yaml:"flush-interval" default:"5"`
BatchSize int `yaml:"batch-size" default:"1048576"`
RetryInterval int `yaml:"retry-interval" default:"10"`
TextFormat string `yaml:"text-format" default:""`
ProxyURL string `yaml:"proxy-url" default:""`
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
BasicAuthLogin string `yaml:"basic-auth-login" default:""`
BasicAuthPwd string `yaml:"basic-auth-pwd" default:""`
BasicAuthPwdFile string `yaml:"basic-auth-pwd-file" default:""`
TenantID string `yaml:"tenant-id" default:""`
RelabelConfigs []*relabel.Config `yaml:"relabel-configs" default:"[]"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"lokiclient"`
Statsd struct {
Enable bool `yaml:"enable" default:"false"`
Prefix string `yaml:"prefix" default:"dnscollector"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1"`
RemotePort int `yaml:"remote-port" default:"8125"`
ConnectTimeout int `yaml:"connect-timeout" default:"5"`
Transport string `yaml:"transport" default:"udp"`
FlushInterval int `yaml:"flush-interval" default:"10"`
CertFile string `yaml:"cert-file" default:""`
TLSSupport bool `yaml:"tls-support" default:"false"` // deprecated
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
KeyFile string `yaml:"key-file" default:""`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"statsd"`
ElasticSearchClient struct {
Enable bool `yaml:"enable" default:"false"`
Index string `yaml:"index" default:"dnscollector"`
Server string `yaml:"server" default:"http://127.0.0.1:9200/"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
BulkSize int `yaml:"bulk-size" default:"5242880"`
BulkChannelSize int `yaml:"bulk-channel-size" default:"10"`
FlushInterval int `yaml:"flush-interval" default:"10"`
Compression string `yaml:"compression" default:"none"`
BasicAuthEnabled bool `yaml:"basic-auth-enable" default:"false"`
BasicAuthLogin string `yaml:"basic-auth-login" default:""`
BasicAuthPwd string `yaml:"basic-auth-pwd" default:""`
} `yaml:"elasticsearch"`
OpenTelemetryClient struct {
Enable bool `yaml:"enable" default:"false"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
CleanupSpansInterval int `yaml:"cleanup-spans-interval" default:"30"`
MaxSpanTime int `yaml:"max-span-time" default:"120"`
OtelEndpoint string `yaml:"otel-endpoint" default:""`
} `yaml:"opentelemetry"`
ScalyrClient struct {
Enable bool `yaml:"enable" default:"false"`
Mode string `yaml:"mode" default:"text"`
TextFormat string `yaml:"text-format" default:""`
SessionInfo map[string]string `yaml:"sessioninfo" default:"{}"`
Attrs map[string]interface{} `yaml:"attrs" default:"{}"`
ServerURL string `yaml:"server-url" default:"app.scalyr.com"`
APIKey string `yaml:"apikey" default:""`
Parser string `yaml:"parser" default:""`
FlushInterval int `yaml:"flush-interval" default:"10"`
ProxyURL string `yaml:"proxy-url" default:""`
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"scalyrclient"`
RedisPub struct {
Enable bool `yaml:"enable" default:"false"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1"`
RemotePort int `yaml:"remote-port" default:"6379"`
SockPath string `yaml:"sock-path" default:""` // deprecated
RetryInterval int `yaml:"retry-interval" default:"10"`
Transport string `yaml:"transport" default:"tcp"`
TLSSupport bool `yaml:"tls-support" default:"false"` // deprecated
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
Mode string `yaml:"mode" default:"flat-json"`
TextFormat string `yaml:"text-format" default:""`
PayloadDelimiter string `yaml:"delimiter" default:"\n"`
BufferSize int `yaml:"buffer-size" default:"100"`
FlushInterval int `yaml:"flush-interval" default:"30"`
ConnectTimeout int `yaml:"connect-timeout" default:"5"`
RedisChannel string `yaml:"redis-channel" default:"dns_collector"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"redispub"`
KafkaProducer struct {
Enable bool `yaml:"enable" default:"false"`
RemoteAddress string `yaml:"remote-address" default:"127.0.0.1"`
RemotePort int `yaml:"remote-port" default:"9092"`
RetryInterval int `yaml:"retry-interval" default:"10"`
TLSSupport bool `yaml:"tls-support" default:"false"`
TLSInsecure bool `yaml:"tls-insecure" default:"false"`
TLSMinVersion string `yaml:"tls-min-version" default:"1.2"`
CAFile string `yaml:"ca-file" default:""`
CertFile string `yaml:"cert-file" default:""`
KeyFile string `yaml:"key-file" default:""`
SaslSupport bool `yaml:"sasl-support" default:"false"`
SaslUsername string `yaml:"sasl-username" default:""`
SaslPassword string `yaml:"sasl-password" default:""`
SaslMechanism string `yaml:"sasl-mechanism" default:"PLAIN"`
Mode string `yaml:"mode" default:"flat-json"`
TextFormat string `yaml:"text-format" default:""`
BufferSize int `yaml:"buffer-size" default:"100"`
FlushInterval int `yaml:"flush-interval" default:"10"`
ConnectTimeout int `yaml:"connect-timeout" default:"5"`
Topic string `yaml:"topic" default:"dnscollector"`
Partition *int `yaml:"partition" default:"nil"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
Compression string `yaml:"compression" default:"none"`
} `yaml:"kafkaproducer"`
FalcoClient struct {
Enable bool `yaml:"enable" default:"false"`
URL string `yaml:"url" default:"http://127.0.0.1:9200"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"falco"`
ClickhouseClient struct {
Enable bool `yaml:"enable" default:"false"`
URL string `yaml:"url" default:"http://localhost:8123"`
User string `yaml:"user" default:"default"`
Password string `yaml:"password" default:"password"`
Database string `yaml:"database" default:"dnscollector"`
Table string `yaml:"table" default:"records"`
ChannelBufferSize int `yaml:"chan-buffer-size" default:"0"`
} `yaml:"clickhouse"`
}
func (c *ConfigLoggers) SetDefault() {
defaults.Set(c)
}
func (c *ConfigLoggers) IsValid(userCfg map[string]interface{}) error {
return CheckConfigWithTags(reflect.ValueOf(*c), userCfg)
}
func (c *ConfigLoggers) GetNames() (ret []string) {
cl := reflect.TypeOf(*c)
for i := 0; i < cl.NumField(); i++ {
field := cl.Field(i)
tag := field.Tag.Get("yaml")
ret = append(ret, tag)
}
return ret
}
func (c *ConfigLoggers) IsExists(name string) bool {
tags := c.GetNames()
for i := range tags {
if name == tags[i] {
return true
}
}
return false
}