Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ConnectionsInUseDesc = prometheus.NewDesc( metricsSubsystem+"_connections_in_use", "Number of database connections currently in use.", nil, prometheus.Labels{labelComponent: componentValue, labelVersion: api.Version}, )
ConnectionsInUseDesc is the descriptor for the connections_in_use gauge.
var ConnectionsOpenDesc = prometheus.NewDesc( metricsSubsystem+"_connections_open", "Number of open database connections.", nil, prometheus.Labels{labelComponent: componentValue, labelVersion: api.Version}, )
ConnectionsOpenDesc is the descriptor for the connections_open gauge.
var ErrorsMetric = prometheus.NewCounterVec( prometheus.CounterOpts{ Subsystem: metricsSubsystem, Name: "errors_total", Help: "Total number of database query errors.", }, []string{labelOperation, labelErrorType, labelComponent, labelVersion}, )
ErrorsMetric is a counter of database query errors.
var QueryDurationMetric = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Subsystem: metricsSubsystem, Name: "query_duration_seconds", Help: "Duration of database queries in seconds.", Buckets: queryDurationBuckets, }, []string{labelOperation, labelTable, labelComponent, labelVersion}, )
QueryDurationMetric is a histogram of database query durations in seconds.
Functions ¶
func RegisterMetrics ¶
func RegisterMetrics()
RegisterMetrics registers the database metrics with Prometheus. It is safe to call multiple times; registration happens only once.
func RegisterPlugin ¶
RegisterPlugin registers the metrics GORM callbacks on the provided *gorm.DB. It adds before/after callbacks for create, query, update, delete, and raw operations.
func RegisterPoolCollector ¶
RegisterPoolCollector creates and registers a new PoolCollector for the given database.
Types ¶
type PoolCollector ¶
type PoolCollector struct {
// contains filtered or unexported fields
}
PoolCollector implements the prometheus.Collector interface to report database connection pool statistics.
func NewPoolCollector ¶
func NewPoolCollector(db *sql.DB) *PoolCollector
NewPoolCollector creates a new PoolCollector for the given database connection.
func (*PoolCollector) Collect ¶
func (c *PoolCollector) Collect(ch chan<- prometheus.Metric)
Collect reads the current connection pool stats and sends them as metrics.
func (*PoolCollector) Describe ¶
func (c *PoolCollector) Describe(ch chan<- *prometheus.Desc)
Describe sends the descriptors for the connection pool metrics.