service

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 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
	ConnSettings       []ConnSetting
	Filters            map[string]filter.Filter
	DisabledCollectors []string
}

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 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)

func (*Repository) GetService

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

func (*Repository) GetServiceIDs

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

func (*Repository) SetupServices

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

func (*Repository) StartBackgroundDiscovery

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

func (*Repository) TotalServices

func (repo *Repository) TotalServices() int

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