Documentation
¶
Index ¶
- Variables
- type CmdOpts
- type HostConfigAttrs
- type HostConfigPerMetricDisabledTimes
- type Kind
- type MonitoredDatabase
- func (md *MonitoredDatabase) Connect(ctx context.Context, opts CmdOpts) (err error)
- func (md *MonitoredDatabase) GetDatabaseName() string
- func (md *MonitoredDatabase) IsPostgresSource() bool
- func (md *MonitoredDatabase) Ping(ctx context.Context) error
- func (md *MonitoredDatabase) SetDatabaseName(name string)
- type MonitoredDatabases
- type PatroniClusterMember
- type Reader
- type ReaderWriter
- type Source
- type Sources
- type Writer
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CmdOpts ¶
type CmdOpts struct {
Sources string `` /* 160-byte string literal not displayed */
Refresh int `` /* 127-byte string literal not displayed */
Groups []string `` /* 150-byte string literal not displayed */
MinDbSizeMB int64 `` /* 184-byte string literal not displayed */
MaxParallelConnectionsPerDb int `` /* 241-byte string literal not displayed */
TryCreateListedExtsIfMissing string `` /* 290-byte string literal not displayed */
}
SourceOpts specifies the sources related command-line options
type HostConfigAttrs ¶
type HostConfigAttrs struct {
DcsType string `yaml:"dcs_type"`
DcsEndpoints []string `yaml:"dcs_endpoints"`
Scope string
Namespace string
Username string
Password string
CAFile string `yaml:"ca_file"`
CertFile string `yaml:"cert_file"`
KeyFile string `yaml:"key_file"`
LogsGlobPath string `yaml:"logs_glob_path"` // default $data_directory / $log_directory / *.csvlog
LogsMatchRegex string `yaml:"logs_match_regex"` // default is for CSVLOG format. needs to capture following named groups: log_time, user_name, database_name and error_severity
PerMetricDisabledTimes []HostConfigPerMetricDisabledTimes `yaml:"per_metric_disabled_intervals"`
}
type Kind ¶
type Kind string
const ( SourcePostgres Kind = "postgres" SourcePostgresContinuous Kind = "postgres-continuous-discovery" SourcePgBouncer Kind = "pgbouncer" SourcePgPool Kind = "pgpool" SourcePatroni Kind = "patroni" SourcePatroniContinuous Kind = "patroni-continuous-discovery" SourcePatroniNamespace Kind = "patroni-namespace-discovery" )
type MonitoredDatabase ¶
type MonitoredDatabase struct {
Source
Conn db.PgxPoolIface
ConnConfig *pgxpool.Config
}
MonitoredDatabase represents a single database to monitor. Unlike source, it contains a database connection. Continuous discovery sources (postgres-continuous-discovery, patroni-continuous-discovery, patroni-namespace-discovery) will produce multiple monitored databases structs based on the discovered databases.
func ResolveDatabasesFromPatroni ¶
func ResolveDatabasesFromPatroni(ce Source) ([]*MonitoredDatabase, error)
func (*MonitoredDatabase) Connect ¶
func (md *MonitoredDatabase) Connect(ctx context.Context, opts CmdOpts) (err error)
Connect will establish a connection to the database if it's not already connected. If the connection is already established, it pings the server to ensure it's still alive.
func (*MonitoredDatabase) GetDatabaseName ¶
func (md *MonitoredDatabase) GetDatabaseName() string
GetDatabaseName returns the database name from the connection string
func (*MonitoredDatabase) IsPostgresSource ¶
func (md *MonitoredDatabase) IsPostgresSource() bool
func (*MonitoredDatabase) Ping ¶
func (md *MonitoredDatabase) Ping(ctx context.Context) error
Ping will try to establish a brand new connection to the server and return any error
func (*MonitoredDatabase) SetDatabaseName ¶
func (md *MonitoredDatabase) SetDatabaseName(name string)
SetDatabaseName sets the database name in the connection config for resolved databases
type MonitoredDatabases ¶
type MonitoredDatabases []*MonitoredDatabase
MonitoredDatabase represents a single database to monitor. Unlike source, it contains a database connection. Continuous discovery sources (postgres-continuous-discovery, patroni-continuous-discovery, patroni-namespace-discovery) will produce multiple monitored databases structs based on the discovered databases.
func ResolveDatabasesFromPostgres ¶
func ResolveDatabasesFromPostgres(s Source) (resolvedDbs MonitoredDatabases, err error)
"resolving" reads all the DB names from the given host/port, additionally matching/not matching specified regex patterns
func (MonitoredDatabases) GetMonitoredDatabase ¶
func (mds MonitoredDatabases) GetMonitoredDatabase(DBUniqueName string) *MonitoredDatabase
func (MonitoredDatabases) SyncFromReader ¶
func (mds MonitoredDatabases) SyncFromReader(r Reader) (newmds MonitoredDatabases, err error)
SyncFromReader will update the monitored databases with the latest configuration from the reader. Any resolution errors will be returned, e.g. etcd unavailability. It's up to the caller to proceed with the databases available or stop the execution due to errors.
type PatroniClusterMember ¶
type ReaderWriter ¶
func NewPostgresSourcesReaderWriter ¶
func NewPostgresSourcesReaderWriter(ctx context.Context, connstr string) (ReaderWriter, error)
func NewPostgresSourcesReaderWriterConn ¶
func NewPostgresSourcesReaderWriterConn(ctx context.Context, conn db.PgxPoolIface) (ReaderWriter, error)
func NewYAMLSourcesReaderWriter ¶
func NewYAMLSourcesReaderWriter(ctx context.Context, path string) (ReaderWriter, error)
type Source ¶
type Source struct {
Name string `yaml:"name" db:"name"`
Group string `yaml:"group" db:"group"`
ConnStr string `yaml:"conn_str" db:"connstr"`
Metrics map[string]float64 `yaml:"custom_metrics" db:"config"`
MetricsStandby map[string]float64 `yaml:"custom_metrics_standby" db:"config_standby"`
Kind Kind `yaml:"kind" db:"dbtype"`
IncludePattern string `yaml:"include_pattern" db:"include_pattern"`
ExcludePattern string `yaml:"exclude_pattern" db:"exclude_pattern"`
PresetMetrics string `yaml:"preset_metrics" db:"preset_config"`
PresetMetricsStandby string `yaml:"preset_metrics_standby" db:"preset_config_standby"`
IsSuperuser bool `yaml:"is_superuser" db:"is_superuser"`
IsEnabled bool `yaml:"is_enabled" db:"is_enabled"`
CustomTags map[string]string `yaml:"custom_tags" db:"custom_tags"`
HostConfig HostConfigAttrs `yaml:"host_config" db:"host_config"`
OnlyIfMaster bool `yaml:"only_if_master" db:"only_if_master"`
}
Source represents a configuration how to get databases to monitor. It can be a single database, a group of databases in postgres cluster, a group of databases in HA patroni cluster. pgbouncer and pgpool kinds are purely to indicate that the monitored database connection is made through a connection pooler, which supports its own additional metrics. If one is not interested in those additional metrics, it is ok to specify the connection details as a regular postgres source.
func (*Source) GetDatabaseName ¶
func (Source) ResolveDatabases ¶
func (s Source) ResolveDatabases() (MonitoredDatabases, error)
ResolveDatabases() return a slice of found databases for continuous monitoring sources, e.g. patroni
type Sources ¶
type Sources []Source
func (Sources) ResolveDatabases ¶
func (srcs Sources) ResolveDatabases() (_ MonitoredDatabases, err error)
ResolveDatabases() updates list of monitored objects from continuous monitoring sources, e.g. patroni