acquisition

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 39 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// We register the datasources at init time so we can tell if they are unsupported, or excluded from the build
	AcquisitionSources = map[string]func() DataSource{}
)

Functions

func GetMetrics added in v1.1.0

func GetMetrics(sources []DataSource, aggregated bool) error

func GetMetricsLevelFromPromCfg added in v1.6.1

func GetMetricsLevelFromPromCfg(prom *csconfig.PrometheusCfg) metrics.AcquisitionMetricsLevel

func StartAcquisition added in v1.0.0

func StartAcquisition(ctx context.Context, sources []DataSource, output chan types.Event, acquisTomb *tomb.Tomb) error

Types

type DSNConfigurer added in v1.7.1

type DSNConfigurer interface {
	// Configure the datasource
	ConfigureByDSN(dsn string, labels map[string]string, logger *log.Entry, uniqueID string) error
}

type DataSource added in v1.0.0

type DataSource interface {
	// identity, lifecycle
	GetMode() string // Get the mode (TAIL, CAT or SERVER)
	GetName() string // Get the name of the module
	GetUuid() string // Get the unique identifier of the datasource
	Dump() any
	CanRun() error // Whether the datasource can run or not (eg, journalctl on BSD is a non-sense)

	// configuration
	UnmarshalConfig(yamlConfig []byte) error                                                            // Decode and pre-validate the YAML datasource - anything that can be checked before runtime
	Configure(yamlConfig []byte, logger *log.Entry, metricsLevel metrics.AcquisitionMetricsLevel) error // Complete the YAML datasource configuration and perform runtime checks.
}

The interface each datasource must implement

func DataSourceConfigure added in v1.0.0

func DataSourceConfigure(commonConfig configuration.DataSourceCommonCfg, yamlConfig []byte, metricsLevel metrics.AcquisitionMetricsLevel) (DataSource, error)

DataSourceConfigure creates and returns a DataSource object from a configuration, if the configuration is not valid it returns an error. If the datasource can't be run (eg. journalctl not available), it still returns an error which can be checked for the appropriate action.

func GetDataSourceIface added in v1.1.0

func GetDataSourceIface(dataSourceType string) (DataSource, error)

func LoadAcquisitionFromDSN added in v1.1.0

func LoadAcquisitionFromDSN(dsn string, labels map[string]string, transformExpr string) ([]DataSource, error)

func LoadAcquisitionFromFiles added in v1.6.10

func LoadAcquisitionFromFiles(config *csconfig.CrowdsecServiceCfg, prom *csconfig.PrometheusCfg) ([]DataSource, error)

LoadAcquisitionFromFiles unmarshals the configuration item and checks its availability

type DataSourceUnavailableError added in v1.5.3

type DataSourceUnavailableError struct {
	Name string
	Err  error
}

func (*DataSourceUnavailableError) Error added in v1.5.3

func (*DataSourceUnavailableError) Unwrap added in v1.5.3

func (e *DataSourceUnavailableError) Unwrap() error

type Fetcher added in v1.7.1

type Fetcher interface {
	// Start one shot acquisition(eg, cat a file)
	OneShotAcquisition(ctx context.Context, out chan types.Event, acquisTomb *tomb.Tomb) error
}

type MetricsProvider added in v1.7.1

type MetricsProvider interface {
	// Returns pointers to metrics that are managed by the module
	GetMetrics() []prometheus.Collector

	// Returns pointers to metrics that are managed by the module (aggregated mode, limits cardinality)
	GetAggregMetrics() []prometheus.Collector
}

type Tailer added in v1.7.1

type Tailer interface {
	// Start live acquisition (eg, tail a file)
	StreamingAcquisition(ctx context.Context, out chan types.Event, acquisTomb *tomb.Tomb) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL