diff --git a/CHANGELOG.md b/CHANGELOG.md index b283010275d..468faf89ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * [FEATURE] The distributor can now drop labels from samples (similar to the removal of the replica label for HA ingestion) per user via the `distributor.drop-label` flag. #1726 * [FEATURE] Added `global` ingestion rate limiter strategy. Deprecated `-distributor.limiter-reload-period` flag. #1766 * [FEATURE] Added support for Microsoft Azure blob storage to be used for storing chunk data. #1913 +* [ENHANCEMENT] Added `password` and `enable_tls` options to redis cache configuration. Enables usage of Microsoft Azure Cache for Redis service. * [BUGFIX] Fixed unnecessary CAS operations done by the HA tracker when the jitter is enabled. #1861 ## 0.4.0 / 2019-12-02 diff --git a/pkg/chunk/cache/redis_cache.go b/pkg/chunk/cache/redis_cache.go index 43e14dba3fc..c6cbc662006 100644 --- a/pkg/chunk/cache/redis_cache.go +++ b/pkg/chunk/cache/redis_cache.go @@ -25,6 +25,8 @@ type RedisConfig struct { Expiration time.Duration `yaml:"expiration,omitempty"` MaxIdleConns int `yaml:"max_idle_conns,omitempty"` MaxActiveConns int `yaml:"max_active_conns,omitempty"` + Password string `yaml:"password"` + EnableTLS bool `yaml:"enable_tls"` } // RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet @@ -34,6 +36,8 @@ 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.MaxIdleConns, prefix+"redis.max-idle-conns", 80, description+"Maximum number of idle connections in pool.") f.IntVar(&cfg.MaxActiveConns, prefix+"redis.max-active-conns", 0, description+"Maximum number of active connections in pool.") + f.StringVar(&cfg.Password, prefix+"redis.password", "", description+"Password to use when connecting to redis.") + f.BoolVar(&cfg.EnableTLS, prefix+"redis.enable-tls", false, description+"Enables connecting to redis with TLS.") } // NewRedisCache creates a new RedisCache @@ -44,7 +48,15 @@ func NewRedisCache(cfg RedisConfig, name string, pool *redis.Pool) *RedisCache { MaxIdle: cfg.MaxIdleConns, MaxActive: cfg.MaxActiveConns, Dial: func() (redis.Conn, error) { - c, err := redis.Dial("tcp", cfg.Endpoint) + options := make([]redis.DialOption, 0, 2) + if cfg.EnableTLS { + options = append(options, redis.DialUseTLS(true)) + } + if cfg.Password != "" { + options = append(options, redis.DialPassword(cfg.Password)) + } + + c, err := redis.Dial("tcp", cfg.Endpoint, options...) if err != nil { return nil, err }