Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

README.md 1.9 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # go-redis-prometheus
  2. <p>
  3. <img src="https://img.shields.io/github/workflow/status/globocom/go-redis-prometheus/Go?style=flat-square">
  4. <a href="https://github.com/globocom/go-redis-prometheus/blob/master/LICENSE">
  5. <img src="https://img.shields.io/github/license/globocom/go-buffer?color=blue&style=flat-square">
  6. </a>
  7. <img src="https://img.shields.io/github/go-mod/go-version/globocom/go-redis-prometheus?style=flat-square">
  8. <a href="https://pkg.go.dev/github.com/globocom/go-redis-prometheus">
  9. <img src="https://img.shields.io/badge/Go-reference-blue?style=flat-square">
  10. </a>
  11. </p>
  12. [go-redis](https://github.com/go-redis/redis) hook that exports Prometheus metrics.
  13. ## Installation
  14. go get github.com/globocom/go-redis-prometheus
  15. ## Usage
  16. ```golang
  17. package main
  18. import (
  19. "github.com/go-redis/redis/v8"
  20. "github.com/globocom/go-redis-prometheus"
  21. )
  22. func main() {
  23. hook := redisprom.NewHook(
  24. redisprom.WithInstanceName("cache"),
  25. redisprom.WithNamespace("my_namespace"),
  26. redisprom.WithDurationBuckets([]float64{.001, .005, .01}),
  27. )
  28. client := redis.NewClient(&redis.Options{
  29. Addr: "localhost:6379",
  30. Password: "",
  31. })
  32. client.AddHook(hook)
  33. // run redis commands...
  34. }
  35. ```
  36. ## Exported metrics
  37. The hook exports the following metrics:
  38. - Single commands (not pipelined):
  39. - Histogram of commands: `redis_single_commands_bucket{instance="main",command="get"}`
  40. - Counter of errors: `redis_single_errors{instance="main",command="get"}`
  41. - Pipelined commands:
  42. - Counter of commands: `redis_pipelined_commands{instance="main",command="get"}`
  43. - Counter of errors: `redis_pipelined_errors{instance="main",command="get"}`
  44. ## Note on pipelines
  45. It isn't possible to measure the duration of individual
  46. pipelined commands, but the duration of the pipeline itself is calculated and
  47. exported as a pseudo-command called "pipeline" under the single command metric.