Documentation ¶
Overview ¶
Package promredis exports pool stats of go-redis/redis as prometheus metrics.
Example ¶
c := redis.NewClient(&redis.Options{ Addr: "localhost:6379", }) if err := prometheus.Register(promredis.NewPoolStatsCollector(c)); err != nil { panic(err) } go func() { http.ListenAndServe(":8080", promhttp.Handler()) }() time.Sleep(1 * time.Second) resp, err := http.Get("http://localhost:8080") if err != nil { panic(err) } defer resp.Body.Close() s := bufio.NewScanner(resp.Body) for s.Scan() { line := s.Text() if strings.Contains(line, "redis") { fmt.Println(line) } }
Output: # HELP go_redis_pool_stats_hits Number of times free connection was found in the pool. # TYPE go_redis_pool_stats_hits gauge go_redis_pool_stats_hits 0 # HELP go_redis_pool_stats_idle_conns Number of idle connections in the pool. # TYPE go_redis_pool_stats_idle_conns gauge go_redis_pool_stats_idle_conns 0 # HELP go_redis_pool_stats_misses Number of times free connection was NOT found in the pool. # TYPE go_redis_pool_stats_misses gauge go_redis_pool_stats_misses 0 # HELP go_redis_pool_stats_stale_conns Number of stale connections removed from the pool. # TYPE go_redis_pool_stats_stale_conns gauge go_redis_pool_stats_stale_conns 0 # HELP go_redis_pool_stats_timeouts Number of times a wait timeout occurred. # TYPE go_redis_pool_stats_timeouts gauge go_redis_pool_stats_timeouts 0 # HELP go_redis_pool_stats_total_conns Number of total connections in the pool. # TYPE go_redis_pool_stats_total_conns gauge go_redis_pool_stats_total_conns 0
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPoolStatsCollector ¶
func NewPoolStatsCollector(client PoolStatsClient) prometheus.Collector
NewPoolStatsCollector returns a new collector implements prometheus.Collector.
Types ¶
type PoolStatsClient ¶
type PoolStatsClient interface {
PoolStats() *redis.PoolStats
}
PoolStatsClient describes a getter for *redis.PoolStats.
Click to show internal directories.
Click to hide internal directories.