config

package
v0.0.0-...-68d2f45 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Tag used to unmarshal the config.
	// We need to use the "yaml" tag instead of the default "koanf" tag because
	// the config embeds the blackbox module config which uses YAML.
	Tag                   = "yaml"
	EnvGloutonConfigFiles = "GLOUTON_CONFIG_FILES"
)

Variables

View Source
var (
	ErrInvalidValue = errors.New("invalid config value")
)

Functions

func CensorSecretItem

func CensorSecretItem(key string, value interface{}) interface{}

CensorSecretItem returns the censored item value with secrets and password removed for safe external use.

func DefaultPaths

func DefaultPaths() []string

DefaultPaths returns the default paths used to search for config files.

func Dump

func Dump(config Config) map[string]interface{}

Dump return a copy of the whole configuration, with secrets retracted. secret is any key containing "key", "secret", "password" or "passwd".

func Load

func Load(withDefault bool, loadEnviron bool, paths ...string) (Config, []Item, prometheus.MultiError, error)

Load the configuration from files and environment variables. It returns the config, the loaded items, warnings and an error.

func ParseBool

func ParseBool(value string) (bool, error)

ParseBool works like strconv.ParseBool but also supports "yes" and "no".

Types

type Agent

type Agent struct {
	CloudImageCreationFile string          `yaml:"cloudimage_creation_file"`
	InstallationFormat     string          `yaml:"installation_format"`
	FactsFile              string          `yaml:"facts_file"`
	NetstatFile            string          `yaml:"netstat_file"`
	StateFile              string          `yaml:"state_file"`
	StateCacheFile         string          `yaml:"state_cache_file"`
	StateResetFile         string          `yaml:"state_reset_file"`
	DeprecatedStateFile    string          `yaml:"deprecated_state_file"`
	StateDirectory         string          `yaml:"state_directory"`
	EnableCrashReporting   bool            `yaml:"enable_crash_reporting"`
	MaxCrashReportsCount   int             `yaml:"max_crash_reports_count"`
	UpgradeFile            string          `yaml:"upgrade_file"`
	AutoUpgradeFile        string          `yaml:"auto_upgrade_file"`
	ProcessExporter        ProcessExporter `yaml:"process_exporter"`
	PublicIPIndicator      string          `yaml:"public_ip_indicator"`
	NodeExporter           NodeExporter    `yaml:"node_exporter"`
	WindowsExporter        NodeExporter    `yaml:"windows_exporter"`
	Telemetry              Telemetry       `yaml:"telemetry"`
}

type Blackbox

type Blackbox struct {
	Enable          bool                     `yaml:"enable"`
	ScraperName     string                   `yaml:"scraper_name"`
	ScraperSendUUID bool                     `yaml:"scraper_send_uuid"`
	UserAgent       string                   `yaml:"user_agent"`
	Targets         []BlackboxTarget         `yaml:"targets"`
	Modules         map[string]bbConf.Module `yaml:"modules"`
}

type BlackboxTarget

type BlackboxTarget struct {
	Name   string `yaml:"name"`
	URL    string `yaml:"url"`
	Module string `yaml:"module"`
}

type Bleemeo

type Bleemeo struct {
	AccountID                         string       `yaml:"account_id"`
	APIBase                           string       `yaml:"api_base"`
	APISSLInsecure                    bool         `yaml:"api_ssl_insecure"`
	Cache                             BleemeoCache `yaml:"cache"`
	ContainerRegistrationDelaySeconds int          `yaml:"container_registration_delay_seconds"`
	Enable                            bool         `yaml:"enable"`
	InitialAgentName                  string       `yaml:"initial_agent_name"`
	InitialServerGroupName            string       `yaml:"initial_server_group_name"`
	InitialServerGroupNameForSNMP     string       `yaml:"initial_server_group_name_for_snmp"`
	InitialServerGroupNameForVSphere  string       `yaml:"initial_server_group_name_for_vsphere"`
	MQTT                              BleemeoMQTT  `yaml:"mqtt"`
	RegistrationKey                   string       `yaml:"registration_key"`
	Sentry                            Sentry       `yaml:"sentry"`
}

type BleemeoCache

