service

package
v0.4.23 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector interface {
	Describe(chan<- *prometheus.Desc)
	Collect(chan<- prometheus.Metric)
}

Exporter is an interface for prometheus.Collector.

type Config

type Config struct {
	RuntimeMode        int
	NoTrackMode        bool
	ConnDefaults       map[string]string `yaml:"defaults"` // Defaults
	ConnsSettings      ConnsSettings
	Filters            map[string]filter.Filter
	DisabledCollectors []string
	// CollectorsSettings defines all collector settings propagated from main YAML configuration.
	CollectorsSettings model.CollectorsSettings
}

Config defines service's configuration.

type ConnSetting

type ConnSetting struct {
	// ServiceType defines type of service for which these connection settings are used.
	ServiceType string `yaml:"service_type"`
	// Conninfo is the connection string in service-specific format.
	Conninfo string `yaml:"conninfo"`
}

ConnSetting describes connection settings required for connecting to particular service. This struct primarily is used for representing services defined by user in the config file.

type ConnsSettings added in v0.4.23

type ConnsSettings map[string]ConnSetting

ConnsSettings defines a set of all connection settings of exact services.

type Repository

type Repository struct {
	sync.RWMutex                    // protect concurrent access
	Services     map[string]Service // service repo store
}

Repository is the repository with services.

func NewRepository

func NewRepository() *Repository

NewRepository creates new services repository.

func (*Repository) AddServicesFromConfig

func (repo *Repository) AddServicesFromConfig(config Config)

AddServicesFromConfig is a public wrapper on AddServicesFromConfig method.

func (*Repository) GetService

func (repo *Repository) GetService(id string) Service

GetService is a public wrapper on getService method.

func (*Repository) GetServiceIDs

func (repo *Repository) GetServiceIDs() []string

GetServiceIDs is a public wrapper on GetServiceIDs method.

func (*Repository) SetupServices

func (repo *Repository) SetupServices(config Config) error

SetupServices is a public wrapper on SetupServices method.

func (*Repository) StartBackgroundDiscovery

func (repo *Repository) StartBackgroundDiscovery(ctx context.Context, config Config)

StartBackgroundDiscovery is a public wrapper on StartBackgroundDiscovery method.

func (*Repository) TotalServices

func (repo *Repository) TotalServices() int

TotalServices is a public wrapper on TotalServices method.

type Service

type Service struct {
	// Service identifier is unique key across all monitored services and used to distinguish services of the same type
	// running on the single host (two Postgres services running on the same host but listening on different ports).
	// Hence not to mix their metrics the ServiceID is introduced and attached to metrics as "sid" label:
	// metric_xact_commits{database="test", sid="postgres:5432"} -- metric from the first postgres running on 5432 port
	// metric_xact_commits{database="test", sid="postgres:5433"} -- metric from the second postgres running on 5433 port
	ServiceID string
	// Connection settings required for connecting to the service.
	ConnSettings ConnSetting
	// Prometheus-based metrics collector associated with the service. Each 'service' has its own dedicated collector instance
	// which implements a service-specific set of metric collectors.
	Collector Collector
	// TotalErrors represents total number of times where service's health checks failed. When errors limit is reached service
	// removed from the repo.
	TotalErrors int
}

Service struct describes service - the target from which should be collected metrics.

func TestPgbouncerService

func TestPgbouncerService() Service

TestPgbouncerService returns pgbouncer service for testing purposes

func TestPostgresService

func TestPostgresService() Service

TestPostgresService returns postgres service for testing purposes

func TestSystemService

func TestSystemService() Service

TestSystemService returns system service for testing purposes

Jump to

Keyboard shortcuts

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