diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index 7cd552db1..49b7de979 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -138,7 +138,7 @@ func NewApp(cfg *config.Config, options ...Option) (*App, error) { var engine *rules.Engine var rs *config.RulesCompileResult - if cfg.Filters.Rules.Enabled && !cfg.ForwardMode && !cfg.IsCaptureSet() { + if cfg.Filters.Rules.Enabled && !cfg.ForwardMode && !cfg.IsCaptureSet() && !cfg.IsFilamentSet() { engine = rules.NewEngine(psnap, cfg) var err error rs, err = engine.Compile() @@ -203,9 +203,8 @@ func (f *App) Run(args []string) error { // In case of a regular run, we additionally set up the aggregator. // The aggregator will grab the events from the queue, assemble them // into batches and hand over to output sinks. - filamentName := cfg.Filament.Name - if filamentName != "" { - f.filament, err = filament.New(filamentName, f.psnap, f.hsnap, cfg) + if cfg.IsFilamentSet() { + f.filament, err = filament.New(cfg.Filament.Name, f.psnap, f.hsnap, cfg) if err != nil { return err } @@ -314,9 +313,9 @@ func (f *App) ReadCapture(ctx context.Context, args []string) error { if err != nil { return err } - filamentName := f.config.Filament.Name - if filamentName != "" { - f.filament, err = filament.New(filamentName, f.psnap, f.hsnap, f.config) + + if f.config.IsFilamentSet() { + f.filament, err = filament.New(f.config.Filament.Name, f.psnap, f.hsnap, f.config) if err != nil { return err } @@ -355,6 +354,7 @@ func (f *App) ReadCapture(ctx context.Context, args []string) error { return err } } + return api.StartServer(f.config) } diff --git a/pkg/config/config_windows.go b/pkg/config/config_windows.go index 3d51cb0c0..f7f6f1817 100644 --- a/pkg/config/config_windows.go +++ b/pkg/config/config_windows.go @@ -310,6 +310,9 @@ func (c *Config) Init() error { // in the capture file. func (c *Config) IsCaptureSet() bool { return c.CapFile != "" } +// IsFilamentSet indicates if the filament is supplied. +func (c *Config) IsFilamentSet() bool { return c.Filament.Name != "" } + // TryLoadFile attempts to load the configuration file from specified path on the file system. func (c *Config) TryLoadFile(file string) error { c.viper.SetConfigFile(file)