Documentation
¶
Overview ¶
Package reaper is responsible to query the metrics from monitored sources and send measurements to sinks.
Index ¶
- func CheckFolderExistsAndReadable(path string) bool
- func DoesEmergencyTriggerfileExist(fname string) bool
- func GetAllRecoMetricsForVersion() (metrics.MetricDefs, error)
- func GetGoPsutilCPU(interval float64) ([]map[string]any, error)
- func GetGoPsutilDiskPG(DataDirs, TblspaceDirs []map[string]any) ([]map[string]any, error)
- func GetGoPsutilDiskTotals() ([]map[string]any, error)
- func GetGoPsutilMem() ([]map[string]any, error)
- func GetLoadAvgLocal() ([]map[string]any, error)
- func GetPathUnderlyingDeviceID(path string) (uint64, error)
- func GetRecommendations(ctx context.Context, md *sources.SourceConn) (metrics.Measurements, error)
- func IsDirectlyFetchableMetric(metric string) bool
- func QueryMeasurements(ctx context.Context, md *sources.SourceConn, sql string, args ...any) (metrics.Measurements, error)
- func TryCreateMetricsFetchingHelpers(ctx context.Context, md *sources.SourceConn) (err error)
- func TryCreateMissingExtensions(ctx context.Context, md *sources.SourceConn, extensionNames []string, ...) []string
- type ChangeDetectionResults
- func DetectConfigurationChanges(ctx context.Context, md *sources.SourceConn, ...) ChangeDetectionResults
- func DetectIndexChanges(ctx context.Context, md *sources.SourceConn, ...) ChangeDetectionResults
- func DetectPrivilegeChanges(ctx context.Context, md *sources.SourceConn, ...) ChangeDetectionResults
- func DetectSprocChanges(ctx context.Context, md *sources.SourceConn, ...) ChangeDetectionResults
- func DetectTableChanges(ctx context.Context, md *sources.SourceConn, ...) ChangeDetectionResults
- type ConcurrentMetricDefs
- func (cmd *ConcurrentMetricDefs) Assign(newDefs *metrics.Metrics)
- func (cmd *ConcurrentMetricDefs) GetMetricDef(name string) (m metrics.Metric, ok bool)
- func (cmd *ConcurrentMetricDefs) GetPresetDef(name string) (m metrics.Preset, ok bool)
- func (cmd *ConcurrentMetricDefs) GetPresetMetrics(name string) (m map[string]float64)
- type ExistingPartitionInfo
- type InstanceMetricCache
- type Reaper
- func (r *Reaper) AddSysinfoToMeasurements(data metrics.Measurements, md *sources.SourceConn)
- func (r *Reaper) CheckForPGObjectChangesAndStore(ctx context.Context, dbUnique string, md *sources.SourceConn, ...)
- func (r *Reaper) CloseResourcesForRemovedMonitoredDBs(shutDownDueToRoleChange map[string]bool)
- func (r *Reaper) CreateSourceHelpers(ctx context.Context, srcL log.Logger, monitoredSource *sources.SourceConn)
- func (r *Reaper) FetchMetric(ctx context.Context, md *sources.SourceConn, metricName string, ...) (_ *metrics.MeasurementEnvelope, err error)
- func (r *Reaper) FetchStatsDirectlyFromOS(ctx context.Context, md *sources.SourceConn, metricName string) (*metrics.MeasurementEnvelope, error)
- func (r *Reaper) LoadMetrics() (err error)
- func (r *Reaper) LoadSources() (err error)
- func (r *Reaper) PrintMemStats()
- func (r *Reaper) Ready() bool
- func (r *Reaper) Reap(ctx context.Context)
- func (r *Reaper) ShutdownOldWorkers(ctx context.Context, hostsToShutDownDueToRoleChange map[string]bool)
- func (r *Reaper) WriteMeasurements(ctx context.Context)
- func (r *Reaper) WriteMonitoredSources(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFolderExistsAndReadable ¶ added in v3.3.0
func GetAllRecoMetricsForVersion ¶
func GetAllRecoMetricsForVersion() (metrics.MetricDefs, error)
func GetGoPsutilCPU ¶ added in v3.3.0
Simulates "psutil" metric output. Assumes the result from last call as input, otherwise uses a 1s measurement
func GetGoPsutilDiskPG ¶
func GetGoPsutilDiskTotals ¶ added in v3.3.0
func GetGoPsutilMem ¶ added in v3.3.0
func GetLoadAvgLocal ¶ added in v3.3.0
func GetPathUnderlyingDeviceID ¶ added in v3.3.0
func GetRecommendations ¶
func GetRecommendations(ctx context.Context, md *sources.SourceConn) (metrics.Measurements, error)
func QueryMeasurements ¶ added in v3.2.0
func QueryMeasurements(ctx context.Context, md *sources.SourceConn, sql string, args ...any) (metrics.Measurements, error)
func TryCreateMetricsFetchingHelpers ¶
func TryCreateMetricsFetchingHelpers(ctx context.Context, md *sources.SourceConn) (err error)
Called once on daemon startup to try to create "metric fething helper" functions automatically
func TryCreateMissingExtensions ¶
func TryCreateMissingExtensions(ctx context.Context, md *sources.SourceConn, extensionNames []string, existingExtensions map[string]int) []string
Called once on daemon startup if some commonly wanted extension (most notably pg_stat_statements) is missing. With newer Postgres version can even succeed if the user is not a real superuser due to some cloud-specific whitelisting or "trusted extensions" (a feature from v13). Ignores errors.
Types ¶
type ChangeDetectionResults ¶
func DetectConfigurationChanges ¶
func DetectConfigurationChanges(ctx context.Context, md *sources.SourceConn, storageCh chan<- metrics.MeasurementEnvelope, hostState map[string]map[string]string) ChangeDetectionResults
func DetectIndexChanges ¶
func DetectIndexChanges(ctx context.Context, md *sources.SourceConn, storageCh chan<- metrics.MeasurementEnvelope, hostState map[string]map[string]string) ChangeDetectionResults
func DetectPrivilegeChanges ¶
func DetectPrivilegeChanges(ctx context.Context, md *sources.SourceConn, storageCh chan<- metrics.MeasurementEnvelope, hostState map[string]map[string]string) ChangeDetectionResults
func DetectSprocChanges ¶
func DetectSprocChanges(ctx context.Context, md *sources.SourceConn, storageCh chan<- metrics.MeasurementEnvelope, hostState map[string]map[string]string) ChangeDetectionResults
func DetectTableChanges ¶
func DetectTableChanges(ctx context.Context, md *sources.SourceConn, storageCh chan<- metrics.MeasurementEnvelope, hostState map[string]map[string]string) ChangeDetectionResults
type ConcurrentMetricDefs ¶ added in v3.3.0
func NewConcurrentMetricDefs ¶ added in v3.3.0
func NewConcurrentMetricDefs() *ConcurrentMetricDefs
func (*ConcurrentMetricDefs) Assign ¶ added in v3.3.0
func (cmd *ConcurrentMetricDefs) Assign(newDefs *metrics.Metrics)
func (*ConcurrentMetricDefs) GetMetricDef ¶ added in v3.3.0
func (cmd *ConcurrentMetricDefs) GetMetricDef(name string) (m metrics.Metric, ok bool)
func (*ConcurrentMetricDefs) GetPresetDef ¶ added in v3.3.0
func (cmd *ConcurrentMetricDefs) GetPresetDef(name string) (m metrics.Preset, ok bool)
func (*ConcurrentMetricDefs) GetPresetMetrics ¶ added in v3.3.0
func (cmd *ConcurrentMetricDefs) GetPresetMetrics(name string) (m map[string]float64)
type ExistingPartitionInfo ¶
type InstanceMetricCache ¶ added in v3.3.0
func NewInstanceMetricCache ¶ added in v3.3.0
func NewInstanceMetricCache() *InstanceMetricCache
func (*InstanceMetricCache) Get ¶ added in v3.3.0
func (imc *InstanceMetricCache) Get(key string, age time.Duration) metrics.Measurements
func (*InstanceMetricCache) Put ¶ added in v3.3.0
func (imc *InstanceMetricCache) Put(key string, data metrics.Measurements)
type Reaper ¶
Reaper is the struct that responsible for fetching metrics measurements from the sources and storing them to the sinks
func (*Reaper) AddSysinfoToMeasurements ¶ added in v3.2.0
func (r *Reaper) AddSysinfoToMeasurements(data metrics.Measurements, md *sources.SourceConn)
func (*Reaper) CheckForPGObjectChangesAndStore ¶ added in v3.2.0
func (*Reaper) CloseResourcesForRemovedMonitoredDBs ¶ added in v3.3.0
func (*Reaper) CreateSourceHelpers ¶ added in v3.3.0
func (r *Reaper) CreateSourceHelpers(ctx context.Context, srcL log.Logger, monitoredSource *sources.SourceConn)
CreateSourceHelpers creates the extensions and metric helpers for the monitored source
func (*Reaper) FetchMetric ¶ added in v3.3.0
func (*Reaper) FetchStatsDirectlyFromOS ¶ added in v3.3.0
func (r *Reaper) FetchStatsDirectlyFromOS(ctx context.Context, md *sources.SourceConn, metricName string) (*metrics.MeasurementEnvelope, error)
func (*Reaper) LoadMetrics ¶ added in v3.2.0
LoadMetrics loads metric definitions from the reader
func (*Reaper) LoadSources ¶ added in v3.2.0
LoadSources loads sources from the reader
func (*Reaper) PrintMemStats ¶ added in v3.5.0
func (r *Reaper) PrintMemStats()
func (*Reaper) Ready ¶ added in v3.1.0
Ready() returns true if the service is healthy and operating correctly
func (*Reaper) Reap ¶
Reap() starts the main monitoring loop. It is responsible for fetching metrics measurements from the sources and storing them to the sinks. It also manages the lifecycle of the metric gatherers. In case of a source or metric definition change, it will start or stop the gatherers accordingly.
func (*Reaper) ShutdownOldWorkers ¶ added in v3.3.0
func (*Reaper) WriteMeasurements ¶ added in v3.2.0
WriteMeasurements() writes the metrics to the sinks
func (*Reaper) WriteMonitoredSources ¶ added in v3.2.0
WriteMonitoredSources writes actively monitored DBs listing to sinks every monitoredDbsDatastoreSyncIntervalSeconds (default 10min)