Documentation
¶
Index ¶
- type AZVault
- type Config
- type ConnectConfig
- type Database
- type DatabaseConfig
- type Exporter
- func (e *Exporter) Collect(ch chan<- prometheus.Metric)
- func (e *Exporter) DefaultMetrics() map[string]*Metric
- func (e *Exporter) Describe(ch chan<- *prometheus.Desc)
- func (e *Exporter) GetDBs() []*Database
- func (e *Exporter) RunScheduledScrapes(ctx context.Context)
- func (e *Exporter) ScrapeMetric(d *Database, ch chan<- prometheus.Metric, m *Metric) error
- type HashiCorpVault
- type LoggingConfig
- type Metric
- type MetricCacheRecord
- type Metrics
- type MetricsCache
- func (c *MetricsCache) CacheAndSend(ch chan<- prometheus.Metric, m *Metric, metric prometheus.Metric)
- func (c *MetricsCache) GetLastScraped(m *Metric) *time.Time
- func (c *MetricsCache) Reset(m *Metric)
- func (c *MetricsCache) SendAll(ch chan<- prometheus.Metric, m *Metric)
- func (c *MetricsCache) SetLastScraped(m *Metric, tick *time.Time)
- type MetricsConfiguration
- type MetricsFilesConfig
- type OCIVault
- type ScrapeContext
- type ScrapeResult
- type VaultConfig
- type WebConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ConfigFile string
User string
Password string
ConnectString string
DbRole string
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 string
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
Config DatabaseConfig
// MetricsCache holds computed metrics for a database, so these metrics are available on each scrape.
// Given a metric's scrape configuration, it may not be computed on the same interval as other metrics.
MetricsCache *MetricsCache
Valid bool
}
func NewDatabase ¶
func NewDatabase(logger *slog.Logger, dbname string, dbconfig DatabaseConfig) *Database
func (*Database) UpMetric ¶
func (d *Database) UpMetric(exporterLabels map[string]string) prometheus.Metric
func (*Database) WarmupConnectionPool ¶
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
PasswordFile string `yaml:"passwordFile"`
URL string `yaml:"url"`
ConnectConfig `yaml:",inline"`
Vault *VaultConfig `yaml:"vault,omitempty"`
Labels map[string]string `yaml:"labels,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 ¶
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) RunScheduledScrapes ¶
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 ¶
ScrapeMetric is an interface method to call scrapeGenericValues using Metric struct values
type HashiCorpVault ¶
type HashiCorpVault struct {
Socket string `yaml:"proxySocket"`
MountType string `yaml:"mountType"`
MountName string `yaml:"mountName"`
SecretPath string `yaml:"secretPath"`
UsernameAttr string `yaml:"usernameAttribute"`
PasswordAttr string `yaml:"passwordAttribute"`
AsProxy string `yaml:"useAsProxyFor"`
// contains filtered or unexported fields
}
func (HashiCorpVault) GetPasswordAttr ¶
func (h HashiCorpVault) GetPasswordAttr() string
func (HashiCorpVault) GetUsernameAttr ¶
func (h HashiCorpVault) GetUsernameAttr() string
type LoggingConfig ¶
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
func (*Metric) IsEnabledForDatabase ¶
IsEnabledForDatabase checks if a metric is enabled for a database. If the m.Databases slice is nil, the metric is enabled for all databases. If the m.Databases slice contains the database name, the metric is enabled for that database. Otherwise, the metric is disabled for all databases (non-nil, empty m.Databases slice)
type MetricCacheRecord ¶
type MetricCacheRecord struct {
// PrometheusMetrics stores cached prometheus metric values.
// Used when custom scrape intervals are used, and the metric must be returned to the collector, but not scraped.
PrometheusMetrics []prometheus.Metric
// LastScraped is the collector tick time when the metric was last computed.
LastScraped *time.Time
}
MetricCacheRecord stores metadata associated with a given Metric As one metric may have multiple prometheus.Metric representations, These are cached as a map value.
type Metrics ¶
type Metrics struct {
Metric []*Metric `yaml:"metrics"`
}
Metrics is a container structure for prometheus metrics
type MetricsCache ¶
type MetricsCache struct {
// contains filtered or unexported fields
}
func NewMetricsCache ¶
func NewMetricsCache(metrics map[string]*Metric) *MetricsCache
func (*MetricsCache) CacheAndSend ¶
func (c *MetricsCache) CacheAndSend(ch chan<- prometheus.Metric, m *Metric, metric prometheus.Metric)
func (*MetricsCache) GetLastScraped ¶
func (c *MetricsCache) GetLastScraped(m *Metric) *time.Time
func (*MetricsCache) Reset ¶
func (c *MetricsCache) Reset(m *Metric)
func (*MetricsCache) SendAll ¶
func (c *MetricsCache) SendAll(ch chan<- prometheus.Metric, m *Metric)
func (*MetricsCache) SetLastScraped ¶
func (c *MetricsCache) SetLastScraped(m *Metric, tick *time.Time)
type MetricsConfiguration ¶
type MetricsConfiguration struct {
ListenAddress string `yaml:"listenAddress"`
MetricsPath string `yaml:"metricsPath"`
Databases map[string]DatabaseConfig `yaml:"databases"`
Metrics MetricsFilesConfig `yaml:"metrics"`
Logging LoggingConfig `yaml:"log"`
Web WebConfig `yaml:"web"`
}
func LoadMetricsConfiguration ¶
func LoadMetricsConfiguration(logger *slog.Logger, cfg *Config, path string, flags *web.FlagConfig) (*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 ScrapeContext ¶
type ScrapeContext struct {
}
type ScrapeResult ¶
ScrapeResult 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"`
// HashiCorp Vault if present. HashiCorp Vault will be used to fetch database credentials.
HashiCorp *HashiCorpVault `yaml:"hashicorp"`
}