-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
54 lines (42 loc) · 1.13 KB
/
config.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
package graylog
import (
"compress/flate"
"errors"
"os"
"time"
"github.com/Graylog2/go-gelf/gelf"
)
// Config stores graylog hook config
type Config struct {
Hostname string
Facility string
StaticMeta map[string]interface{} // static meta always sent to graylog
// default not compress to save cpu power as logs are most likely to send over private network
CompressType gelf.CompressType // default to NoCompression
CompressionLevel int // default to flate.NoCompression
// health check
HealthCheckInterval time.Duration // default to 5 seconds
}
// NodeConfig stores node configuration
type NodeConfig struct {
UDPAddress string
HealthCheckURL string
Weight int
}
// NewConfig returns a default graylog hook config
func NewConfig() Config {
hostname, _ := os.Hostname()
return Config{
Hostname: hostname,
CompressType: gelf.CompressNone,
CompressionLevel: flate.NoCompression,
HealthCheckInterval: time.Second * 5,
}
}
// ValidateConfig validates config
func ValidateConfig(c Config) error {
if c.Hostname == "" {
return errors.New("hostname cannot be empty")
}
return nil
}