mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:22:13 +08:00
Chore: Add username option for redis remote cache (#101787)
* Chore: Add username option for redis remote cache (cherry picked from commit 25e28dc85e646e8cb7ab9ab582de8fb247b58b07) * Chore: Update docs and config with sample Redis conn with user+pass --------- Co-authored-by: Thomas Fournier <tfournier@evolves.fr>
This commit is contained in:
@ -198,7 +198,7 @@ type = database
|
||||
|
||||
# cache connectionstring options
|
||||
# database: will use Grafana primary database.
|
||||
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false`. Only addr is required. ssl may be 'true', 'false', or 'insecure'.
|
||||
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0,username=grafana,password=grafanaRocks,ssl=false`. Only addr is required. ssl may be 'true', 'false', or 'insecure'.
|
||||
# memcache: 127.0.0.1:11211
|
||||
connstr =
|
||||
|
||||
|
@ -197,7 +197,7 @@
|
||||
|
||||
# cache connectionstring options
|
||||
# database: will use Grafana primary database.
|
||||
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false`. Only addr is required. ssl may be 'true', 'false', or 'insecure'.
|
||||
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0,username=grafana,password=grafanaRocks,ssl=false`. Only addr is required. ssl may be 'true', 'false', or 'insecure'.
|
||||
# memcache: 127.0.0.1:11211
|
||||
;connstr =
|
||||
|
||||
|
@ -491,11 +491,13 @@ Leave empty when using `database` and Grafana uses the primary database.
|
||||
|
||||
##### `redis`
|
||||
|
||||
Example connection string: `addr=127.0.0.1:6379,pool_size=100,db=0,ssl=false`
|
||||
Example connection string: `addr=127.0.0.1:6379,pool_size=100,db=0,username=grafana,password=grafanaRocks,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`
|
||||
|
@ -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":
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user