collector

package
v0.0.0-...-773ecb8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT, UPL-1.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AZVault

type AZVault struct {
	ID             string `yaml:"id"`
	UsernameSecret string `yaml:"usernameSecret"`
	PasswordSecret string `yaml:"passwordSecret"`
}

type Config

type Config struct {
	ConfigFile         string
	User               string
	Password           string
	ConnectString      string
	DbRole             dsn.AdminRole
	ConfigDir          string
	ExternalAuth       bool
	MaxIdleConns       int
	MaxOpenConns       int
	PoolIncrement      int
	PoolMaxConnections int
	PoolMinConnections int
	CustomMetrics      string
	QueryTimeout       int
	DefaultMetricsFile string
	ScrapeInterval     time.Duration
	LoggingConfig      LoggingConfig
}

type ConnectConfig

type ConnectConfig struct {
	Role               dsn.AdminRole
	TNSAdmin           string `yaml:"tnsAdmin"`
	ExternalAuth       bool   `yaml:"externalAuth"`
	MaxOpenConns       *int   `yaml:"maxOpenConns"`
	MaxIdleConns       *int   `yaml:"maxIdleConns"`
	PoolIncrement      *int   `yaml:"poolIncrement"`
	PoolMaxConnections *int   `yaml:"poolMaxConnections"`
	PoolMinConnections *int   `yaml:"poolMinConnections"`
	QueryTimeout       *int   `yaml:"queryTimeout"`
}

func (ConnectConfig) GetMaxIdleConns

func (c ConnectConfig) GetMaxIdleConns() int

func (ConnectConfig) GetMaxOpenConns

func (c ConnectConfig) GetMaxOpenConns() int

func (ConnectConfig) GetPoolIncrement

func (c ConnectConfig) GetPoolIncrement() int

func (ConnectConfig) GetPoolMaxConnections

func (c ConnectConfig) GetPoolMaxConnections() int

func (ConnectConfig) GetPoolMinConnections

func (c ConnectConfig) GetPoolMinConnections() int

func (ConnectConfig) GetQueryTimeout

func (c ConnectConfig) GetQueryTimeout() int

type Database

type Database struct {
	Name    string
	Up      float64
	Session *sql.DB
	Type    float64
	Config  DatabaseConfig
}

func NewDatabase

func NewDatabase(logger *slog.Logger, dbname string, dbconfig DatabaseConfig) *Database

func (*Database) DBTypeMetric

func (d *Database) DBTypeMetric() prometheus.Metric

func (*Database) UpMetric

func (d *Database) UpMetric() prometheus.Metric

func (*Database) WarmupConnectionPool

func (d *Database) WarmupConnectionPool(logger *slog.Logger)

WarmupConnectionPool serially acquires connections to "warm up" the connection pool. This is a workaround for a perceived bug in ODPI_C where rapid acquisition of connections results in a SIGABRT.

type DatabaseConfig

type DatabaseConfig struct {
	Username      string
	Password      string
	URL           string `yaml:"url"`
	ConnectConfig `yaml:",inline"`
	Vault         *VaultConfig `yaml:"vault,omitempty"`
}

func (DatabaseConfig) GetPassword

func (d DatabaseConfig) GetPassword() string

func (DatabaseConfig) GetUsername

func (d DatabaseConfig) GetUsername() string

type Exporter

type Exporter struct {
	*MetricsConfiguration
	// contains filtered or unexported fields
}

Exporter collects Oracle DB metrics. It implements prometheus.Collector.

func NewExporter

func NewExporter(logger *slog.Logger, m *MetricsConfiguration) *Exporter

NewExporter creates a new Exporter instance

func (*Exporter) Collect

func (e *Exporter) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Exporter) DefaultMetrics

func (e *Exporter) DefaultMetrics() Metrics

DefaultMetrics is a somewhat hacky way to load the default metrics

func (*Exporter) Describe

func (e *Exporter) Describe(ch chan<- *prometheus.Desc)

Describe describes all the metrics exported by the Oracle DB exporter.

func (*Exporter) GetDBs

func (e *Exporter) GetDBs() []*Database

this is used by the log exporter to share the database connection

func (*Exporter) RunScheduledScrapes

func (e *Exporter) RunScheduledScrapes(ctx context.Context)

RunScheduledScrapes is only relevant for users of this package that want to set the scrape on a timer rather than letting it be per Collect call

func (*Exporter) ScrapeMetric

func (e *Exporter) ScrapeMetric(d *Database, ch chan<- prometheus.Metric, m Metric) error

ScrapeMetric is an interface method to call scrapeGenericValues using Metric struct values

type LoggingConfig

type LoggingConfig struct {
	LogDisable     *int           `yaml:"disable"`
	LogInterval    *time.Duration `yaml:"interval"`
	LogDestination string         `yaml:"destination"`
}

type Metric

type Metric struct {
	Context          string
	Labels           []string
	MetricsDesc      map[string]string
	MetricsType      map[string]string
	MetricsBuckets   map[string]map[string]string
	FieldToAppend    string
	Request          string
	IgnoreZeroResult bool
	QueryTimeout     string
	ScrapeInterval   string
	Databases        []string
}

Metric is an object description

type Metrics

type Metrics struct {
	Metric []Metric
}

Metrics is a container structure for prometheus metrics

type MetricsConfiguration

type MetricsConfiguration struct {
	MetricsPath string                    `yaml:"metricsPath"`
	Databases   map[string]DatabaseConfig `yaml:"databases"`
	Metrics     MetricsFilesConfig        `yaml:"metrics"`
	Logging     LoggingConfig             `yaml:"log"`
}

func LoadMetricsConfiguration

func LoadMetricsConfiguration(logger *slog.Logger, cfg *Config, path string) (*MetricsConfiguration, error)

func (*MetricsConfiguration) CustomMetricsFiles

func (m *MetricsConfiguration) CustomMetricsFiles() []string

func (*MetricsConfiguration) LogDestination

func (m *MetricsConfiguration) LogDestination() string

func (*MetricsConfiguration) LogDisable

func (m *MetricsConfiguration) LogDisable() int

func (*MetricsConfiguration) LogInterval

func (m *MetricsConfiguration) LogInterval() time.Duration

func (*MetricsConfiguration) ScrapeInterval

func (m *MetricsConfiguration) ScrapeInterval() time.Duration

type MetricsFilesConfig

type MetricsFilesConfig struct {
	Default        string
	Custom         []string
	ScrapeInterval *time.Duration `yaml:"scrapeInterval"`
}

type OCIVault

type OCIVault struct {
	ID             string `yaml:"id"`
	UsernameSecret string `yaml:"usernameSecret"`
	PasswordSecret string `yaml:"passwordSecret"`
}

type ScrapeContext

type ScrapeContext struct {
}

type ScrapeResult

type ScrapeResult struct {
	Err         error
	Metric      Metric
	ScrapeStart time.Time
}

ScrapResult is container structure for error handling

type VaultConfig

type VaultConfig struct {
	// OCI if present, OCI vault will be used to load username and/or password.
	OCI *OCIVault `yaml:"oci"`
	// Azure if present, Azure vault will be used to load username and/or password.
	Azure *AZVault `yaml:"azure"`
}

Jump to

Keyboard shortcuts

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