Documentation
¶
Index ¶
- type Collector
- type Config
- type ConnSetting
- type Repository
- func (repo *Repository) AddServicesFromConfig(config Config)
- func (repo *Repository) GetService(id string) Service
- func (repo *Repository) GetServiceIDs() []string
- func (repo *Repository) SetupServices(config Config) error
- func (repo *Repository) StartBackgroundDiscovery(ctx context.Context, config Config)
- func (repo *Repository) TotalServices() int
- type Service
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
ProjectID string
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
// Project identifier is unique key across all projects (project may have several instances). ProjectID also is attached
// as a label and unions metrics collected from the several hosts. See example below, there are two metrics from different
// hosts but these hosts belong to the same "project" with ID = 1.
// metric_xact_rollbacks{db_instance="host-1" sid="postgres:5432", database="test", project_id="1"}
// metric_xact_rollbacks{db_instance="host-2" sid="postgres:5432", database="test", project_id="1"}
ProjectID 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