Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new flags and memcached support to query frontend #166

Merged
merged 3 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions all.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ local qf = t.queryFrontend(commonConfig {
maxRetries: 10,
logQueriesLongerThan: '10s',
serviceMonitor: true,
queryRangeCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERCIVE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERCIVE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
labelsCache: {
type: 'memcached',
config+: {
// NOTICE: <MEMCACHED_SERCIVE> is a placeholder to generate examples.
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses: ['dnssrv+_client._tcp.<MEMCACHED_SERCIVE>.%s.svc.cluster.local' % commonConfig.namespace],
},
},
});

{ ['thanos-bucket-' + name]: b[name] for name in std.objectFields(b) } +
Expand Down
28 changes: 24 additions & 4 deletions examples/all/manifests/thanos-query-frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,34 @@ spec:
- --http-address=0.0.0.0:9090
- --query-frontend.downstream-url=http://thanos-query.thanos.svc.cluster.local.:9090
- --query-range.split-interval=12h
- --labels.split-interval=12h
- --query-range.max-retries-per-request=10
- --labels.max-retries-per-request=10
- --query-frontend.log-queries-longer-than=10s
- |-
--query-range.response-cache-config="config":
"max_size": "0"
"max_size_items": 2048
"validity": "6h"
"type": "in-memory"
"addresses":
- "dnssrv+_client._tcp.<MEMCACHED_SERCIVE>.thanos.svc.cluster.local"
"dns_provider_update_interval": "10s"
"max_async_buffer_size": 10000
"max_async_concurrency": 20
"max_get_multi_batch_size": 0
"max_get_multi_concurrency": 100
"max_idle_connections": 100
"timeout": "500ms"
"type": "memcached"
- |-
--labels.response-cache-config="config":
"addresses":
- "dnssrv+_client._tcp.<MEMCACHED_SERCIVE>.thanos.svc.cluster.local"
"dns_provider_update_interval": "10s"
"max_async_buffer_size": 10000
"max_async_concurrency": 20
"max_get_multi_batch_size": 0
"max_get_multi_concurrency": 100
"max_idle_connections": 100
"timeout": "500ms"
"type": "memcached"
image: quay.io/thanos/thanos:v0.16.0
livenessProbe:
failureThreshold: 4
Expand Down
61 changes: 50 additions & 11 deletions jsonnet/kube-thanos/kube-thanos-query-frontend.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,37 @@ local defaults = {
splitInterval: '24h',
maxRetries: 5,
logQueriesLongerThan: '0',
fifoCache: {
max_size: '0', // Don't limit maximum item size.
max_size_items: 2048,
validity: '6h',
fifoCache+:: {
config+: {
max_size: '0', // Don't limit maximum item size.
max_size_items: 2048,
validity: '6h',
}
},
queryRangeCache: {},
labelsCache: {},
logLevel: 'info',
resources: {},
serviceMonitor: false,
ports: {
http: 9090,
},

memcachedDefaults+:: {
config+: {
// List of memcached addresses, that will get resolved with the DNS service discovery provider.
// For DNS service discovery reference https://thanos.io/service-discovery.md/#dns-service-discovery
addresses+: error 'must provide memcached addresses',
timeout: '500ms',
max_idle_connections: 100,
max_async_concurrency: 20,
max_async_buffer_size: 10000,
max_get_multi_concurrency: 100,
max_get_multi_batch_size: 0,
dns_provider_update_interval: '10s',
},
},

commonLabels:: {
'app.kubernetes.io/name': 'thanos-query-frontend',
'app.kubernetes.io/instance': defaults.name,
Expand All @@ -42,12 +61,25 @@ function(params) {
local tqf = self,

// Combine the defaults and the passed params to make the component's config.
config:: defaults + params,
config:: defaults + params + {
queryRangeCache+:
if std.objectHas(params, 'queryRangeCache') && params.queryRangeCache.type == 'memcached' then
defaults.memcachedDefaults + params.queryRangeCache
else if std.objectHas(params, 'queryRangeCache') && params.queryRangeCache.type == 'in-memory' then
defaults.fifoCache + params.queryRangeCache
else {},
labelsCache+:
if std.objectHas(params, 'labelsCache') && params.labelsCache.type == 'memcached' then
defaults.memcachedDefaults + params.labelsCache
else if std.objectHas(params, 'labelsCache') && params.labelsCache.type == 'in-memory' then
defaults.fifoCache + params.labelsCache
else {},
},
// Safety checks for combined config of defaults and params
assert std.isNumber(tqf.config.replicas) && tqf.config.replicas >= 0 : 'thanos query frontend replicas has to be number >= 0',
assert std.isObject(tqf.config.resources),
assert std.isBoolean(tqf.config.serviceMonitor),
assert std.isNumber(tqf.config.maxRetries),
assert std.isNumber(tqf.config.maxRetries) && tqf.config.maxRetries >= 0 : 'thanos query frontend maxRetries has to be number >= 0',

service:
{
Expand Down Expand Up @@ -84,14 +116,21 @@ function(params) {
'--http-address=0.0.0.0:%d' % tqf.config.ports.http,
'--query-frontend.downstream-url=%s' % tqf.config.downstreamURL,
'--query-range.split-interval=%s' % tqf.config.splitInterval,
'--labels.split-interval=%s' % tqf.config.splitInterval,
'--query-range.max-retries-per-request=%d' % tqf.config.maxRetries,
'--labels.max-retries-per-request=%d' % tqf.config.maxRetries,
'--query-frontend.log-queries-longer-than=%s' % tqf.config.logQueriesLongerThan,
] + (
if std.length(tqf.config.fifoCache) > 0 then [
'--query-range.response-cache-config=' + std.manifestYamlDoc({
type: 'in-memory',
config: tqf.config.fifoCache,
}),
if std.length(tqf.config.queryRangeCache) > 0 then [
'--query-range.response-cache-config=' + std.manifestYamlDoc(
tqf.config.queryRangeCache
),
] else []
) + (
if std.length(tqf.config.labelsCache) > 0 then [
'--labels.response-cache-config=' + std.manifestYamlDoc(
tqf.config.labelsCache
),
] else []
),
ports: [
Expand Down