Fusl 53842ced4b | 2 роки тому | |
---|---|---|
.. | ||
.gitignore | 2 роки тому | |
LICENSE | 2 роки тому | |
Makefile | 2 роки тому | |
README.md | 2 роки тому | |
hook.go | 2 роки тому | |
options.go | 2 роки тому |
go-redis hook that exports Prometheus metrics.
go get github.com/globocom/go-redis-prometheus
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...
}
The hook exports the following metrics:
redis_single_commands_bucket{instance="main",command="get"}
redis_single_errors{instance="main",command="get"}
redis_pipelined_commands{instance="main",command="get"}
redis_pipelined_errors{instance="main",command="get"}
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.