type BleemeoCache struct {
	DeactivatedMetricsExpirationDays int `yaml:"deactivated_metrics_expiration_days"`
}

type BleemeoMQTT

type BleemeoMQTT struct {
	CAFile      string `yaml:"cafile"`
	Host        string `yaml:"host"`
	Port        int    `yaml:"port"`
	SSLInsecure bool   `yaml:"ssl_insecure"`
	SSL         bool   `yaml:"ssl"`
}

type Config

type Config struct {
	Agent                          Agent                `yaml:"agent"`
	Blackbox                       Blackbox             `yaml:"blackbox"`
	Bleemeo                        Bleemeo              `yaml:"bleemeo"`
	Container                      Container            `yaml:"container"`
	DF                             DF                   `yaml:"df"`
	DiskIgnore                     []string             `yaml:"disk_ignore"`
	DiskMonitor                    []string             `yaml:"disk_monitor"`
	IPMI                           IPMI                 `yaml:"ipmi"`
	JMX                            JMX                  `yaml:"jmx"`
	JMXTrans                       JMXTrans             `yaml:"jmxtrans"`
	Kubernetes                     Kubernetes           `yaml:"kubernetes"`
	Log                            Log                  `yaml:"log"`
	Logging                        Logging              `yaml:"logging"`
	Mdstat                         Mdstat               `yaml:"mdstat"`
	Metric                         Metric               `yaml:"metric"`
	MQTT                           OpenSourceMQTT       `yaml:"mqtt"`
	NetworkInterfaceDenylist       []string             `yaml:"network_interface_denylist"`
	NRPE                           NRPE                 `yaml:"nrpe"`
	NvidiaSMI                      NvidiaSMI            `yaml:"nvidia_smi"`
	Services                       []Service            `yaml:"service"`
	ServiceAbsentDeactivationDelay time.Duration        `yaml:"service_absent_deactivation_delay"`
	ServiceIgnore                  []NameInstance       `yaml:"service_ignore"`
	ServiceIgnoreMetrics           []NameInstance       `yaml:"service_ignore_metrics"`
	ServiceIgnoreCheck             []NameInstance       `yaml:"service_ignore_check"`
	Smart                          Smart                `yaml:"smart"`
	Tags                           []string             `yaml:"tags"`
	Telegraf                       Telegraf             `yaml:"telegraf"`
	Thresholds                     map[string]Threshold `yaml:"thresholds"`
	VSphere                        []VSphere            `yaml:"vsphere"`
	Web                            Web                  `yaml:"web"`
	Zabbix                         Zabbix               `yaml:"zabbix"`
}

Config is the structured configuration of the agent.

func DefaultConfig

func DefaultConfig() Config

type Container

type Container struct {
	Filter           ContainerFilter  `yaml:"filter"`
	Type             string           `yaml:"type"`
	PIDNamespaceHost bool             `yaml:"pid_namespace_host"`
	Runtime          ContainerRuntime `yaml:"runtime"`
}

type ContainerFilter

type ContainerFilter struct {
	AllowByDefault bool     `yaml:"allow_by_default"`
	AllowList      []string `yaml:"allow_list"`
	DenyList       []string `yaml:"deny_list"`
}

type ContainerRuntime

type ContainerRuntime struct {
	Docker     ContainerRuntimeAddresses `yaml:"docker"`
	ContainerD ContainerRuntimeAddresses `yaml:"containerd"`
}

type ContainerRuntimeAddresses

type ContainerRuntimeAddresses struct {
	Addresses      []string `yaml:"addresses"`
	PrefixHostRoot bool     `yaml:"prefix_hostroot"`
}

type DF

type DF struct {
	HostMountPoint string   `yaml:"host_mount_point"`
	PathIgnore     []string `yaml:"path_ignore"`
	IgnoreFSType   []string `yaml:"ignore_fs_type"`
}

type DFFSTypeMatcher

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

func NewDFFSTypeMatcher

func NewDFFSTypeMatcher(config Config) (DFFSTypeMatcher, error)

func (DFFSTypeMatcher) AsDenyRegexp

func (f DFFSTypeMatcher) AsDenyRegexp() string

func (DFFSTypeMatcher) Match

func (f DFFSTypeMatcher) Match(fsType string) bool

type DFPathMatcher

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

