acquisition

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CAT_MODE = "cat"
View Source
var JOURNALD_CMD = "journalctl"
View Source
var JOURNALD_DEFAULT_CAT_ARGS = []string{}
View Source
var JOURNALD_DEFAULT_TAIL_ARGS = []string{"--follow"}
View Source
var ReaderHits = prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "cs_reader_hits_total",
		Help: "Total lines where read.",
	},
	[]string{"source"},
)
View Source
var TAIL_MODE = "tail"

Functions

func StartAcquisition added in v1.0.0

func StartAcquisition(sources []DataSource, output chan types.Event, AcquisTomb *tomb.Tomb) error

Types

type DataSource added in v1.0.0

type DataSource interface {
	Configure(DataSourceCfg) error
	/*the readers must watch the tomb (especially in tail mode) to know when to shutdown.
	tomb is as well used to trigger general shutdown when a datasource errors */
	StartReading(chan types.Event, *tomb.Tomb) error
	Mode() string //return CAT_MODE or TAIL_MODE

}

func DataSourceConfigure added in v1.0.0

func DataSourceConfigure(config DataSourceCfg) (DataSource, error)

func LoadAcquisitionFromFile added in v1.0.0

func LoadAcquisitionFromFile(config *csconfig.CrowdsecServiceCfg) ([]DataSource, error)

type DataSourceCfg added in v1.0.0

type DataSourceCfg struct {
	Mode              string            `yaml:"mode,omitempty"` //tail|cat|...
	Filename          string            `yaml:"filename,omitempty"`
	Filenames         []string          `yaml:"filenames,omitempty"`
	JournalctlFilters []string          `yaml:"journalctl_filter,omitempty"`
	Labels            map[string]string `yaml:"labels,omitempty"`
	Profiling         bool              `yaml:"profiling,omitempty"`
}

type FileSource added in v1.0.0

type FileSource struct {
	Config DataSourceCfg

	Files []string
	// contains filtered or unexported fields
}

func (*FileSource) CatOneFile added in v1.0.0

func (f *FileSource) CatOneFile(output chan types.Event, AcquisTomb *tomb.Tomb, idx int) error

A one shot file reader (cat)

func (*FileSource) Configure added in v1.0.0

func (f *FileSource) Configure(Config DataSourceCfg) error

func (*FileSource) Mode added in v1.0.0

func (f *FileSource) Mode() string

func (*FileSource) StartCat added in v1.0.0

func (f *FileSource) StartCat(output chan types.Event, AcquisTomb *tomb.Tomb) error

A one shot file reader (cat)

func (*FileSource) StartReading added in v1.0.0

func (f *FileSource) StartReading(out chan types.Event, t *tomb.Tomb) error

func (*FileSource) StartTail added in v1.0.0

func (f *FileSource) StartTail(output chan types.Event, AcquisTomb *tomb.Tomb) error

A tail-mode file reader (tail)

func (*FileSource) TailOneFile added in v1.0.0

func (f *FileSource) TailOneFile(output chan types.Event, AcquisTomb *tomb.Tomb, idx int) error

A tail-mode file reader (tail)

type JournaldSource added in v1.0.0

type JournaldSource struct {
	Config  DataSourceCfg
	Cmd     *exec.Cmd
	Stdout  io.ReadCloser
	Stderr  io.ReadCloser
	Decoder *json.Decoder
	SrcName string
}

func (*JournaldSource) Configure added in v1.0.0

func (j *JournaldSource) Configure(config DataSourceCfg) error

func (*JournaldSource) Mode added in v1.0.0

func (j *JournaldSource) Mode() string

func (*JournaldSource) StartCat added in v1.0.0

func (j *JournaldSource) StartCat(out chan types.Event, t *tomb.Tomb) error

func (*JournaldSource) StartReading added in v1.0.0

func (j *JournaldSource) StartReading(out chan types.Event, t *tomb.Tomb) error

func (*JournaldSource) StartTail added in v1.0.0

func (j *JournaldSource) StartTail(out chan types.Event, t *tomb.Tomb) error

Jump to

Keyboard shortcuts

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