metadata

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, Apache-2.0 Imports: 14 Imported by: 0

README

package metadata

This package is responsible to provide metadata in the right form to be directly sent to the backend. Metadata collection is iterated during Agent execution at different time intervals for different use cases.

Providers

Single metadata providers are defined in the form of insulated sub packages exposing a public method like:

func GetPayload() *Payload

along with their specific Payload definition. Payload formats can be different, that's why metadata providers are not implemented as interfaces. These components should be loosely coupled with the rest of the Agent, this way they can be used as independent go packages in different projects and different environments.

Collectors

Collectors are used by the Agent and are supposed to be run periodically. They are responsible to invoke the relevant Provider, collect all the info needed, fill the appropriate payload and send it to the specific endpoint in the intake. Collectors are allowed to be strongly coupled to the rest of the Agent components because they're not supposed to be used elsewhere. Collectors can be user configurable, except for the host metadata collector that is always scheduled with a default interval.

Notice: For the time being, several providers collect a piece of information that is used in the v5 package to compose a single metadata payload compatible with the one from Agent v.5. This way we can send metadata through the current backend endpoints (see HostCollector and ResourcesCollector), waiting for the new ones to be deployed. At that point, all the subpackages will be required to define a payload with either the new Protobuf format or a custom JSON compatible with the v2 intake API.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// AllDefaultCollectors the names of all the available default collectors
	AllDefaultCollectors = []string{}
)

Functions

func RegisterCollector

func RegisterCollector(name string, metadataCollector Collector)

RegisterCollector adds a Metadata Collector to the catalog

func SetupInventories

SetupInventories registers the inventories collector into the Scheduler and, if configured, schedules it

func SetupInventoriesExpvar

func SetupInventoriesExpvar(ac inventories.AutoConfigInterface, coll inventories.CollectorInterface)

SetupInventoriesExpvar init the expvar function for inventories

func SetupMetadataCollection

func SetupMetadataCollection(sch *Scheduler, additionalCollectors []string) error

SetupMetadataCollection initializes the metadata scheduler and its collectors based on the config. This function also starts the default collectors listed in 'additionalCollectors' if they're not listed in the configuration.

Types

type Collector

type Collector interface {
	Send(s *serializer.Serializer) error
}

Collector is anything capable to collect and send metadata payloads through the forwarder. A Metadata Collector normally uses a Metadata Provider to fill the payload.

type CollectorWithInit

type CollectorWithInit interface {
	Init() error
}

CollectorWithInit is an optional interface that collectors that need to be initialized can implement. If implemented, the Init method will be called when the collector is scheduled

type HostCollector

type HostCollector struct{}

HostCollector fills and sends the old metadata payload used in the Agent v5

func (*HostCollector) Send

Send collects the data needed and submits the payload

type Payload

type Payload interface {
	Reset()
	String() string
	ProtoMessage()
	Descriptor() ([]byte, []int)
}

Payload is an interface shared by the output of the newer metadata providers. Right now this interface simply satisfies the Protobuf interface.

type ResourcesCollector

type ResourcesCollector struct{}

ResourcesCollector sends the old metadata payload used in the Agent v5

func (*ResourcesCollector) Send

Send collects the data needed and submits the payload

type Scheduler

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

Scheduler takes care of sending metadata at specific time intervals

func NewScheduler

func NewScheduler(s *serializer.Serializer) *Scheduler

NewScheduler builds and returns a new Metadata Scheduler

func (*Scheduler) AddCollector

func (c *Scheduler) AddCollector(name string, interval time.Duration) error

AddCollector schedules a Metadata Collector at the given interval

func (*Scheduler) IsScheduled

func (c *Scheduler) IsScheduled(name string) bool

IsScheduled returns wether a given Collector has been added to this Scheduler

func (*Scheduler) Stop

func (c *Scheduler) Stop()

Stop scheduling collectors

func (*Scheduler) TriggerAndResetCollectorTimer

func (c *Scheduler) TriggerAndResetCollectorTimer(name string, delay time.Duration)

TriggerAndResetCollectorTimer runs a collector manually, on demand. The delay parameter can be set to 0 to run it immediately, or to a duration after which the collector will run. The runs at regular intervals of the collector will be resumed *after* this manual run. Calling TriggerAndResetCollectorTimer on a stopped Scheduler does nothing, since the goroutine that waits on the Timer will not be running.

Directories

Path Synopsis
Package ecs provides functionalities to collect ECS metadata
Package ecs provides functionalities to collect ECS metadata
Package externalhost implements the External Host Tags metadata provider.
Package externalhost implements the External Host Tags metadata provider.

Jump to

Keyboard shortcuts

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