Пример #1
0
// config reads the configuration file from disk, parses the common options
// defined in BeatConfig, initializes logging, and set GOMAXPROCS if defined
// in the config. Lastly it invokes the Config method implemented by the beat.
func (bc *instance) config() error {
	var err error
	bc.data.RawConfig, err = cfgfile.Load("")
	if err != nil {
		return fmt.Errorf("error loading config file: %v", err)
	}

	err = bc.data.RawConfig.Unpack(&bc.data.Config)
	if err != nil {
		return fmt.Errorf("error unpacking config data: %v", err)
	}

	err = paths.InitPaths(&bc.data.Config.Path)
	if err != nil {
		return fmt.Errorf("error setting default paths: %v", err)
	}

	err = logp.Init(bc.data.Name, &bc.data.Config.Logging)
	if err != nil {
		return fmt.Errorf("error initializing logging: %v", err)
	}
	// Disable stderr logging if requested by cmdline flag
	logp.SetStderr()

	// log paths values to help with troubleshooting
	logp.Info(paths.Paths.String())

	bc.data.filters, err = filter.New(bc.data.Config.Filters)
	if err != nil {
		return fmt.Errorf("error initializing filters: %v", err)
	}
	debugf("Filters: %+v", bc.data.filters)

	if bc.data.Config.Shipper.MaxProcs != nil {
		maxProcs := *bc.data.Config.Shipper.MaxProcs
		if maxProcs > 0 {
			runtime.GOMAXPROCS(maxProcs)
		}
	}

	return bc.beater.Config(bc.data)

	// TODO: If -configtest is set it should exit at this point. But changing
	// this now would mean a change in behavior. Some Beats may depend on the
	// Setup() method being invoked in order to do configuration validation.
	// If we do not change this, it means -configtest requires the outputs to
	// be available because the publisher is being started (this is not
	// desirable - elastic/beats#1213). It (may?) also cause the index template
	// to be loaded.
}
Пример #2
0
// config reads the configuration file from disk, parses the common options
// defined in BeatConfig, initializes logging, and set GOMAXPROCS if defined
// in the config. Lastly it invokes the Config method implemented by the beat.
func (bc *instance) config() error {
	var err error
	bc.data.RawConfig, err = cfgfile.Load("")
	if err != nil {
		return fmt.Errorf("error loading config file: %v", err)
	}

	err = bc.data.RawConfig.Unpack(&bc.data.Config)
	if err != nil {
		return fmt.Errorf("error unpacking config data: %v", err)
	}

	err = paths.InitPaths(&bc.data.Config.Path)
	if err != nil {
		return fmt.Errorf("error setting default paths: %v", err)
	}

	err = logp.Init(bc.data.Name, &bc.data.Config.Logging)
	if err != nil {
		return fmt.Errorf("error initializing logging: %v", err)
	}
	// Disable stderr logging if requested by cmdline flag
	logp.SetStderr()

	// log paths values to help with troubleshooting
	logp.Info(paths.Paths.String())

	bc.data.filters, err = filter.New(bc.data.Config.Filters)
	if err != nil {
		return fmt.Errorf("error initializing filters: %v", err)
	}
	debugf("Filters: %+v", bc.data.filters)

	if bc.data.Config.Shipper.MaxProcs != nil {
		maxProcs := *bc.data.Config.Shipper.MaxProcs
		if maxProcs > 0 {
			runtime.GOMAXPROCS(maxProcs)
		}
	}

	return bc.beater.Config(bc.data)
}
Пример #3
0
// config reads the configuration file from disk, parses the common options
// defined in BeatConfig, initializes logging, and set GOMAXPROCS if defined
// in the config. Lastly it invokes the Config method implemented by the beat.
func (b *Beat) configure() error {
	var err error

	cfg, err := cfgfile.Load("")
	if err != nil {
		return fmt.Errorf("error loading config file: %v", err)
	}

	b.RawConfig = cfg
	err = cfg.Unpack(&b.Config)
	if err != nil {
		return fmt.Errorf("error unpacking config data: %v", err)
	}

	err = paths.InitPaths(&b.Config.Path)
	if err != nil {
		return fmt.Errorf("error setting default paths: %v", err)
	}

	err = logp.Init(b.Name, &b.Config.Logging)
	if err != nil {
		return fmt.Errorf("error initializing logging: %v", err)
	}
	// Disable stderr logging if requested by cmdline flag
	logp.SetStderr()

	// log paths values to help with troubleshooting
	logp.Info(paths.Paths.String())

	if b.Config.Shipper.MaxProcs != nil {
		maxProcs := *b.Config.Shipper.MaxProcs
		if maxProcs > 0 {
			runtime.GOMAXPROCS(maxProcs)
		}
	}

	return nil
}