integration

package
v0.0.0-...-438bf1b Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

package integration

This package is responsible of defining the types representing an integration which can be used by several components of the agent to configure checks or logs collectors for example.

Documentation

Overview

Package integration contains the type that represents a configuration.

Index

Constants

View Source
const (
	// FakeConfigHash is used in unit tests
	FakeConfigHash = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvancedADIdentifier

type AdvancedADIdentifier struct {
	KubeService   KubeNamespacedName `yaml:"kube_service,omitempty"`
	KubeEndpoints KubeNamespacedName `yaml:"kube_endpoints,omitempty"`
}

AdvancedADIdentifier contains user-defined autodiscovery information It replaces ADIdentifiers for advanced use-cases. Typically, file-based k8s service and endpoint checks.

type CommonGlobalConfig

type CommonGlobalConfig struct {
	Service string `yaml:"service"`
}

CommonGlobalConfig holds the reserved fields for the yaml init_config data

type CommonInstanceConfig

type CommonInstanceConfig struct {
	MinCollectionInterval int      `yaml:"min_collection_interval"`
	EmptyDefaultHostname  bool     `yaml:"empty_default_hostname"`
	Tags                  []string `yaml:"tags"`
	Service               string   `yaml:"service"`
	Name                  string   `yaml:"name"`
	Namespace             string   `yaml:"namespace"`
	NoIndex               bool     `yaml:"no_index"`
}

CommonInstanceConfig holds the reserved fields for the yaml instance data

type Config

type Config struct {

	// Name of the integration
	Name string `json:"check_name"` // (include in digest: true)

	// Instances is the list of instances in YAML or JSON.
	Instances []Data `json:"instances"` // (include in digest: true)

	// InitConfig is the init_config in YAML or JSON
	InitConfig Data `json:"init_config"` // (include in digest: true)

	// MetricConfig is the metric config in YAML or JSON (jmx check only)
	MetricConfig Data `json:"metric_config"` // (include in digest: false)

	// LogsConfig is the logs config in YAML or JSON (logs-agent only)
	LogsConfig Data `json:"logs"` // (include in digest: true)

	// ADIdentifiers is the list of AutoDiscovery identifiers for this
	// integration.  If either ADIdentifiers or AdvancedADIdentifiers are
	// present, then this config is a template and will be resolved when a
	// matching service is discovered. Otherwise, the config will be scheduled
	// immediately. (optional)
	ADIdentifiers []string `json:"ad_identifiers"` // (include in digest: true)

	// AdvancedADIdentifiers is the list of advanced AutoDiscovery identifiers;
	// see ADIdentifiers.  (optional)
	AdvancedADIdentifiers []AdvancedADIdentifier `json:"advanced_ad_identifiers"` // (include in digest: false)

	// Provider is the name of the config provider that issued the config.  If
	// this is "", then the config is a service config, representing a service
	// discovered by a listener.
	Provider string `json:"provider"` // (include in digest: false)

	// ServiceID is the ID of the service (set only for resolved templates and
	// for service configs)
	ServiceID string `json:"service_id"` // (include in digest: true)

	// TaggerEntity is the tagger entity ID
	TaggerEntity string `json:"-"` // (include in digest: false)

	// ClusterCheck is cluster-check configuration flag
	ClusterCheck bool `json:"cluster_check"` // (include in digest: false)

	// NodeName is node name in case of an endpoint check backed by a pod
	NodeName string `json:"node_name"` // (include in digest: true)

	// Source is the source of the configuration
	Source string `json:"source"` // (include in digest: false)

	// IgnoreAutodiscoveryTags is used to ignore tags coming from autodiscovery
	IgnoreAutodiscoveryTags bool `json:"ignore_autodiscovery_tags"` // (include in digest: true)

	// CheckTagCardinality is used to override the default tag cardinality in the agent configuration
	CheckTagCardinality string `json:"check_tag_cardinality"` // (include in digest: false)

	// MetricsExcluded is whether metrics collection is disabled (set by
	// container listeners only)
	MetricsExcluded bool `json:"metrics_excluded"` // (include in digest: false)

	// LogsExcluded is whether logs collection is disabled (set by container
	// listeners only)
	LogsExcluded bool `json:"logs_excluded"` // (include in digest: false)
}

Config is a generic container for configuration data specific to an integration. It contains snippets of configuration for various agent components, in fields of type Data.

The Data fields contain YAML data except when config.Provider is names.Container or names.Kubernetes, in which case the configuration is in JSON.

func (*Config) AddMetrics

func (c *Config) AddMetrics(metrics Data) error

AddMetrics adds metrics to a check configuration

func (*Config) Digest

func (c *Config) Digest() string

Digest returns an hash value representing the data stored in this configuration. The ClusterCheck field is intentionally left out to keep a stable digest between the cluster-agent and the node-agents

func (*Config) Dump

func (c *Config) Dump(multiline bool) string

Dump returns a string representing this Config value, for debugging purposes. If multiline is true, then it contains newlines; otherwise, it is comma-separated.

func (*Config) Equal

func (c *Config) Equal(cfg *Config) bool

Equal determines whether the passed config is the same

func (*Config) FastDigest

func (c *Config) FastDigest() uint64

FastDigest returns an hash value representing the data stored in this configuration. Difference with Digest is that FastDigest does not consider that difference may appear inside Instances allowing to remove costly YAML Marshal/UnMarshal operations The ClusterCheck field is intentionally left out to keep a stable digest between the cluster-agent and the node-agents

func (*Config) GetTemplateVariablesForInstance

func (c *Config) GetTemplateVariablesForInstance(i int) []tmplvar.TemplateVar

GetTemplateVariablesForInstance returns a slice of raw template variables it found in a config instance template.

func (*Config) HasFilter

func (c *Config) HasFilter(filter containers.FilterType) bool

HasFilter returns true if metrics or logs collection must be disabled for this config.

func (*Config) IntDigest

func (c *Config) IntDigest() uint64

IntDigest returns a hash value representing the data stored in the configuration.

func (*Config) IsCheckConfig

func (c *Config) IsCheckConfig() bool

IsCheckConfig returns true if the config is a node-agent check configuration,

func (*Config) IsLogConfig

func (c *Config) IsLogConfig() bool

IsLogConfig returns true if config contains a logs config.

func (*Config) IsTemplate

func (c *Config) IsTemplate() bool

IsTemplate returns if the config has AD identifiers

func (*Config) ScrubbedString

func (c *Config) ScrubbedString() string

ScrubbedString returns the YAML representation of the config with secrets scrubbed

func (*Config) String

func (c *Config) String() string

String constructs the YAML representation of the config.

type ConfigChanges

type ConfigChanges struct {
	// Schedule contains configs that should be scheduled as a result of
	// this event.
	Schedule []Config

	// Unschedule contains configs that should be unscheduled as a result of
	// this event.
	Unschedule []Config
}

ConfigChanges contains the changes that occurred due to an event in AutoDiscovery.

func (*ConfigChanges) IsEmpty

func (c *ConfigChanges) IsEmpty() bool

IsEmpty determines whether this set of changes is empty

func (*ConfigChanges) Merge

func (c *ConfigChanges) Merge(other ConfigChanges)

Merge merges the given ConfigChanges into this one.

func (*ConfigChanges) ScheduleConfig

func (c *ConfigChanges) ScheduleConfig(config Config)

ScheduleConfig adds a config to `Schedule`

func (*ConfigChanges) UnscheduleConfig

func (c *ConfigChanges) UnscheduleConfig(config Config)

UnscheduleConfig adds a config to `Unschedule`

type ConfigCheckResponse

type ConfigCheckResponse struct {
	Configs         []Config            `json:"configs"`
	ResolveWarnings map[string][]string `json:"resolve_warnings"`
	ConfigErrors    map[string]string   `json:"config_errors"`
	Unresolved      map[string][]Config `json:"unresolved"`
}

ConfigCheckResponse holds the config check response

type Data

type Data []byte

Data contains YAML code

func (*Data) GetNameForInstance

func (c *Data) GetNameForInstance() string

GetNameForInstance returns the name from an instance if specified, fallback on namespace

func (*Data) MergeAdditionalTags

func (c *Data) MergeAdditionalTags(tags []string) error

MergeAdditionalTags merges additional tags to possible existing config tags

func (*Data) SetField

func (c *Data) SetField(key string, value interface{}) error

SetField allows to set an arbitrary field to a given value, overriding the existing value if present

func (*Data) SetNameForInstance

func (c *Data) SetNameForInstance(name string) error

SetNameForInstance set name for instance

type JSONMap

type JSONMap map[string]interface{}

JSONMap is the generic type to hold JSON configurations

type KubeNamespacedName

type KubeNamespacedName struct {
	Name      string `yaml:"name"`
	Namespace string `yaml:"namespace"`
}

KubeNamespacedName identifies a kubernetes object.

func (KubeNamespacedName) IsEmpty

func (k KubeNamespacedName) IsEmpty() bool

IsEmpty returns true if the KubeNamespacedName is empty

type RawMap

type RawMap map[interface{}]interface{}

RawMap is the generic type to hold YAML configurations

Jump to

Keyboard shortcuts

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