func NewDFPathMatcher

func NewDFPathMatcher(config Config) DFPathMatcher

func (DFPathMatcher) Match

func (f DFPathMatcher) Match(path string) bool

type DiskIOMatcher

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

func NewDiskIOMatcher

func NewDiskIOMatcher(config Config) (DiskIOMatcher, error)

func (DiskIOMatcher) AsDenyRegexp

func (f DiskIOMatcher) AsDenyRegexp() string

AsDenyRegexp return a regexp as string that should be used as denylist: any value that match this regexp should be ignored. If the denylist is empty, this regexp won't correspond to Match() method.

func (DiskIOMatcher) Match

func (f DiskIOMatcher) Match(disk string) bool

type IPMI

type IPMI struct {
	Enable           bool   `yaml:"enable"`
	BinarySearchPath string `yaml:"bin_search_path"`
	UseSudo          bool   `yaml:"use_sudo"`
	Timeout          int    `yaml:"timeout"`
}

type Item

type Item struct {
	// The config Key (e.g. "bleemeo.enable").
	Key string
	// The Value for this config key.
	Value interface{}
	// Type of the value.
	Type ItemType
	// Source of the config key (can be a default value, an environment variable or a file).
	Source ItemSource
	// Path to the file the item comes (empty when it doesn't come from a file).
	Path string
	// Priority of the item.
	// When two items have the same key, the one with the highest Priority is kept.
	// When the value is a map or an array, the items may have the same Priority, in
	// this case the arrays are appended to each other, and the maps are merged.
	Priority int
}

Item represents a single config key from a provider.

type ItemSource

type ItemSource int

ItemSource represents the ItemSource of an item.

const (
	SourceDefault ItemSource = iota
	SourceEnv
	SourceFile
)

type ItemType

type ItemType int

ItemType represents the type of an item value.

const (
	TypeAny ItemType = iota
	TypeInt
	TypeFloat
	TypeBool
	TypeString
	TypeListString
	TypeListInt
	TypeMapStrStr
	TypeMapStrInt
	TypeThresholds
	TypeServices
	TypeNameInstances
	TypeBlackboxTargets
	TypePrometheusTargets
	TypeSNMPTargets
	TypeLogInputs
)

type JMX

type JMX struct {
	Enable bool `yaml:"enable"`
}

type JMXTrans

type JMXTrans struct {
	ConfigFile     string `yaml:"config_file"`
	FilePermission string `yaml:"file_permission"`
	GraphitePort   int    `yaml:"graphite_port"`
}

type JmxMetric

type JmxMetric struct {
	Name      string   `yaml:"name"`
	MBean     string   `yaml:"mbean"`
	Attribute string   `yaml:"attribute"`
	Path      string   `yaml:"path"`
	Scale     float64  `yaml:"scale"`
	Derive    bool     `yaml:"derive"`
	Sum       bool     `yaml:"sum"`
	TypeNames []string `yaml:"type_names"`
	Ratio     string   `yaml:"ratio"`
}

type Kubernetes

type Kubernetes struct {
	Enable              bool   `yaml:"enable"`
	AllowClusterMetrics bool   `yaml:"allow_cluster_metrics"`
	NodeName            string `yaml:"nodename"`
	ClusterName         string `yaml:"clustername"`
	KubeConfig          string `yaml:"kubeconfig"`
}

type Listener

type Listener struct {
	Address string `yaml:"address"`
	Port    int    `yaml:"port"`
}

type LocalUI

type LocalUI struct {
	Enable bool `yaml:"enable"`
}

type Log

type Log struct {
	FluentBitURL   string     `yaml:"fluentbit_url"`
	HostRootPrefix string     `yaml:"hostroot_prefix"`
	Inputs         []LogInput `yaml:"inputs"`
}

type LogFilter

type LogFilter struct {
	Metric string `yaml:"metric"`
	Regex  string `yaml:"regex"`
}

type LogInput

type LogInput struct {
	Path          string            `yaml:"path"`
	ContainerName string            `yaml:"container_name"`
	Selectors     map[string]string `yaml:"container_selectors"`
	Filters       []LogFilter       `yaml:"filters"`
}

type Logging

