Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/logs/global.go
4094 views
1
package logs
2
3
import (
4
"reflect"
5
"time"
6
7
"github.com/grafana/loki/clients/pkg/promtail/client"
8
"github.com/grafana/loki/clients/pkg/promtail/targets/file"
9
)
10
11
// DefaultGlobalConfig holds default global settings to be used across all instances.
12
var DefaultGlobalConfig = GlobalConfig{
13
ClientConfigs: []client.Config{},
14
FileWatch: file.WatchConfig{
15
MinPollFrequency: 250 * time.Millisecond,
16
MaxPollFrequency: 250 * time.Millisecond,
17
},
18
}
19
20
// GlobalConfig holds global settings that apply to all instances by default.
21
type GlobalConfig struct {
22
FileWatch file.WatchConfig `yaml:"file_watch_config,omitempty"`
23
ClientConfigs []client.Config `yaml:"clients,omitempty"`
24
}
25
26
// UnmarshalYAML implements yaml.Unmarshaler.
27
func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
28
*c = DefaultGlobalConfig
29
30
type plain GlobalConfig
31
return unmarshal((*plain)(c))
32
}
33
34
func (c GlobalConfig) IsZero() bool {
35
return reflect.DeepEqual(c, GlobalConfig{}) || reflect.DeepEqual(c, DefaultGlobalConfig)
36
}
37
38