diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b849f9b1..5cc472138c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6605](https://github.com/thanos-io/thanos/pull/6605) Query Frontend: Support vertical sharding binary expression with metric name when no matching labels specified. - [#6308](https://github.com/thanos-io/thanos/pull/6308) Ruler: Support configuration flag that allows customizing template for alert message. - [#6760](https://github.com/thanos-io/thanos/pull/6760) Query Frontend: Added TLS support in `--query-frontend.downstream-tripper-config` and `--query-frontend.downstream-tripper-config-file` +- [#7004](https://github.com/thanos-io/thanos/pull/7004) Query Frontend: Support documented auto discovery for memcached - [#6749](https://github.com/thanos-io/thanos/pull/6749) Store Gateway: Added `thanos_store_index_cache_fetch_duration_seconds` histogram for tracking latency of fetching data from index cache. - [#6690](https://github.com/thanos-io/thanos/pull/6690) Store: *breaking :warning:* Add tenant label to relevant exported metrics. Note that this change may cause some pre-existing dashboard queries to be incorrect due to the added label. - [#6530](https://github.com/thanos-io/thanos/pull/6530) / [#6690](https://github.com/thanos-io/thanos/pull/6690) Query: Add command line arguments for configuring tenants and forward tenant information to Store Gateway. diff --git a/internal/cortex/chunk/cache/memcached_client.go b/internal/cortex/chunk/cache/memcached_client.go index a2f7b6b88b..9455f76400 100644 --- a/internal/cortex/chunk/cache/memcached_client.go +++ b/internal/cortex/chunk/cache/memcached_client.go @@ -19,7 +19,10 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/sony/gobreaker" + "github.com/thanos-io/thanos/pkg/clientconfig" "github.com/thanos-io/thanos/pkg/discovery/dns" + memcacheDiscovery "github.com/thanos-io/thanos/pkg/discovery/memcache" + "github.com/thanos-io/thanos/pkg/extprom" ) // MemcachedClient interface exists for mocking memcacheClient. @@ -45,7 +48,7 @@ type memcachedClient struct { service string addresses []string - provider *dns.Provider + provider clientconfig.AddressProvider cbs map[ /*address*/ string]*gobreaker.CircuitBreaker cbFailures uint @@ -68,6 +71,7 @@ type MemcachedClientConfig struct { Host string `yaml:"host"` Service string `yaml:"service"` Addresses string `yaml:"addresses"` // EXPERIMENTAL. + AutoDiscovery bool `yaml:"auto_discovery"` Timeout time.Duration `yaml:"timeout"` MaxIdleConns int `yaml:"max_idle_conns"` MaxItemSize int `yaml:"max_item_size"` @@ -107,9 +111,19 @@ func NewMemcachedClient(cfg MemcachedClientConfig, name string, r prometheus.Reg client.Timeout = cfg.Timeout client.MaxIdleConns = cfg.MaxIdleConns - dnsProviderRegisterer := prometheus.WrapRegistererWithPrefix("cortex_", prometheus.WrapRegistererWith(prometheus.Labels{ - "name": name, - }, r)) + var addressProvider clientconfig.AddressProvider + if cfg.AutoDiscovery { + addressProvider = memcacheDiscovery.NewProvider( + logger, + extprom.WrapRegistererWithPrefix("cortex_", r), + cfg.Timeout, + ) + } else { + dnsProviderRegisterer := prometheus.WrapRegistererWithPrefix("cortex_", prometheus.WrapRegistererWith(prometheus.Labels{ + "name": name, + }, r)) + addressProvider = dns.NewProvider(logger, dnsProviderRegisterer, dns.GolangResolverType) + } newClient := &memcachedClient{ name: name, @@ -118,7 +132,7 @@ func NewMemcachedClient(cfg MemcachedClientConfig, name string, r prometheus.Reg hostname: cfg.Host, service: cfg.Service, logger: logger, - provider: dns.NewProvider(logger, dnsProviderRegisterer, dns.GolangResolverType), + provider: addressProvider, cbs: make(map[string]*gobreaker.CircuitBreaker), cbFailures: cfg.CBFailures, cbInterval: cfg.CBInterval, diff --git a/pkg/queryfrontend/config.go b/pkg/queryfrontend/config.go index ba45f80d9e..4b915764c5 100644 --- a/pkg/queryfrontend/config.go +++ b/pkg/queryfrontend/config.go @@ -142,6 +142,7 @@ func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Con Timeout: config.Memcached.Timeout, MaxIdleConns: config.Memcached.MaxIdleConnections, Addresses: strings.Join(config.Memcached.Addresses, ","), + AutoDiscovery: config.Memcached.AutoDiscovery, UpdateInterval: config.Memcached.DNSProviderUpdateInterval, MaxItemSize: int(config.Memcached.MaxItemSize), },