thanos-query-frontend
Thanos Query Frontend - caching and query splitting layer for Thanos Query
About this chart
Thanos Query Frontend
Thanos Query Frontend is a caching and query splitting layer that sits in front of Thanos Query. It improves query performance by caching responses and splitting large queries into smaller ones.
Features
- Query Caching: In-memory or Memcached response caching
- Query Splitting: Splits long time range queries into smaller chunks
- Query Retries: Automatic retry of failed downstream queries
- Slow Query Logging: Identify problematic queries
- Response Compression: Reduce bandwidth usage
- Horizontal Scaling: Stateless design enables easy HPA
Prerequisites
- Kubernetes 1.19+
- Helm 3.2+
- Thanos Query running and accessible
Installation
helm repo add scripton-charts https://scriptonbasestar-container.github.io/sb-helm-charts
helm install thanos-query-frontend scripton-charts/thanos-query-frontend \
--set thanos.queryFrontend.downstreamUrl=http://thanos-query:10904
Configuration
Key Parameters
| Parameter | Description | Default |
|---|---|---|
replicaCount | Number of Query Frontend replicas | 1 |
thanos.queryFrontend.downstreamUrl | Thanos Query URL | http://thanos-query:10904 |
thanos.queryFrontend.splitInterval | Query range splitting interval | 24h |
thanos.queryFrontend.cache.enabled | Enable response caching | true |
thanos.queryFrontend.cache.type | Cache type (in-memory/memcached) | in-memory |
service.httpPort | HTTP service port | 10913 |
ingress.enabled | Enable ingress | false |
autoscaling.enabled | Enable HPA | false |
Cache Configuration
In-Memory Cache (Default)
thanos:
queryFrontend:
cache:
enabled: true
type: "in-memory"
inMemory:
maxSize: "250MB"
maxItems: 2048
Memcached Cache
thanos:
queryFrontend:
cache:
enabled: true
type: "memcached"
memcached:
addresses:
- memcached-0.memcached:11211
- memcached-1.memcached:11211
timeout: "500ms"
maxIdleConnections: 100
High Availability
replicaCount: 3
podDisruptionBudget:
enabled: true
minAvailable: 2
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 10
targetCPUUtilizationPercentage: 70
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: thanos-query-frontend
Architecture
+---------------------+
Grafana -------->| Query Frontend (QF) |-----> Thanos Query
+---------------------+
|
+------+------+
| Cache |
| (in-memory/ |
| memcached) |
+-------------+
Query Frontend provides:
- Caching Layer: Caches query results to reduce load on Query
- Query Splitting: Splits queries by time range (e.g., 24h chunks)
- Retry Logic: Automatically retries failed queries
Ports
| Port | Protocol | Description |
|---|---|---|
| 10902 | HTTP | Internal container port |
| 10913 | HTTP | Default service port |
Metrics
Query Frontend exposes Prometheus metrics at /metrics:
thanos_query_frontend_queries_total- Total queries processedthanos_query_frontend_split_queries_total- Queries that were splitthanos_query_frontend_cache_hits_total- Cache hit countthanos_query_frontend_cache_requests_total- Total cache requests
Enable ServiceMonitor for Prometheus Operator:
serviceMonitor:
enabled: true
interval: "30s"
Troubleshooting
Query Frontend Not Connecting to Query
-
Verify downstream URL is correct:
kubectl exec -it <pod> -- wget -qO- http://thanos-query:10904/-/ready -
Check Query Frontend logs:
kubectl logs -l app.kubernetes.io/name=thanos-query-frontend
Cache Not Working
- Verify cache configuration in logs
- Check cache metrics at
/metrics - For memcached, ensure addresses are reachable
High Latency
- Increase
splitIntervalfor fewer query splits - Scale up replicas with HPA
- Consider using memcached for larger deployments
Values Reference
See values.yaml for all configuration options.
License
BSD-3-Clause
Deploy thanos-query-frontend with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has thanos-query-frontend on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartthanos-query-frontend is pinned at v0.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply