https://github.com/globocom/go-redis-prometheus
go-redis hook to export Prometheus metrics
https://github.com/globocom/go-redis-prometheus
go go-redis golang prometheus redis
Last synced: 4 months ago
JSON representation
go-redis hook to export Prometheus metrics
- Host: GitHub
- URL: https://github.com/globocom/go-redis-prometheus
- Owner: globocom
- License: mit
- Created: 2020-10-28T22:05:52.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-27T14:12:40.000Z (over 5 years ago)
- Last Synced: 2025-09-08T09:49:46.944Z (10 months ago)
- Topics: go, go-redis, golang, prometheus, redis
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 22
- Watchers: 10
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-redis-prometheus
[go-redis](https://github.com/go-redis/redis) hook that exports Prometheus metrics.
Also check out our lib https://github.com/globocom/go-redis-opentracing.
## Installation
go get github.com/globocom/go-redis-prometheus
## Usage
```golang
package main
import (
"github.com/go-redis/redis/v8"
"github.com/globocom/go-redis-prometheus"
)
func main() {
hook := redisprom.NewHook(
redisprom.WithInstanceName("cache"),
redisprom.WithNamespace("my_namespace"),
redisprom.WithDurationBuckets([]float64{.001, .005, .01}),
)
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
})
client.AddHook(hook)
// run redis commands...
}
```
## Exported metrics
The hook exports the following metrics:
- Single commands (not pipelined):
- Histogram of commands: `redis_single_commands_bucket{instance="main",command="get"}`
- Counter of errors: `redis_single_errors{instance="main",command="get"}`
- Pipelined commands:
- Counter of commands: `redis_pipelined_commands{instance="main",command="get"}`
- Counter of errors: `redis_pipelined_errors{instance="main",command="get"}`
## Note on pipelines
It isn't possible to measure the duration of individual
pipelined commands, but the duration of the pipeline itself is calculated and
exported as a pseudo-command called "pipeline" under the single command metric.
## API stability
The API is unstable at this point and it might change before `v1.0.0` is released.