Documentation
¶
Overview ¶
Package discovery contains function related to the service discovery.
Index ¶
- func AddDefaultInputs(commandRunner *gloutonexec.Runner, metricRegistry GathererRegistry, ...) error
- type Application
- type ApplicationType
- type CheckDetails
- type CheckNow
- type Discoverer
- type Discovery
- func (d *Discovery) Close()
- func (d *Discovery) DiagnosticArchive(_ context.Context, zipFile types.ArchiveWriter) error
- func (d *Discovery) GetCheckNow(nameInstance NameInstance) (CheckNow, error)
- func (d *Discovery) GetLatestDiscovery() ([]Service, time.Time)
- func (d *Discovery) RemoveIfNonRunning(services []Service)
- func (d *Discovery) Run(ctx context.Context) error
- func (d *Discovery) Subscribe(ctx context.Context) <-chan []Service
- func (d *Discovery) TriggerUpdate()
- type DynamicDiscovery
- type GathererRegistry
- type IgnoredService
- type MockDiscoverer
- func (md *MockDiscoverer) Discovery(_ context.Context) (services []Service, wantedNextUpdate time.Time, err error)
- func (md *MockDiscoverer) GetLatestDiscovery() ([]Service, time.Time)
- func (md *MockDiscoverer) RemoveIfNonRunning([]Service)
- func (md *MockDiscoverer) SetResult(services []Service, err error)
- type NameInstance
- type Option
- type PersistentDiscoverer
- type Registry
- type Service
- type ServiceLogReceiver
- type ServiceName
- type State
- type SudoFileReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDefaultInputs ¶
func AddDefaultInputs(commandRunner *gloutonexec.Runner, metricRegistry GathererRegistry, inputsConfig inputs.CollectorConfig, vethProvider *veth.Provider) error
AddDefaultInputs adds system inputs to a collector.
Types ¶
type Application ¶
type Application struct {
Name string
Type ApplicationType
}
type ApplicationType ¶
type ApplicationType int
const ( ApplicationUnset ApplicationType = 0 ApplicationDockerCompose ApplicationType = 1 )
type CheckDetails ¶
type CheckDetails struct {
// contains filtered or unexported fields
}
CheckDetails is used to save a check and his id.
type CheckNow ¶
type CheckNow func(ctx context.Context) (types.StatusDescription, error)
CheckNow is type of check function.
type Discoverer ¶
Discoverer allow to discover services. See DynamicDiscovery and Discovery.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery implements the full discovery mechanism. It will take information from both the dynamic discovery (service currently running) and previously detected services. It will configure metrics input and add them to a Collector.
func New ¶
func New( dynamicDiscovery Discoverer, commandRunner *gloutonexec.Runner, metricRegistry GathererRegistry, state State, containerInfo containerInfoProvider, servicesOverride []config.Service, isServiceIgnored func(Service) bool, isCheckIgnored func(Service) bool, isInputIgnored func(Service) bool, isContainerIgnored func(c facts.Container) bool, processFact processFact, absentServiceDeactivationDelay time.Duration, logProcessingCfg config.OpenTelemetry, ) (*Discovery, prometheus.MultiError)
New returns a new Discovery and some warnings.
func (*Discovery) Close ¶
func (d *Discovery) Close()
Close stop & cleanup inputs & check created by the discovery.
func (*Discovery) DiagnosticArchive ¶
DiagnosticArchive add to a zipfile useful diagnostic information.
func (*Discovery) GetCheckNow ¶
func (d *Discovery) GetCheckNow(nameInstance NameInstance) (CheckNow, error)
GetCheckNow returns the GetCheckNow function associated to a NameInstance.
func (*Discovery) GetLatestDiscovery ¶
GetLatestDiscovery return list of services detected on the system with date of latest update.
func (*Discovery) RemoveIfNonRunning ¶
RemoveIfNonRunning remove a service if the service is not running.
This is useful to remove persisted service that no longer run. The service will immediately be remove from next call to GetLatestDiscovery and a next discovery will be run asynchroniously if from entry were deleted.
func (*Discovery) Run ¶
Run execute the discovery thread that will update the discovery when needed.
func (*Discovery) Subscribe ¶
Subscribe return a channel that will receive all update of services after a discovery run.
On subscribe a list of current discovered service will be sent, unless no discovery have yet run.
The channel will be closed when ctx expire. You must drain the full channel or discovery could be blocked.
func (*Discovery) TriggerUpdate ¶
func (d *Discovery) TriggerUpdate()
TriggerUpdate ask for a new discovery to be run. This function as asynchronous and the discovery might not have finished when TriggerUpdate return.
Use Subscribe to get notified after every change in discovery.
type DynamicDiscovery ¶
type DynamicDiscovery struct {
// contains filtered or unexported fields
}
DynamicDiscovery implement the dynamic discovery. It will only return service dynamically discovery from processes list, containers running, ... It don't include manually configured service or previously detected services.
func NewDynamic ¶
func NewDynamic(opts Option) *DynamicDiscovery
NewDynamic create a new dynamic service discovery which use information from processes and netstat to discovery services.
func (*DynamicDiscovery) Discovery ¶
Discovery detect service running on the system and return a list of Service object. It also return a date for wanted next update.
func (*DynamicDiscovery) ProcessServiceInfo ¶
func (dd *DynamicDiscovery) ProcessServiceInfo(cmdLine []string, pid int, createTime time.Time) (serviceName ServiceName, containerName string)
ProcessServiceInfo return the service & container a process belong based on its command line + pid & start time.
type GathererRegistry ¶
type GathererRegistry interface {
RegisterGatherer(opt registry.RegistrationOption, gatherer prometheus.Gatherer) (types.Registration, error)
RegisterInput(opt registry.RegistrationOption, input telegraf.Input) (types.Registration, error)
}
GathererRegistry allow to register/unregister prometheus Gatherer.
type IgnoredService ¶
type IgnoredService struct {
// contains filtered or unexported fields
}
IgnoredService saves the ignored services (checks/metrics/everything) imported from the configuration file.
func NewIgnoredService ¶
func NewIgnoredService(ignoredNamesInstances []config.NameInstance) IgnoredService
NewIgnoredService initializes IgnoredService struct.
func (IgnoredService) IsServiceIgnored ¶
func (ic IgnoredService) IsServiceIgnored(srv Service) bool
IsServiceIgnored returns whether the given service should be ignored or not.
func (IgnoredService) IsServiceIgnoredNameAndContainer ¶
func (ic IgnoredService) IsServiceIgnoredNameAndContainer(name, containerName string) bool
IsServiceIgnoredNameAndContainer does the same as IsServiceIgnored, but without the whole Service type.
type MockDiscoverer ¶
MockDiscoverer is useful for tests.
func (*MockDiscoverer) Discovery ¶
func (md *MockDiscoverer) Discovery(_ context.Context) (services []Service, wantedNextUpdate time.Time, err error)
Discovery implements Discoverer.
func (*MockDiscoverer) GetLatestDiscovery ¶
func (md *MockDiscoverer) GetLatestDiscovery() ([]Service, time.Time)
GetLatestDiscovery implements Discoverer.
func (*MockDiscoverer) RemoveIfNonRunning ¶
func (md *MockDiscoverer) RemoveIfNonRunning([]Service)
RemoveIfNonRunning implements PersistentDiscoverer.
func (*MockDiscoverer) SetResult ¶
func (md *MockDiscoverer) SetResult(services []Service, err error)
SetResult fill result of Discovery.
type NameInstance ¶
NameInstance contains the service and instance names.
The instance could be either a container name OR simply a arbitrary value.
type PersistentDiscoverer ¶
type PersistentDiscoverer interface {
GetLatestDiscovery() ([]Service, time.Time)
RemoveIfNonRunning(services []Service)
}
PersistentDiscoverer also allow to remove a non-running service and get latest discovery done.
type Registry ¶
type Registry interface {
AddTask(task task.Runner, shortName string) (int, error)
RemoveTask(taskID int)
}
Registry will contains checks.
type Service ¶
type Service struct {
Config config.Service
Name string
Instance string
Tags []string
Applications []Application
ServiceType ServiceName
ContainerID string
ContainerName string // If ContainerName is set, Instance must be the same value.
IPAddress string // IPAddress is the IPv4 address to reach service for metrics gathering. If empty, it means IP was not found
ListenAddresses []facts.ListenAddress
ExePath string
IgnoredPorts map[int]bool
Active bool
CheckIgnored bool
MetricsIgnored bool
// The interval of the check, used only for custom checks.
Interval time.Duration
// May be nil if no log processing should be applied.
LogProcessing []ServiceLogReceiver
HasNetstatInfo bool
LastNetstatInfo time.Time
LastTimeSeen time.Time
// contains filtered or unexported fields
}
Service is the information found about a given service.
func (Service) AddressForPort ¶
AddressForPort return the IP address for given port & network (tcp, udp).
func (Service) AddressPort ¶
AddressPort return the IP address &port for the "main" service (e.g. for RabbitMQ the AMQP port, not the management port).
func (Service) AnnotationsOfStatus ¶
func (s Service) AnnotationsOfStatus() types.MetricAnnotations
AnnotationsOfStatus returns the annotations for the status metrics of this service.
func (Service) LabelsOfStatus ¶
LabelsOfStatus returns the labels for the status metrics of this service.
type ServiceLogReceiver ¶
type ServiceName ¶
type ServiceName string
ServiceName is the name of a supported service.
const ( ApacheService ServiceName = "apache" AsteriskService ServiceName = "asterisk" BindService ServiceName = "bind" BitBucketService ServiceName = "bitbucket" CassandraService ServiceName = "cassandra" ConfluenceService ServiceName = "confluence" DovecotService ServiceName = "dovecot" EjabberService ServiceName = "ejabberd" ElasticSearchService ServiceName = "elasticsearch" EximService ServiceName = "exim" Fail2banService ServiceName = "fail2ban" FreeradiusService ServiceName = "freeradius" HAProxyService ServiceName = "haproxy" InfluxDBService ServiceName = "influxdb" JenkinsService ServiceName = "jenkins" JIRAService ServiceName = "jira" KafkaService ServiceName = "kafka" LibvirtService ServiceName = "libvirt" MariaDBService ServiceName = "mariadb" MemcachedService ServiceName = "memcached" MongoDBService ServiceName = "mongodb" MosquittoService ServiceName = "mosquitto" //nolint:misspell MySQLService ServiceName = "mysql" NatsService ServiceName = "nats" NfsService ServiceName = "nfs" NginxService ServiceName = "nginx" NTPService ServiceName = "ntp" OpenLDAPService ServiceName = "openldap" OpenVPNService ServiceName = "openvpn" PHPFPMService ServiceName = "phpfpm" PostfixService ServiceName = "postfix" PostgreSQLService ServiceName = "postgresql" RabbitMQService ServiceName = "rabbitmq" RedisService ServiceName = "redis" SaltMasterService ServiceName = "salt_master" SquidService ServiceName = "squid" UWSGIService ServiceName = "uwsgi" ValkeyService ServiceName = "valkey" VarnishService ServiceName = "varnish" UPSDService ServiceName = "upsd" ZookeeperService ServiceName = "zookeeper" CustomService ServiceName = "__custom__" )
List of known service names.
type SudoFileReader ¶
type SudoFileReader struct {
HostRootPath string
Runner *gloutonexec.Runner
}
SudoFileReader read file using sudo cat (or direct read if running as root).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package promexporter implement an discovery of Prometheus exporter based on Docker labels / Kubernetes annotations
|
Package promexporter implement an discovery of Prometheus exporter based on Docker labels / Kubernetes annotations |