diff --git a/docs/sources/setup-grafana/configure-grafana/_index.md b/docs/sources/setup-grafana/configure-grafana/_index.md index cbd476fef97..f48fd2a1019 100644 --- a/docs/sources/setup-grafana/configure-grafana/_index.md +++ b/docs/sources/setup-grafana/configure-grafana/_index.md @@ -456,6 +456,8 @@ Example connstr: `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false` - `addr` is the host `:` port of the redis server. - `pool_size` (optional) is the number of underlying connections that can be made to redis. - `db` (optional) is the number identifier of the redis database you want to use. +- `username` (optional) is the connection identifier to authenticate the current connection. +- `password` (optional) is the connection secret to authenticate the current connection. - `ssl` (optional) is if SSL should be used to connect to redis server. The value may be `true`, `false`, or `insecure`. Setting the value to `insecure` skips verification of the certificate chain and hostname when making the connection. #### memcache diff --git a/pkg/infra/remotecache/redis_storage.go b/pkg/infra/remotecache/redis_storage.go index 84c9a081f81..de10aa88eb3 100644 --- a/pkg/infra/remotecache/redis_storage.go +++ b/pkg/infra/remotecache/redis_storage.go @@ -39,6 +39,8 @@ func parseRedisConnStr(connStr string) (*redis.Options, error) { switch connKey { case "addr": options.Addr = connVal + case "username": + options.Username = connVal case "password": options.Password = connVal case "db": diff --git a/pkg/infra/remotecache/redis_storage_test.go b/pkg/infra/remotecache/redis_storage_test.go index 32138431f21..6f796bd5ab6 100644 --- a/pkg/infra/remotecache/redis_storage_test.go +++ b/pkg/infra/remotecache/redis_storage_test.go @@ -16,11 +16,12 @@ func Test_parseRedisConnStr(t *testing.T) { ShouldErr bool }{ "all redis options should parse": { - "addr=127.0.0.1:6379,pool_size=100,db=1,password=grafanaRocks,ssl=false", + "addr=127.0.0.1:6379,pool_size=100,db=1,username=grafana,password=grafanaRocks,ssl=false", &redis.Options{ Addr: "127.0.0.1:6379", PoolSize: 100, DB: 1, + Username: "grafana", Password: "grafanaRocks", Network: "tcp", TLSConfig: nil,