thanos-query

by ScriptonBasestar

Helm chartv0.3.0App 0.37.2

Thanos Query - PromQL query layer for distributed Prometheus with deduplication

About this chart

Thanos Query Helm Chart

Thanos Query provides a global query view across multiple Prometheus instances or other Thanos Store API endpoints with PromQL compatibility and deduplication.

Overview

Thanos Query implements the Prometheus HTTP v1 API and can query data from any component implementing the Store API:

  • Thanos Sidecar (Prometheus sidecar)
  • Thanos Store (object storage gateway)
  • Thanos Receive (remote write receiver)
  • Thanos Ruler (rule evaluation results)
  • Other Thanos Query instances (federation)

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.2+

Installation

helm repo add scripton-charts https://scriptonbasestar-container.github.io/sb-helm-charts
helm install thanos-query scripton-charts/thanos-query

Configuration

Store Endpoints

Configure Store API endpoints to query:

thanos:
  stores:
    # DNS service discovery (recommended)
    - dnssrv+_grpc._tcp.thanos-sidecar.default.svc.cluster.local
    - dnssrv+_grpc._tcp.thanos-store.default.svc.cluster.local
    # Static endpoints
    - thanos-receive:10901

Deduplication

Configure replica labels for deduplication:

thanos:
  query:
    replicaLabels:
      - replica
      - prometheus_replica

Query Settings

thanos:
  query:
    timeout: "2m"
    maxConcurrent: 20
    partialResponse: "warn"  # warn, abort
    autoDownsampling: true

Parameters

ParameterDescriptionDefault
replicaCountNumber of Query replicas1
image.repositoryImage repositoryquay.io/thanos/thanos
image.tagImage tag"" (uses appVersion)
thanos.storesStore API endpoints[]
thanos.query.replicaLabelsLabels for deduplication[replica, prometheus_replica]
thanos.query.timeoutQuery timeout2m
thanos.query.maxConcurrentMax concurrent queries20
service.httpPortHTTP service port10904
service.grpcPortgRPC service port10903
ingress.enabledEnable ingressfalse
autoscaling.enabledEnable HPAfalse

Grafana Integration

Add Thanos Query as a Prometheus data source in Grafana:

apiVersion: 1
datasources:
  - name: Thanos
    type: prometheus
    url: http://thanos-query:10904
    access: proxy

High Availability

For HA deployments:

replicaCount: 3

podDisruptionBudget:
  enabled: true
  minAvailable: 2

autoscaling:
  enabled: true
  minReplicas: 3
  maxReplicas: 10

Troubleshooting

Check connected stores

kubectl port-forward svc/thanos-query 10904:10904
curl http://localhost:10904/api/v1/stores

Check query health

curl http://localhost:10904/-/ready
curl http://localhost:10904/-/healthy

License

BSD-3-Clause

Deploy thanos-query 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 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartthanos-query is pinned at v0.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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