type Logging struct {
	Buffer        LoggingBuffer `yaml:"buffer"`
	Level         string        `yaml:"level"`
	Output        string        `yaml:"output"`
	FileName      string        `yaml:"filename"`
	PackageLevels string        `yaml:"package_levels"`
}

type LoggingBuffer

type LoggingBuffer struct {
	HeadSizeBytes int `yaml:"head_size_bytes"`
	TailSizeBytes int `yaml:"tail_size_bytes"`
}

type Mdstat

type Mdstat struct {
	Enable    bool   `yaml:"enable"`
	PathMdadm string `yaml:"path_mdadm"`
	UseSudo   bool   `yaml:"use_sudo"`
}

type Metric

type Metric struct {
	AllowMetrics            []string       `yaml:"allow_metrics"`
	DenyMetrics             []string       `yaml:"deny_metrics"`
	IncludeDefaultMetrics   bool           `yaml:"include_default_metrics"`
	Prometheus              Prometheus     `yaml:"prometheus"`
	SoftStatusPeriodDefault int            `yaml:"softstatus_period_default"`
	SoftStatusPeriod        map[string]int `yaml:"softstatus_period"`
	SNMP                    SNMP           `yaml:"snmp"`
}

type NRPE

type NRPE struct {
	Enable    bool     `yaml:"enable"`
	Address   string   `yaml:"address"`
	Port      int      `yaml:"port"`
	SSL       bool     `yaml:"ssl"`
	ConfPaths []string `yaml:"conf_paths"`
}

type NameInstance

type NameInstance struct {
	Name     string `yaml:"name"`
	Instance string `yaml:"instance"`
}

type NetworkInterfaceMatcher

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

func NewNetworkInterfaceMatcher

func NewNetworkInterfaceMatcher(config Config) NetworkInterfaceMatcher

func (NetworkInterfaceMatcher) AsDenyRegexp

func (f NetworkInterfaceMatcher) AsDenyRegexp() string

func (NetworkInterfaceMatcher) Match

func (f NetworkInterfaceMatcher) Match(netif string) bool

type NodeExporter

type NodeExporter struct {
	Enable     bool     `yaml:"enable"`
	Collectors []string `yaml:"collectors"`
}

type NvidiaSMI

type NvidiaSMI struct {
	Enable  bool   `yaml:"enable"`
	BinPath string `yaml:"bin_path"`
	Timeout int    `yaml:"timeout"`
}

type OpenSourceMQTT

type OpenSourceMQTT struct {
	Enable      bool     `yaml:"enable"`
	Username    string   `yaml:"username"`
	Password    string   `yaml:"password"`
	CAFile      string   `yaml:"ca_file"`
	Hosts       []string `yaml:"hosts"`
	Port        int      `yaml:"port"`
	SSLInsecure bool     `yaml:"ssl_insecure"`
	SSL         bool     `yaml:"ssl"`
}

type ProcessExporter

type ProcessExporter struct {
	Enable bool `yaml:"enable"`
}

type Prometheus

type Prometheus struct {
	Targets []PrometheusTarget `yaml:"targets"`
}

type PrometheusTarget

type PrometheusTarget struct {
	URL          string   `yaml:"url"`
	Name         string   `yaml:"name"`
	AllowMetrics []string `yaml:"allow_metrics"`
	DenyMetrics  []string `yaml:"deny_metrics"`
}

type SNMP

type SNMP struct {
	ExporterAddress string       `yaml:"exporter_address"`
	Targets         []SNMPTarget `yaml:"targets"`
}

type SNMPTarget

type SNMPTarget struct {
	InitialName string `yaml:"initial_name"`
	Target      string `yaml:"target"`
}

type Sentry

type Sentry struct {
	DSN string `yaml:"dsn"`
}

type Service

