État et surveillance du cluster
Apprenez à surveiller l’état de votre cluster, à identifier les problèmes et à utiliser les API essentielles pour comprendre son état de fonctionnement.
État et surveillance du cluster est une leçon Elasticsearch & Full Text Search Systems gratuite sur CoddyKit. Ceci est la leçon 2 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Elasticsearch & Full Text Search Systems, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Elasticsearch & Full Text Search Systems comprend 4 leçons au total.
Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.
Why Monitor Your Cluster?
Just like a car needs regular checks, your Elasticsearch cluster needs monitoring. This ensures it's running smoothly and efficiently.
Monitoring helps you catch problems early, before they affect your users. It's crucial to:
- Prevent data loss
- Ensure high availability
- Optimize performance
- Troubleshoot issues quickly
Your First Health Check
Elasticsearch provides a powerful REST API to check its health. The _cluster/health API is your go-to for a quick overview. It tells you if your cluster is alive and well.
You'd typically make an HTTP GET request to this endpoint:
GET /_cluster/healthGreen, Yellow, Red: What They Mean
The _cluster/health API returns a status that's typically one of three colors:
- Green: All primary and replica shards are allocated. Your cluster is fully operational.
- Yellow: All primary shards are allocated, but some replica shards are not. Data is available, but you might be at risk if a node fails.
- Red: One or more primary shards are unallocated. This means some data is unavailable. Immediate action is needed!
Beyond Just the Color
The _cluster/health API provides more than just a color. It shows important metrics like:
number_of_nodes: Total nodes in the cluster.number_of_data_nodes: Nodes holding data.active_shards: Shards currently processing data.unassigned_shards: Shards that haven't been allocated to a node. These are often the cause of Yellow or Red status.
Always look for unassigned_shards if your status isn't Green.
Checking Individual Nodes
Sometimes you need to check the status of individual nodes. The _cat/nodes API gives you a compact, human-readable list of all nodes, their IP addresses, roles, and resource usage.
The ?v parameter adds column headers for easier reading:
GET /_cat/nodes?vDiving into Shards
The _cat/shards API is crucial for understanding shard allocation. It lists every shard in your cluster, its index, primary/replica status, state (e.g., STARTED, UNASSIGNED), and which node it's on.
This helps diagnose Yellow or Red statuses by showing exactly which shards are unassigned:
GET /_cat/shards?vWhy '_cat' APIs are Handy
The _cat APIs (short for 'concise and tabular') are designed for command-line use. They provide data in a plain text format, making it easy to quickly check various aspects of your cluster without parsing complex JSON.
- Human-readable output
- Fast for quick checks
- Great for scripting
- Many
_catAPIs exist (e.g.,_cat/indices,_cat/health)
Common Monitoring Scenarios
When monitoring, keep an eye on:
- Red Cluster Status: Indicates data loss or inaccessibility.
- Yellow Cluster Status: Replica shards unassigned, risk of data loss on node failure.
- High CPU/Memory Usage: A node might be overloaded.
- Disk Space: Nodes running out of disk space can cause issues.
- Unassigned Shards: Always check
_cat/shardsto understand why.
These are early warning signs that require attention.
Proactive Monitoring
While manual checks are good, for a production system, you need proactive monitoring. Tools like Kibana's Alerting, Prometheus & Grafana, or dedicated monitoring services can automatically notify you of issues.
Proactive monitoring helps you:
- Automate health checks
- Get instant notifications
- Visualize trends over time
- Integrate with incident management
Check Your Understanding
You've learned about Elasticsearch cluster health statuses. Let's test your knowledge!
Recap: Your Monitoring Toolkit
We've covered essential tools for monitoring your Elasticsearch cluster:
- The
_cluster/healthAPI gives a quick overview (Green, Yellow, Red statuses). _cat/nodeshelps you check individual node status and resources._cat/shardsis key to understanding shard allocation and diagnosing unassigned shards.
Regular monitoring and understanding these statuses are crucial for a stable and reliable Elasticsearch deployment.
Questions Fréquemment Posées
La leçon « État et surveillance du cluster » est-elle gratuite ?
Oui — le texte complet de « État et surveillance du cluster » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Elasticsearch & Full Text Search Systems, passe à CoddyKit PRO. Le cours Elasticsearch & Full Text Search Systems comprend 4 leçons au total.
Qu'est-ce que j'apprendrai dans « État et surveillance du cluster » ?
Apprenez à surveiller l’état de votre cluster, à identifier les problèmes et à utiliser les API essentielles pour comprendre son état de fonctionnement. Tu pratiques Elasticsearch & Full Text Search Systems avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.
Dois-je avoir de l'expérience pour commencer Elasticsearch & Full Text Search Systems ?
Aucune expérience préalable n'est requise. Elasticsearch & Full Text Search Systems sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 2 sur 4.
Combien de temps prend la leçon « État et surveillance du cluster » ?
La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.
Peux-tu écrire et exécuter du code dans cette leçon Elasticsearch & Full Text Search Systems ?
Oui. Chaque leçon Elasticsearch & Full Text Search Systems inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.
Toutes les leçons de ce cours
- Explication du partitionnement et des répliques
- État et surveillance du cluster
- Rôles des nœuds et architecture
- Allocation et rééquilibrage des fragments