This article is available in French.
1. Thanos Query #
Le point d'entrée PromQL.
Lancer Query #
Thanos Query expose l'API HTTP de Prometheus : Grafana s'y connecte comme à un Prometheus classique. À chaque requête, il interroge en parallèle tous ses endpoints StoreAPI (sidecars, Store Gateway, Receive, autres Query) et fusionne les résultats.
thanos query \
--http-address=0.0.0.0:10902 \
--grpc-address=0.0.0.0:10903 \
--endpoint=sidecar-a:10901 \
--endpoint=sidecar-b:10901 \
--endpoint=store:10901 \
--query.replica-label=replica \
--query.auto-downsampling# Docker Compose (extrait)
query:
image: quay.io/thanos/thanos:latest
command:
- query
- --http-address=0.0.0.0:10902
- --endpoint=sidecar:10901
- --endpoint=store:10901
- --query.replica-label=replica
ports: ["10902:10902"]2. La déduplication #
Haute disponibilité sans doublons.
Replica label #
replica est retiré pour comparer les séries.Thanos Query traite comme équivalentes les séries qui ne diffèrent que par le --query.replica-label. Si l'une des deux a un trou (redémarrage, panne), l'autre le comble : c'est ce qui donne la haute disponibilité des données.
# Dans l'interface Query : activer/désactiver "Use Deduplication" et comparer
count(up{job="node"}) # avec dédup : 1 série par instance
# sans dédup : 2 séries (replica=A et replica=B)
# Plusieurs labels de réplicas (par ex. Prometheus + Operator)
thanos query --query.replica-label=replica --query.replica-label=prometheus_replica3. Exploiter l'interface et l'API #
Stores, requêtes et diagnostic.
Interface web et API #
# http://localhost:10902 -> Graph, Stores (état de chaque endpoint), Alerts, Config
# API compatible Prometheus
curl -s 'http://localhost:10902/api/v1/query?query=up' | jq '.data.result | length'
curl -s 'http://localhost:10902/api/v1/stores' | jq '.data | keys'
# Réponse partielle autorisée si un store est indisponible (par défaut) ou refusée
curl -s 'http://localhost:10902/api/v1/query?query=up&partial_response=false'
# Choisir la résolution (downsampling) : max_source_resolution en ms
curl -s 'http://localhost:10902/api/v1/query_range?query=up&start=...&end=...&step=3600&max_source_resolution=3600000'Erreur Courante : Une partial response peut masquer l'absence d'un cluster entier : surveillez la page Stores et alertez sur thanos_store_nodes_grpc_connections.4. Query Frontend #
Cache et parallélisation.
Configuration #
thanos query-frontend \
--http-address=0.0.0.0:9090 \
--query-frontend.downstream-url=http://query:10902 \
--query-range.split-interval=24h \
--query-range.max-retries-per-request=5 \
--query-frontend.log-queries-longer-than=5s \
--query-range.response-cache-config-file=/etc/thanos/cache.yml# cache.yml
type: IN-MEMORY
config:
max_size: 512MB
max_size_items: 0
validity: 10mBonne Pratique : Faites pointer Grafana vers le Query Frontend (et non directement vers Query) : les requêtes de plage sont découpées par jour, exécutées en parallèle et mises en cache.
My progress
Sign in to track your progress and take notes. Sign in
Recommended Articles
Understanding the concept of score
The concept of score allows Elasticsearch to rank your documents by relevance during a search.
Understanding the Elastic Common Schema (ECS)
As always in our consulting engagements, we recommend that companies harmonise and standardise: k...
License consumption types
Understand the evolution of billing in Dynatrace: the difference between the old licensing model ...
Grafana Alloy: The importance of Self-Monitoring
Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...
Grafana Alloy: Understanding and exploiting the User Interface (UI)
Discover how to enable, secure, and use Grafana Alloy's built-in web interface to visualize your ...
Grafana Alloy: Introduction and Architecture
Discover the fundamental concepts of Grafana Alloy, the transition from the static Agent to Alloy...
Grafana Alloy: Syntax and Configuration (Alloy Language: River)
As part of a Grafana training or observability training, master the declarative syntax of Grafana...
Grafana Alloy: Metrics Collection (Prometheus & Ecosystem)
Learn how to configure Grafana Alloy to collect, transform, and forward metrics using the Prometh...
Grafana Alloy: Log Management with Loki
Discover how to configure Grafana Alloy to read log files, journald, or network streams, process ...