type Service struct {
	// The name of the service type, like "apache", "nginx". For custom service, it could be any value.
	Type string `yaml:"type"`
	// Instance of the service, used to differentiate between two same services (like two apaches)
	Instance string `yaml:"instance"`
	// The port the service is running on.
	Port int `yaml:"port"`
	// Ports that should be ignored.
	IgnorePorts []int `yaml:"ignore_ports"`
	// The address of the service.
	Address string `yaml:"address"`
	// Tags associated with this service.
	Tags []string `yaml:"tags"`
	// The delay between two consecutive checks in seconds.
	Interval int `yaml:"interval"`
	// Check type used for custom checks.
	CheckType string `yaml:"check_type"`
	// The path used for HTTP checks.
	HTTPPath string `yaml:"http_path"`
	// The expected status code for HTTP checks.
	HTTPStatusCode int `yaml:"http_status_code"`
	// Host header sent with HTTP checks.
	HTTPHost string `yaml:"http_host"`
	// Regex to match in a process check.
	MatchProcess string `yaml:"match_process"`
	// Command used for a Nagios check.
	CheckCommand   string `yaml:"check_command"`
	NagiosNRPEName string `yaml:"nagios_nrpe_name"`
	// Unix socket to connect and gather metric from MySQL.
	MetricsUnixSocket string `yaml:"metrics_unix_socket"`
	// Credentials for services that require authentication.
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	// URL used to retrieve metrics (used for instance by HAProxy and PHP-FMP).
	StatsURL string `yaml:"stats_url"`
	// Port used to get statistics for a service.
	StatsPort int `yaml:"stats_port"`
	// Protocol used to get statistics (TCP, HTTP).
	StatsProtocol string `yaml:"stats_protocol"`
	// Detailed monitoring of specific items (Cassandra tables, Postgres databases or Kafka topics).
	DetailedItems []string `yaml:"detailed_items"`
	// JMX services.
	JMXPort     int         `yaml:"jmx_port"`
	JMXUsername string      `yaml:"jmx_username"`
	JMXPassword string      `yaml:"jmx_password"`
	JMXMetrics  []JmxMetric `yaml:"jmx_metrics"`
	// TLS config.
	SSL         bool   `yaml:"ssl"`
	SSLInsecure bool   `yaml:"ssl_insecure"`
	StartTLS    bool   `yaml:"starttls"`
	CAFile      string `yaml:"ca_file"`
	CertFile    string `yaml:"cert_file"`
	KeyFile     string `yaml:"key_file"`
	// IncludedItems or exclude specific items (for instance Jenkins jobs).
	IncludedItems []string `yaml:"included_items"`
	ExcludedItems []string `yaml:"excluded_items"`
}

type Smart

type Smart struct {
	Enable         bool     `yaml:"enable"`
	PathSmartctl   string   `yaml:"path_smartctl"`
	Devices        []string `yaml:"devices"`
	Excludes       []string `yaml:"excludes"`
	MaxConcurrency int      `yaml:"max_concurrency"`
}

type StatsD

type StatsD struct {
	Enable  bool   `yaml:"enable"`
	Address string `yaml:"address"`
	Port    int    `yaml:"port"`
}

type Telegraf

type Telegraf struct {
	DockerMetricsEnable bool   `yaml:"docker_metrics_enable"`
	StatsD              StatsD `yaml:"statsd"`
}

type Telemetry

type Telemetry struct {
	Enable  bool   `yaml:"enable"`
	Address string `yaml:"address"`
}

type Threshold

type Threshold struct {
	LowWarning   *float64 `yaml:"low_warning"`
	LowCritical  *float64 `yaml:"low_critical"`
	HighWarning  *float64 `yaml:"high_warning"`
	HighCritical *float64 `yaml:"high_critical"`
}

type VSphere

type VSphere struct {
	URL                string `yaml:"url"`
	Username           string `yaml:"username"`
	Password           string `yaml:"password"`
	InsecureSkipVerify bool   `yaml:"insecure_skip_verify"`
	SkipMonitorVMs     bool   `yaml:"skip_monitor_vms"`
}

type Web

type Web struct {
	Enable       bool         `yaml:"enable"`
	Endpoints    WebEndpoints `yaml:"endpoints"`
	LocalUI      LocalUI      `yaml:"local_ui"`
	Listener     Listener     `yaml:"listener"`
	StaticCDNURL string       `yaml:"static_cdn_url"`
}

type WebEndpoints

type WebEndpoints struct {
	DebugEnable bool `yaml:"debug_enable"`
}

type Zabbix

type Zabbix struct {
	Enable  bool   `yaml:"enable"`
	Address string `yaml:"address"`
	Port    int    `yaml:"port"`
}

Jump to

Keyboard shortcuts

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