Documentation ¶
Index ¶
- Variables
- func ChangeDefaultCfgfileFlag(beatName string) error
- func GetPathConfig() string
- func HandleFlags() error
- func IsTestConfig() bool
- func Load(path string) (*common.Config, error)
- func LoadList(file string) ([]*common.Config, error)
- func Read(out interface{}, path string) errordeprecated
- type CfgFile
- type DynamicConfig
- type GlobManager
- type GlobWatcher
- type Registry
- type Reload
- type Reloader
- type Runner
- type RunnerFactory
Constants ¶
This section is empty.
Variables ¶
var ( DefaultDynamicConfig = DynamicConfig{ Reload: Reload{ Period: 10 * time.Second, Enabled: false, }, } )
Functions ¶
func ChangeDefaultCfgfileFlag ¶
ChangeDefaultCfgfileFlag replaces the value and default value for the `-c` flag so that it reflects the beat name.
func GetPathConfig ¶
func GetPathConfig() string
GetPathConfig returns ${path.config}. If ${path.config} is not set, ${path.home} is returned.
func HandleFlags ¶
func HandleFlags() error
HandleFlags adapts default config settings based on command line flags.
func IsTestConfig ¶
func IsTestConfig() bool
IsTestConfig returns whether or not this is configuration used for testing
func Load ¶
Load reads the configuration from a YAML file structure. If path is empty this method reads from the configuration file specified by the '-c' command line flag.
Types ¶
type DynamicConfig ¶
type DynamicConfig struct { // If path is a relative path, it is relative to the ${path.config} Path string `config:"path"` Reload Reload `config:"reload"` }
DynamicConfig loads config files from a given path, allowing to reload new changes while running the beat
type GlobManager ¶
type GlobManager struct {
// contains filtered or unexported fields
}
GlobManager allows to manage a directory of conf files. Using a glob pattern to match them, this object will allow to switch their state between enabled and disabled
func NewGlobManager ¶
func NewGlobManager(glob, enabledExtension, disabledExtension string) (*GlobManager, error)
NewGlobManager takes a glob and enabled/disabled extensions and returns a GlobManager object. Parameters:
- glob - matching conf files (ie: modules.d/*.yml)
- enabledExtension - extension for enabled confs, must match the glob (ie: .yml)
- disabledExtension - extension to append for disabled confs (ie: .disabled)
func (*GlobManager) Disable ¶
func (g *GlobManager) Disable(name string) error
Disable given conf file, does nothing if it's disabled already
func (*GlobManager) Enable ¶
func (g *GlobManager) Enable(name string) error
Enable given conf file, does nothing if it's enabled already
func (*GlobManager) Enabled ¶
func (g *GlobManager) Enabled(name string) bool
Enabled returns true if given conf file is enabled
func (*GlobManager) Exists ¶
func (g *GlobManager) Exists(name string) bool
Exists return true if the given conf exists (enabled or disabled)
func (*GlobManager) ListDisabled ¶
func (g *GlobManager) ListDisabled() []*CfgFile
ListDisabled conf files
func (*GlobManager) ListEnabled ¶
func (g *GlobManager) ListEnabled() []*CfgFile
ListEnabled conf files
type GlobWatcher ¶
type GlobWatcher struct {
// contains filtered or unexported fields
}
func NewGlobWatcher ¶
func NewGlobWatcher(glob string) *GlobWatcher
func (*GlobWatcher) Scan ¶
func (gw *GlobWatcher) Scan() ([]string, bool, error)
Scan scans all files matched by the glob and checks if the number of files or the modtime of the files changed It returns the list of files, a boolean if anything in the glob changed and potential errors. To detect changes not only mod time is compared but also the hash of the files list. This is required to also detect files which were removed. The modtime is compared based on second as normally mod-time is in seconds. If it is unclear if something changed the method will return true for the changes. It is strongly recommend to call scan not more frequent then 1s.
type Registry ¶
Registry holds a list of Runners mapped by their unique hashes
func (*Registry) Get ¶ added in v6.1.0
Get returns the Runner with the given hash, or nil if it doesn't exist
type Reloader ¶
type Reloader struct {
// contains filtered or unexported fields
}
Reloader is used to register and reload modules
func NewReloader ¶
NewReloader creates new Reloader instance for the given config
func (*Reloader) Check ¶
func (rl *Reloader) Check(runnerFactory RunnerFactory) error
Check configs are valid (only if reload is disabled)