Documentation ¶
Overview ¶
Package run runs the actual log agent
Index ¶
- func ParseConfigFile(filepath string) (Config, base.LogSchema, ConfigStats, error)
- func Run(configFile string, metricAddress string, allowReload bool)
- type AnchorsConfig
- type CompleteReloadingFunc
- type Config
- type ConfigStats
- type ConfigStatsBuilder
- type InitiateReloadingFunc
- type Loader
- func (loader *Loader) GetConfigStats() ConfigStats
- func (loader *Loader) GetMetricGatherer() prometheus.Gatherer
- func (loader *Loader) GetMetricQuerier() promreg.MetricQuerier
- func (loader *Loader) LaunchInputs(orchestrator base.Orchestrator) ([]string, func())
- func (loader *Loader) RelaunchOrchestrator(ologger logger.Logger) base.Orchestrator
- func (loader *Loader) StartOrchestrator(ologger logger.Logger) base.Orchestrator
- type ReloadableOrchestrator
- type ReloadableSink
- type Reloader
- type SchemaConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseConfigFile ¶
ParseConfigFile loads config from the path, creates the schema and verify all configurations
Types ¶
type AnchorsConfig ¶
type AnchorsConfig struct{}
AnchorsConfig defines the anchors section in config file
The section is meant to host user-defined YAML variables for other sections and doesn't need to be processed itself
func (AnchorsConfig) MarshalYAML ¶
func (holder AnchorsConfig) MarshalYAML() (interface{}, error)
MarshalYAML does nothing
func (*AnchorsConfig) UnmarshalYAML ¶
func (holder *AnchorsConfig) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML does nothing
type CompleteReloadingFunc ¶
type CompleteReloadingFunc func() base.Orchestrator
CompleteReloadingFunc completes the reloading process and launches the new downstream Orchestrator.
The resulting Orchestrator must be used to replace the existing one after this function is called.
type Config ¶
type Config struct { Anchors AnchorsConfig `yaml:"anchors"` Schema SchemaConfig `yaml:"schema"` Inputs []bconfig.LogInputConfigHolder `yaml:"inputs"` Orchestration bconfig.OrchestratorConfigHolder `yaml:"orchestration"` MetricKeys []string `yaml:"metricKeys"` Transformations []bconfig.LogTransformConfigHolder `yaml:"transformations"` OutputBuffersPairs []bconfig.OutputBufferConfig `yaml:"outputBufferPairs"` }
Config defines the root of slog-agent config file
type ConfigStats ¶
type ConfigStats struct { FixedFields []string // Fixed fields are those used by inputs and orchestration that cannot be moved or renamed UnusedFields []string OrchestrationKeys []string }
ConfigStats provides extra stats related to quality of config file
func (ConfigStats) Log ¶
func (stats ConfigStats) Log(parentLogger logger.Logger)
Log logs important information or warnings if there is any
type ConfigStatsBuilder ¶
type ConfigStatsBuilder struct {
// contains filtered or unexported fields
}
ConfigStatsBuilder helps building ConfigStats
func NewConfigStatsBuilder ¶
func NewConfigStatsBuilder(schema *base.LogSchema) *ConfigStatsBuilder
NewConfigStatsBuilder creates a ConfigStatsTracker for the given schema
Hook(s) in the schema will be used for tracking, and as a result a schema must have multiple trackers associated
func (*ConfigStatsBuilder) BeginTrackingFields ¶
func (tracker *ConfigStatsBuilder) BeginTrackingFields()
BeginTrackingFields begins tracking of all fields for their usage
func (*ConfigStatsBuilder) BeginTrackingFixedFields ¶
func (tracker *ConfigStatsBuilder) BeginTrackingFixedFields()
BeginTrackingFixedFields begins tracking of fields that must remain fixed during config reload, not removed or moved
func (*ConfigStatsBuilder) Finish ¶
func (tracker *ConfigStatsBuilder) Finish(confStats *ConfigStats)
Finish ends all tracking and exports results to the given ConfigStats
type InitiateReloadingFunc ¶
type InitiateReloadingFunc func() (CompleteReloadingFunc, error)
InitiateReloadingFunc initiates the reloading process and returns error if it cannot be continued (e.g. error in new config).
No reload would happen and there should be no side effect if the returned CompleteReloadingFunc is not called.
type Loader ¶
type Loader struct { Config ConfigStats ConfigStats PipelineArgs bconfig.PipelineArgs // parameters for to run a pipeline, may be modified in-place // contains filtered or unexported fields }
Loader loads configuration from file and prepares the environments to be launched
Loader should take care of everything derived from the config file, but not trigger anything automatically ¶
Orchstrator and inputs are exposed in place of a simple main loop to allow customization, see Run()
func NewLoaderFromConfigFile ¶
NewLoaderFromConfigFile creates a new Loader from the given config file
func (*Loader) GetConfigStats ¶
func (loader *Loader) GetConfigStats() ConfigStats
GetConfigStats returns ConfigStats
func (*Loader) GetMetricGatherer ¶
func (loader *Loader) GetMetricGatherer() prometheus.Gatherer
GetMetricGatherer returns a metric gatherer containing default metrics and metrics from both input and pipeline(s)
func (*Loader) GetMetricQuerier ¶
func (loader *Loader) GetMetricQuerier() promreg.MetricQuerier
GetMetricQuerier returns a composite querier that can locate both input metrics and pipeline metrics
func (*Loader) LaunchInputs ¶
func (loader *Loader) LaunchInputs(orchestrator base.Orchestrator) ([]string, func())
LaunchInputs starts all inputs in background and returns (list of addresses, shutdown function)
The returned input addresses are final, e.g. assigned random port if it's 0 in config file
The return shutdown function only shuts down the inputs, not the orchestrator
func (*Loader) RelaunchOrchestrator ¶
func (loader *Loader) RelaunchOrchestrator(ologger logger.Logger) base.Orchestrator
RelaunchOrchestrator launches the Orchestrator again for recovery in test runs
func (*Loader) StartOrchestrator ¶
func (loader *Loader) StartOrchestrator(ologger logger.Logger) base.Orchestrator
StartOrchestrator launches an Orchestrator in background and returns it
type ReloadableOrchestrator ¶
type ReloadableOrchestrator struct {
// contains filtered or unexported fields
}
ReloadableOrchestrator supports config reload by re-creating the downstream Orchestrator.
The type is to be paired with Reloader, which provides the function to reload configuration file and create real Orchestrator(s).
func NewReloadableOrchestrator ¶
func NewReloadableOrchestrator(downstream base.Orchestrator, initiateReload InitiateReloadingFunc) *ReloadableOrchestrator
NewReloadableOrchestrator creates a reloadable orchestrator wrapping the given downstream orchestrator
func (*ReloadableOrchestrator) NewSink ¶
func (orc *ReloadableOrchestrator) NewSink(clientAddress string, clientNumber base.ClientNumber) base.BufferReceiverSink
NewSink creates a new reloadable sink for an input source (e.g. incoming TCP connection)
func (*ReloadableOrchestrator) Shutdown ¶
func (orc *ReloadableOrchestrator) Shutdown()
Shutdown shuts down both of the reloadable orchestrator and the current downstream orchestrator
type ReloadableSink ¶
type ReloadableSink struct {
// contains filtered or unexported fields
}
ReloadableSink wraps Orchestrator's BufferReceiverSink to support reloading.
Like BufferReceiverSink, a ReloadableSink runs in individual input goroutines (e.g. TCP connection handler).
func (*ReloadableSink) Accept ¶
func (sink *ReloadableSink) Accept(buffer []*base.LogRecord)
Accept passes buffered logs to the bound downstream sink
func (*ReloadableSink) Close ¶
func (sink *ReloadableSink) Close()
Close closes the bound downstream sink and the reloadable sink itself
func (*ReloadableSink) Tick ¶
func (sink *ReloadableSink) Tick()
Tick calls Tick on the bound downstream sink
type Reloader ¶
type Reloader struct { *Loader // contains filtered or unexported fields }
Reloader overrides Loader to support configuration reloading
It provides the underlying configuration reloading but not responsible to trigger or to use the reloaded setup
func NewReloaderFromConfigFile ¶
NewReloaderFromConfigFile creates a new Reloader with a new Loader from the given config file
func (*Reloader) GetMetricGatherer ¶
func (reloader *Reloader) GetMetricGatherer() prometheus.Gatherer
GetMetricGatherer returns a metric gatherer containing default metrics and metrics from both input and pipeline(s).
Unlike Loader's GetMetricGatherer which returns a composite Gatherer containing current metric factories, Reloader's returns a GathererFunc which always gathers from the latest metric factories, if they've been recreated by reloading.
func (*Reloader) StartOrchestrator ¶
func (reloader *Reloader) StartOrchestrator(ologger logger.Logger) base.Orchestrator
StartOrchestrator launches a reloadable Orchestrator
type SchemaConfig ¶
SchemaConfig defines the schema section in config file