redisprometheus

package module
v9.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: BSD-2-Clause Imports: 2 Imported by: 0

README

Prometheus Metric Collector

This package implements a prometheus.Collector for collecting metrics about the connection pool used by the various redis clients. Supported clients are redis.Client, redis.ClusterClient, redis.Ring and redis.UniversalClient.

Example
client := redis.NewClient(options)
collector := redisprometheus.NewCollector(namespace, subsystem, client)
prometheus.MustRegister(collector)
Metrics
Name Type Description
pool_hit_total Counter metric number of times a connection was found in the pool
pool_miss_total Counter metric number of times a connection was not found in the pool
pool_timeout_total Counter metric number of times a timeout occurred when getting a connection from the pool
pool_conn_total_current Gauge metric current number of connections in the pool
pool_conn_idle_current Gauge metric current number of idle connections in the pool
pool_conn_stale_total Counter metric number of times a connection was removed from the pool because it was stale

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector collects statistics from a redis client. It implements the prometheus.Collector interface.

func NewCollector

func NewCollector(namespace, subsystem string, getter StatGetter) *Collector

NewCollector returns a new Collector based on the provided StatGetter. The given namespace and subsystem are used to build the fully qualified metric name, i.e. "{namespace}_{subsystem}_{metric}". The provided metrics are:

  • pool_hit_total
  • pool_miss_total
  • pool_timeout_total
  • pool_conn_total_current
  • pool_conn_idle_current
  • pool_conn_stale_total

func (*Collector) Collect

func (s *Collector) Collect(metrics chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Collector) Describe

func (s *Collector) Describe(descs chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type StatGetter

type StatGetter interface {
	PoolStats() *redis.PoolStats
}

StatGetter provides a method to get pool statistics.

Jump to

Keyboard shortcuts

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