Add support for username to redis cache configuration (#7270)

**What this PR does / why we need it**:

Add support for username to redis cache configuration

**Which issue(s) this PR fixes**:
Fixes #<issue number>

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the `CONTRIBUTING.md` guide
- [x] Documentation added
- [ ] Tests updated
- [x] `CHANGELOG.md` updated
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`

Signed-off-by: Wilfried Roset <wilfriedroset@users.noreply.github.com>
pull/7320/head
wilfriedroset 3 years ago committed by GitHub
parent 54f16c008a
commit 8886800bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 4
      docs/sources/configuration/_index.md
  3. 3
      pkg/storage/chunk/cache/redis_client.go

@ -22,6 +22,7 @@
* [5406](https://github.com/grafana/loki/pull/5406) **ctovena**: Revise the configuration parameters that configure the usage report to grafana.com.
* [7264](https://github.com/grafana/loki/pull/7264) **bboreham**: Chunks: decode varints directly from byte buffer, for speed.
* [7263](https://github.com/grafana/loki/pull/7263) **bboreham**: Dependencies: klauspost/compress package to v1.15.11; improves performance.
* [7270](https://github.com/grafana/loki/pull/7270) **wilfriedroset**: Add support for `username` to redis cache configuration.
##### Fixes
* [7288](https://github.com/grafana/loki/pull/7288) **ssncferreira**: Fix query mapping in AST mapper `rangemapper` to support the new `VectorExpr` expression.

@ -1959,6 +1959,10 @@ redis:
# CLI flag: -<prefix>.redis.pool-size
[pool_size: <int> | default = 0]
# Username to use when connecting to redis.
# CLI flag: -<prefix>.redis.username
[username: <string>]
# Password to use when connecting to redis.
# CLI flag: -<prefix>.redis.password
[password: <string>]

@ -23,6 +23,7 @@ type RedisConfig struct {
Expiration time.Duration `yaml:"expiration"`
DB int `yaml:"db"`
PoolSize int `yaml:"pool_size"`
Username string `yaml:"username"`
Password flagext.Secret `yaml:"password"`
EnableTLS bool `yaml:"tls_enabled"`
InsecureSkipVerify bool `yaml:"tls_insecure_skip_verify"`
@ -38,6 +39,7 @@ func (cfg *RedisConfig) RegisterFlagsWithPrefix(prefix, description string, f *f
f.DurationVar(&cfg.Expiration, prefix+"redis.expiration", 0, description+"How long keys stay in the redis.")
f.IntVar(&cfg.DB, prefix+"redis.db", 0, description+"Database index.")
f.IntVar(&cfg.PoolSize, prefix+"redis.pool-size", 0, description+"Maximum number of connections in the pool.")
f.StringVar(&cfg.Username, prefix+"redis.username", "", description+"Username to use when connecting to redis.")
f.Var(&cfg.Password, prefix+"redis.password", description+"Password to use when connecting to redis.")
f.BoolVar(&cfg.EnableTLS, prefix+"redis.tls-enabled", false, description+"Enable connecting to redis with TLS.")
f.BoolVar(&cfg.InsecureSkipVerify, prefix+"redis.tls-insecure-skip-verify", false, description+"Skip validating server certificate.")
@ -74,6 +76,7 @@ func NewRedisClient(cfg *RedisConfig) (*RedisClient, error) {
opt := &redis.UniversalOptions{
Addrs: endpoints,
MasterName: cfg.MasterName,
Username: cfg.Username,
Password: cfg.Password.String(),
DB: cfg.DB,
PoolSize: cfg.PoolSize,

Loading…
Cancel
Save