Documentation
¶
Overview ¶
Package config handles loading and validation of the main configuration file.
Index ¶
- Constants
- func IsNetworkOutput(t OutputType) bool
- type BufferMode
- type ClientTLSConfig
- type ConcurrencyConfig
- type Config
- type EventType
- type FileInputConfig
- type FileOutputConfig
- type FunctionsConfig
- type GeoIPConfig
- type HTTPOutputConfig
- type InputBase
- type InputConfig
- type InputType
- type KafkaAuthConfig
- type KafkaInputConfig
- type KafkaOutputConfig
- type KafkaSASLConfig
- type LoggingConfig
- type LoggingLevel
- type LoggingType
- type MetricsConfig
- type OutputBase
- type OutputConfig
- type OutputType
- type RiskConfig
- type RiskDecayType
- type RiskDefaults
- type RiskThresholds
- type RulesConfig
- type SASLMechanism
- type ScopesConfig
- type SocketInputConfig
- type SocketOutputConfig
- type StartPosition
- type StateConfig
- type TLSConfig
- type ThrottleConfig
- type ThrottleMode
Constants ¶
View Source
const ( ThrottleBackpressure = "backpressure" ThrottleDiscard = "discard" )
View Source
const DefaultShutdownTimeout = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
func IsNetworkOutput ¶
func IsNetworkOutput(t OutputType) bool
Types ¶
type BufferMode ¶
type BufferMode string
const ( BufferBlock BufferMode = "block" BufferDrop BufferMode = "drop" )
type ClientTLSConfig ¶
type ClientTLSConfig struct {
Enabled bool `yaml:"enabled" json:"enabled,omitempty"`
SkipVerify bool `yaml:"skip_verify" json:"skip_verify,omitempty"`
CertFile string `yaml:"cert_file" json:"cert_file,omitempty"`
KeyFile string `yaml:"key_file" json:"key_file,omitempty"`
CAFile string `yaml:"ca_file" json:"ca_file,omitempty"`
}
type ConcurrencyConfig ¶
type ConcurrencyConfig struct {
ParseWorkers *int `yaml:"parse_workers" json:"parse_workers,omitempty"`
MatchWorkers *int `yaml:"match_workers" json:"match_workers,omitempty"`
ExtMatchWorkers *int `yaml:"extended_match_workers" json:"extended_match_workers,omitempty"`
// CompositeWorkers shards composite evaluation by rule and group key.
CompositeWorkers *int `yaml:"composite_workers" json:"composite_workers,omitempty"`
}
type Config ¶
type Config struct {
Input InputConfig `yaml:"input" json:"input"`
Outputs []OutputConfig `yaml:"outputs" json:"outputs" validate:"required"`
Rules RulesConfig `yaml:"rules" json:"rules"`
Functions FunctionsConfig `yaml:"functions" json:"functions,omitzero"`
Scopes ScopesConfig `yaml:"scopes" json:"scopes,omitzero"`
Logging LoggingConfig `yaml:"logging" json:"logging"`
Metrics MetricsConfig `yaml:"metrics" json:"metrics,omitzero"`
Concurrency ConcurrencyConfig `yaml:"concurrency" json:"concurrency,omitzero"`
State StateConfig `yaml:"state" json:"state,omitzero"`
GeoIP GeoIPConfig `yaml:"geoip" json:"geoip,omitzero"`
Risk *RiskConfig `yaml:"risk" json:"risk,omitempty"`
ShutdownTimeout time.Duration `yaml:"shutdown_timeout" json:"shutdown_timeout,omitempty" validate:"gte=0"`
}
func LoadConfig ¶
func (Config) MarshalJSON ¶
type FileInputConfig ¶
type FileOutputConfig ¶
type FunctionsConfig ¶
type FunctionsConfig struct {
Directory string `yaml:"directory" json:"directory,omitempty"`
}
type GeoIPConfig ¶
type GeoIPConfig struct {
Path string `yaml:"path" json:"path,omitempty"`
}
type HTTPOutputConfig ¶
type HTTPOutputConfig struct {
URI string `yaml:"uri" json:"uri" validate:"required"`
Method string `yaml:"method" json:"method,omitempty"`
Headers map[string]string `yaml:"headers" json:"-"`
Timeout time.Duration `yaml:"timeout" json:"timeout,omitempty"`
TLS *ClientTLSConfig `yaml:"tls" json:"tls,omitempty"`
}
func (HTTPOutputConfig) MarshalJSON ¶
func (h HTTPOutputConfig) MarshalJSON() ([]byte, error)
type InputBase ¶
type InputBase struct {
Type InputType `yaml:"type"`
Throttle ThrottleConfig `yaml:"throttle"`
StartPosition StartPosition `yaml:"start_position"`
}
type InputConfig ¶
type InputConfig struct {
Type InputType `yaml:"type" json:"type" validate:"required,oneof=file kafka socket"`
Throttle ThrottleConfig `json:"throttle,omitzero"`
StartPosition StartPosition `json:"start_position,omitempty" validate:"omitempty,oneof=resume beginning end"`
File *FileInputConfig `json:"file,omitempty"`
Kafka *KafkaInputConfig `json:"kafka,omitempty"`
Socket *SocketInputConfig `json:"socket,omitempty"`
}
func (*InputConfig) UnmarshalYAML ¶
func (i *InputConfig) UnmarshalYAML(data []byte) error
type KafkaAuthConfig ¶
type KafkaAuthConfig struct {
SASL *KafkaSASLConfig `yaml:"sasl" json:"sasl,omitempty"`
}
type KafkaInputConfig ¶
type KafkaInputConfig struct {
Brokers []string `yaml:"brokers" json:"brokers" validate:"required"`
Topic string `yaml:"topic" json:"topic" validate:"required"`
ConsumerGroup string `yaml:"consumer_group" json:"consumer_group" validate:"required"`
TLS *ClientTLSConfig `yaml:"tls" json:"tls,omitempty"`
Auth *KafkaAuthConfig `yaml:"auth" json:"auth,omitempty"`
RawKafkaVersion string `yaml:"kafka_version" json:"kafka_version" validate:"required"`
KafkaVersion sarama.KafkaVersion `yaml:"-" json:"-"`
}
type KafkaOutputConfig ¶
type KafkaOutputConfig struct {
Brokers []string `yaml:"brokers" json:"brokers" validate:"required"`
Topic string `yaml:"topic" json:"topic" validate:"required"`
TLS *ClientTLSConfig `yaml:"tls" json:"tls,omitempty"`
Auth *KafkaAuthConfig `yaml:"auth" json:"auth,omitempty"`
RawKafkaVersion string `yaml:"kafka_version" json:"kafka_version" validate:"required"`
KafkaVersion sarama.KafkaVersion `yaml:"-" json:"-"`
}
type KafkaSASLConfig ¶
type KafkaSASLConfig struct {
Mechanism SASLMechanism `yaml:"mechanism" json:"mechanism" validate:"required,oneof=PLAIN SCRAM-SHA-256 SCRAM-SHA-512"`
Username string `yaml:"username" json:"username" validate:"required"`
Password string `yaml:"password" json:"-" validate:"required"`
}
type LoggingConfig ¶
type LoggingConfig struct {
Type LoggingType `yaml:"type" json:"type" validate:"omitempty,oneof=file stdout"`
Level LoggingLevel `yaml:"level" json:"level" validate:"omitempty,oneof=debug info warn error"`
Path string `yaml:"path" json:"path,omitempty" validate:"required_if=Type file"`
Writer io.Writer `yaml:"-" json:"-"`
}
type LoggingLevel ¶
type LoggingLevel string
const ( LoggingDebug LoggingLevel = "debug" LoggingInfo LoggingLevel = "info" LoggingWarn LoggingLevel = "warn" LoggingError LoggingLevel = "error" LoggingDisabled LoggingLevel = "disabled" )
type LoggingType ¶
type LoggingType string
const ( LoggingFile LoggingType = "file" LoggingStdout LoggingType = "stdout" )
type MetricsConfig ¶
type MetricsConfig struct {
Port int `yaml:"port" json:"port,omitempty"`
}
type OutputBase ¶
type OutputBase struct {
Type OutputType `yaml:"type"`
Indent bool `yaml:"indent"`
Events []EventType `yaml:"events"`
BufferSize *int `yaml:"buffer_size,omitempty"`
BufferMode BufferMode `yaml:"buffer_mode,omitempty"`
AllowStartupFailure bool `yaml:"allow_startup_failure,omitempty"`
}
type OutputConfig ¶
type OutputConfig struct {
Type OutputType `json:"type"`
Indent bool `json:"indent,omitempty"`
Events []EventType `json:"events,omitempty"`
BufferSize *int `json:"buffer_size,omitempty"`
BufferMode BufferMode `json:"buffer_mode,omitempty"`
AllowStartupFailure bool `json:"allow_startup_failure,omitempty"`
Kafka *KafkaOutputConfig `json:"kafka,omitempty"`
File *FileOutputConfig `json:"file,omitempty"`
HTTP *HTTPOutputConfig `json:"http,omitempty"`
Socket *SocketOutputConfig `json:"socket,omitempty"`
}
func (*OutputConfig) Accepts ¶
func (o *OutputConfig) Accepts(et EventType) bool
func (*OutputConfig) EffectiveBufferMode ¶
func (o *OutputConfig) EffectiveBufferMode() BufferMode
func (*OutputConfig) EffectiveBufferSize ¶
func (o *OutputConfig) EffectiveBufferSize() int
func (*OutputConfig) UnmarshalYAML ¶
func (o *OutputConfig) UnmarshalYAML(data []byte) error
type OutputType ¶
type OutputType string
const ( OutputStdout OutputType = "stdout" OutputKafka OutputType = "kafka" OutputFile OutputType = "file" OutputHTTP OutputType = "http" OutputSocket OutputType = "socket" OutputTest OutputType = "test" )
type RiskConfig ¶
type RiskConfig struct {
Alerts *bool `yaml:"alerts" json:"alerts,omitempty"`
Thresholds map[string]RiskThresholds `yaml:"thresholds" json:"thresholds,omitempty"`
Defaults RiskDefaults `yaml:"defaults" json:"defaults,omitzero"`
}
func (*RiskConfig) AlertsEnabled ¶
func (r *RiskConfig) AlertsEnabled() bool
func (*RiskConfig) Enabled ¶
func (r *RiskConfig) Enabled() bool
type RiskDecayType ¶
type RiskDecayType string
const ( RiskDecayNone RiskDecayType = "none" RiskDecayLinear RiskDecayType = "linear" )
type RiskDefaults ¶
type RiskDefaults struct {
TTL time.Duration `yaml:"ttl" json:"ttl,omitempty"`
Decay RiskDecayType `yaml:"decay" json:"decay,omitempty" validate:"omitempty,oneof=none linear"`
}
func (RiskDefaults) MarshalJSON ¶
func (r RiskDefaults) MarshalJSON() ([]byte, error)
type RiskThresholds ¶
type RiskThresholds struct {
Low float64 `yaml:"low" json:"low,omitempty"`
Medium float64 `yaml:"medium" json:"medium,omitempty"`
High float64 `yaml:"high" json:"high,omitempty"`
Critical float64 `yaml:"critical" json:"critical,omitempty"`
AlertLevel string `yaml:"alert_level" json:"alert_level,omitempty" validate:"omitempty,oneof=low medium high critical"`
}
type RulesConfig ¶
type RulesConfig struct {
Directory string `yaml:"directory" json:"directory,omitempty" validate:"required"`
}
type SASLMechanism ¶
type SASLMechanism string
const ( SASLPlain SASLMechanism = "PLAIN" SASLSCRAMSHA256 SASLMechanism = "SCRAM-SHA-256" SASLSCRAMSHA512 SASLMechanism = "SCRAM-SHA-512" )
type ScopesConfig ¶
type ScopesConfig struct {
Directory string `yaml:"directory" json:"directory,omitempty"`
}
type SocketInputConfig ¶
type SocketInputConfig struct {
Mode string `yaml:"mode" json:"mode" validate:"required,oneof=tcp unix"`
Address string `yaml:"address" json:"address,omitempty" validate:"required_if=Mode tcp"`
Path string `yaml:"path" json:"path,omitempty" validate:"required_if=Mode unix"`
MaxConnections int `yaml:"max_connections" json:"max_connections,omitempty"`
MaxLineLength int `yaml:"max_line_length" json:"max_line_length,omitempty"`
TLS *TLSConfig `yaml:"tls" json:"tls,omitempty"`
}
type SocketOutputConfig ¶
type SocketOutputConfig struct {
Mode string `yaml:"mode" json:"mode" validate:"required,oneof=tcp unix"`
Address string `yaml:"address" json:"address,omitempty" validate:"required_if=Mode tcp"`
Path string `yaml:"path" json:"path,omitempty" validate:"required_if=Mode unix"`
TLS *ClientTLSConfig `yaml:"tls" json:"tls,omitempty"`
}
type StartPosition ¶
type StartPosition string
const ( StartResume StartPosition = "resume" StartBeginning StartPosition = "beginning" StartEnd StartPosition = "end" )
type StateConfig ¶
type StateConfig struct {
Directory string `yaml:"directory" json:"directory,omitempty"`
// FlushInterval bounds how much state a crash can lose (default 1s).
FlushInterval time.Duration `yaml:"flush_interval" json:"flush_interval,omitempty" validate:"gte=0"`
InMemory bool `yaml:"-" json:"-"`
}
func (StateConfig) IsZero ¶
func (s StateConfig) IsZero() bool
func (StateConfig) MarshalJSON ¶
func (s StateConfig) MarshalJSON() ([]byte, error)
type ThrottleConfig ¶
type ThrottleConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Mode ThrottleMode `yaml:"mode" json:"mode,omitempty" validate:"required_if=Enabled true,omitempty,oneof=backpressure discard"`
MaxEvents int `yaml:"max_events" json:"max_events,omitempty" validate:"required_if=Enabled true"`
Period time.Duration `yaml:"period" json:"period,omitempty" validate:"required_if=Enabled true"`
BufferSize int `yaml:"buffer_size" json:"buffer_size,omitempty" validate:"required_if=Enabled true"`
}
func (ThrottleConfig) MarshalJSON ¶
func (t ThrottleConfig) MarshalJSON() ([]byte, error)
type ThrottleMode ¶
type ThrottleMode string
Click to show internal directories.
Click to hide internal directories.