reaper

package
v5.0.0-...-51a5e96 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Overview

Package reaper is responsible to query the metrics from monitored sources and send measurements to sinks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFolderExistsAndReadable

func CheckFolderExistsAndReadable(path string) bool

func DoesEmergencyTriggerfileExist

func DoesEmergencyTriggerfileExist(fname string) bool

func GetGoPsutilCPU

func GetGoPsutilCPU(interval float64) ([]map[string]any, error)

Simulates "psutil" metric output. Assumes the result from last call as input, otherwise uses a 1s measurement

func GetGoPsutilDiskPG

func GetGoPsutilDiskPG(DataDirs, TblspaceDirs []map[string]any) ([]map[string]any, error)

func GetGoPsutilDiskTotals

func GetGoPsutilDiskTotals() ([]map[string]any, error)

func GetGoPsutilMem

func GetGoPsutilMem() ([]map[string]any, error)

func GetLoadAvgLocal

func GetLoadAvgLocal() ([]map[string]any, error)

func GetPathUnderlyingDeviceID

func GetPathUnderlyingDeviceID(path string) (uint64, error)

func IsDirectlyFetchableMetric

func IsDirectlyFetchableMetric(md *sources.SourceConn, metric string) bool

func QueryMeasurements

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

type ChangeDetectionResults struct {
	Target  string
	Created int
	Altered int
	Dropped int
}

func (*ChangeDetectionResults) String

func (cdr *ChangeDetectionResults) String() string

func (*ChangeDetectionResults) Total

func (cdr *ChangeDetectionResults) Total() int

type ConcurrentMetricDefs

type ConcurrentMetricDefs struct {
	*metrics.Metrics
	sync.RWMutex
}

func NewConcurrentMetricDefs

func NewConcurrentMetricDefs() *ConcurrentMetricDefs

func (*ConcurrentMetricDefs) Assign

func (cmd *ConcurrentMetricDefs) Assign(newDefs *metrics.Metrics)

func (*ConcurrentMetricDefs) GetMetricDef

func (cmd *ConcurrentMetricDefs) GetMetricDef(name string) (m metrics.Metric, ok bool)

func (*ConcurrentMetricDefs) GetPresetDef

func (cmd *ConcurrentMetricDefs) GetPresetDef(name string) (m metrics.Preset, ok bool)

func (*ConcurrentMetricDefs) GetPresetMetrics

func (cmd *ConcurrentMetricDefs) GetPresetMetrics(name string) (m map[string]float64)

type ExistingPartitionInfo

type ExistingPartitionInfo struct {
	StartTime time.Time
	EndTime   time.Time
}

type InstanceMetricCache

type InstanceMetricCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewInstanceMetricCache

func NewInstanceMetricCache() *InstanceMetricCache

func (*InstanceMetricCache) Get

func (*InstanceMetricCache) Put

func (imc *InstanceMetricCache) Put(key string, data metrics.Measurements)

type LogParser

type LogParser struct {
	LogsMatchRegex     *regexp.Regexp
	LogFolder          string
	ServerMessagesLang string
	SourceConn         *sources.SourceConn
	Interval           float64
	StoreCh            chan<- metrics.MeasurementEnvelope
	// contains filtered or unexported fields
}

func NewLogParser

func NewLogParser(ctx context.Context, mdb *sources.SourceConn, storeCh chan<- metrics.MeasurementEnvelope) (*LogParser, error)

func (*LogParser) GetMeasurementEnvelope

func (lp *LogParser) GetMeasurementEnvelope() metrics.MeasurementEnvelope

GetMeasurementEnvelope converts current event counts to a MeasurementEnvelope

func (*LogParser) HasSendIntervalElapsed

func (lp *LogParser) HasSendIntervalElapsed() bool

func (*LogParser) ParseLogs

func (lp *LogParser) ParseLogs() error

type Reaper

type Reaper struct {
	*cmdopts.Options
	// contains filtered or unexported fields
}

Reaper is the struct that responsible for fetching metrics measurements from the sources and storing them to the sinks

func NewReaper

func NewReaper(ctx context.Context, opts *cmdopts.Options) (r *Reaper)

NewReaper creates a new Reaper instance

func (*Reaper) AddSysinfoToMeasurements

func (r *Reaper) AddSysinfoToMeasurements(data metrics.Measurements, md *sources.SourceConn)

func (*Reaper) CloseResourcesForRemovedMonitoredDBs

func (r *Reaper) CloseResourcesForRemovedMonitoredDBs(hostsToShutDown map[string]bool)

func (*Reaper) CreateSourceHelpers

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

func (r *Reaper) DetectConfigurationChanges(ctx context.Context, md *sources.SourceConn) ChangeDetectionResults

func (*Reaper) DetectIndexChanges

func (r *Reaper) DetectIndexChanges(ctx context.Context, md *sources.SourceConn) ChangeDetectionResults

func (*Reaper) DetectPrivilegeChanges

func (r *Reaper) DetectPrivilegeChanges(ctx context.Context, md *sources.SourceConn) ChangeDetectionResults

func (*Reaper) DetectSprocChanges

func (r *Reaper) DetectSprocChanges(ctx context.Context, md *sources.SourceConn) (changeCounts ChangeDetectionResults)

func (*Reaper) DetectTableChanges

func (r *Reaper) DetectTableChanges(ctx context.Context, md *sources.SourceConn) ChangeDetectionResults

func (*Reaper) FetchMetric

func (r *Reaper) FetchMetric(ctx context.Context, md *sources.SourceConn, metricName string) (_ *metrics.MeasurementEnvelope, err error)

func (*Reaper) FetchStatsDirectlyFromOS

func (r *Reaper) FetchStatsDirectlyFromOS(ctx context.Context, md *sources.SourceConn, metricName string) (*metrics.MeasurementEnvelope, error)

func (*Reaper) GetInstanceUpMeasurement

func (r *Reaper) GetInstanceUpMeasurement(ctx context.Context, md *sources.SourceConn) (metrics.Measurements, error)

GetInstanceUpMeasurement returns a single measurement with "instance_up" metric used to detect if the instance is up or down

func (*Reaper) GetObjectChangesMeasurement

func (r *Reaper) GetObjectChangesMeasurement(ctx context.Context, md *sources.SourceConn) (metrics.Measurements, error)

func (*Reaper) LoadMetrics

func (r *Reaper) LoadMetrics() (err error)

LoadMetrics loads metric definitions from the reader

func (*Reaper) LoadSources

func (r *Reaper) LoadSources(ctx context.Context) (err error)

LoadSources loads sources from the reader

func (*Reaper) PrintMemStats

func (r *Reaper) PrintMemStats()

func (*Reaper) Ready

func (r *Reaper) Ready() bool

Ready() returns true if the service is healthy and operating correctly

func (*Reaper) Reap

func (r *Reaper) Reap(ctx context.Context)

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

func (r *Reaper) ShutdownOldWorkers(ctx context.Context, hostsToShutDown map[string]bool)

func (*Reaper) WriteMeasurements

func (r *Reaper) WriteMeasurements(ctx context.Context)

WriteMeasurements() writes the metrics to the sinks

func (*Reaper) WriteMonitoredSources

func (r *Reaper) WriteMonitoredSources(ctx context.Context)

WriteMonitoredSources writes actively monitored DBs listing to sinks every monitoredDbsDatastoreSyncIntervalSeconds (default 10min)

Jump to

Keyboard shortcuts

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