autodiscovery

package
v0.0.2-0...-4ce78c8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

README

package autodiscovery

This package is a core piece of the agent. It is responsible for collecting check configurations from different sources (see package config providers) and then schedule or unschedule integration configurations with the help of the schedulers.

It is also responsible for listening to container-related events and resolve template configurations that would match them.

AutoConfig

As a central component, AutoConfig owns and orchestrates several key modules:

  • it owns a reference to a MetaScheduler that dispatches integrations configs for scheduling or unscheduling to all registered schedulers. There are 3 scheduler implementations: checks scheduler and logs scheduler in the agent, and cluster checks dispatcher in the cluster agent.
  • it stores a list of ConfigProviders and poll them according to their poll policy via configPollers
  • it owns ServiceListener used to listen to lifecycle events of containers and other kind of services like network devices, kubernetes Endpoints and Service objects
  • it uses the ConfigResolver that resolves a configuration template to an actual configuration based on a service matching the template. A template matches a service if they have in common at least one AD identifier element
  • it uses a store component to safely store and retrieve all data and mappings needed for the autodiscovery lifecycle

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigErrors

func GetConfigErrors() map[string]string

GetConfigErrors gets the config errors

func GetResolveWarnings

func GetResolveWarnings() map[string][]string

GetResolveWarnings get the resolve warnings/errors

Types

type AutoConfig

type AutoConfig struct {
	// contains filtered or unexported fields
}

AutoConfig is responsible to collect integrations configurations from different sources and then schedule or unschedule them. It owns and orchestrates several key modules:

  • it owns a reference to the `collector.Collector` that it uses to schedule checks when template or container updates warrant them
  • it holds a list of `providers.ConfigProvider`s and poll them according to their policy
  • it holds a list of `check.Loader`s to load configurations into `Check` objects
  • it holds a list of `listeners.ServiceListener`s` used to listen to container lifecycle events
  • it uses the `ConfigResolver` that resolves a configuration template to an actual configuration based on a service matching the template

Notice the `AutoConfig` public API speaks in terms of `integration.Config`, meaning that you cannot use it to schedule integrations instances directly.

func NewAutoConfig

func NewAutoConfig(scheduler *scheduler.MetaScheduler) *AutoConfig

NewAutoConfig creates an AutoConfig instance.

func (*AutoConfig) AddConfigProvider

func (ac *AutoConfig) AddConfigProvider(provider providers.ConfigProvider, shouldPoll bool, pollInterval time.Duration)

AddConfigProvider adds a new configuration provider to AutoConfig. Callers must pass a flag to indicate whether the configuration provider expects to be polled and at which interval or it's fine for it to be invoked only once in the Agent lifetime. If the config provider is polled, the routine is scheduled right away

func (*AutoConfig) AddListeners

func (ac *AutoConfig) AddListeners(listenerConfigs []config.Listeners)

AddListeners tries to initialise the listeners listed in the given configs. A first try is done synchronously. If a listener fails with a ErrWillRetry, the initialization will be re-triggered later until success or ErrPermaFail.

func (*AutoConfig) AddScheduler

func (ac *AutoConfig) AddScheduler(name string, s scheduler.Scheduler, replayConfigs bool)

AddScheduler allows to register a new scheduler to receive configurations. Previously emitted configurations can be replayed with the replayConfigs flag.

func (*AutoConfig) GetAllConfigs

func (ac *AutoConfig) GetAllConfigs() []integration.Config

GetAllConfigs queries all the providers and returns all the integration configurations found, resolving the ones it can

func (*AutoConfig) GetLoadedConfigs

func (ac *AutoConfig) GetLoadedConfigs() map[string]integration.Config

GetLoadedConfigs returns configs loaded

func (*AutoConfig) GetUnresolvedTemplates

func (ac *AutoConfig) GetUnresolvedTemplates() map[string][]integration.Config

GetUnresolvedTemplates returns templates in cache yet to be resolved

func (*AutoConfig) HasRunOnce

func (ac *AutoConfig) HasRunOnce() bool

HasRunOnce returns true if the AutoConfig has ran once.

func (*AutoConfig) LoadAndRun

func (ac *AutoConfig) LoadAndRun()

LoadAndRun loads all of the integration configs it can find and schedules them. Should always be run once so providers that don't need polling will be queried at least once

func (*AutoConfig) RemoveScheduler

func (ac *AutoConfig) RemoveScheduler(name string)

RemoveScheduler allows to remove a scheduler from the AD system.

func (*AutoConfig) Stop

func (ac *AutoConfig) Stop()

Stop just shuts down AutoConfig in a clean way. AutoConfig is not supposed to be restarted, so this is expected to be called only once at program exit.

type TemplateCache

type TemplateCache struct {
	// contains filtered or unexported fields
}

TemplateCache is a data structure to store configuration templates

func NewTemplateCache

func NewTemplateCache() *TemplateCache

NewTemplateCache creates a new cache

func (*TemplateCache) Del

func (cache *TemplateCache) Del(tpl integration.Config) error

Del removes a template from the cache

func (*TemplateCache) Get

func (cache *TemplateCache) Get(adID string) ([]integration.Config, error)

Get retrieves a template from the cache

func (*TemplateCache) GetUnresolvedTemplates

func (cache *TemplateCache) GetUnresolvedTemplates() map[string][]integration.Config

GetUnresolvedTemplates returns templates yet to be resolved

func (*TemplateCache) Set

func (cache *TemplateCache) Set(tpl integration.Config) error

Set stores or updates a template in the cache

Directories

Path Synopsis
common

Jump to

Keyboard shortcuts

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