Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
DBName string // use DBName as metrics label
RefreshInterval uint32 // refresh metrics interval.
PushAddr string // prometheus pusher address
PushUser string // prometheus pusher basic auth user
PushPassword string // prometheus pusher basic auth password
StartServer bool // if true, create http server to expose metrics
HTTPServerPort uint32 // http server port
MetricsCollector []MetricsCollector // collector
Labels map[string]string // metrics labels
}
type DBStats ¶
type DBStats struct {
MaxOpenConnections prometheus.Gauge // Maximum number of open connections to the database.
// Pool status
OpenConnections prometheus.Gauge // The number of established connections both in use and idle.
InUse prometheus.Gauge // The number of connections currently in use.
Idle prometheus.Gauge // The number of idle connections.
// Counters
WaitCount prometheus.Gauge // The total number of connections waited for.
WaitDuration prometheus.Gauge // The total time blocked waiting for a new connection.
MaxIdleClosed prometheus.Gauge // The total number of connections closed due to SetMaxIdleConns.
MaxLifetimeClosed prometheus.Gauge // The total number of connections closed due to SetConnMaxLifetime.
MaxIdleTimeClosed prometheus.Gauge // The total number of connections closed due to SetConnMaxIdleTime.
}
func (*DBStats) Collectors ¶
func (stats *DBStats) Collectors() (collector []prometheus.Collector)
get collector in stats
type MetricsCollector ¶
type MetricsCollector interface {
Metrics(*Prometheus) []prometheus.Collector
}
type MySQL ¶
type MySQL struct {
Prefix string
Interval uint32
VariableNames []string
// contains filtered or unexported fields
}
func (*MySQL) Metrics ¶
func (m *MySQL) Metrics(p *Prometheus) []prometheus.Collector
type Postgres ¶
type Postgres struct {
Prefix string
Interval uint32
VariableNames []string
// contains filtered or unexported fields
}
Posgres metrics providers. Metrics is being contructed from Sturct labels: Type translation:
int64 - Counter, Gauge time.Time - Gauge string - Label on the metrics
Example:
DatName string `gorm:"column:datname" type:"label" help:"Name of current database"` SizeBytes int64 `gorm:"column:size_bytes" type:"gauge" help:"Size of database in bytes"`
will be translated to: gorm_dbstats_size_bytes{datname="test"} 123456789
func (*Postgres) Metrics ¶
func (m *Postgres) Metrics(p *Prometheus) []prometheus.Collector
type Prometheus ¶
type Prometheus struct {
*gorm.DB
*DBStats
*Config
Labels map[string]string
Collectors []prometheus.Collector
// contains filtered or unexported fields
}
func New ¶
func New(config Config) *Prometheus
func (*Prometheus) Initialize ¶
func (p *Prometheus) Initialize(db *gorm.DB) error
func (*Prometheus) Name ¶
func (p *Prometheus) Name() string
Click to show internal directories.
Click to hide internal directories.