Salud y monitorización del clúster
Aprenda a monitorizar la salud de su clúster, identificar problemas y utilizar las API esenciales para conocer su estado operativo.
Salud y monitorización del clúster es una lección gratuita de Elasticsearch & Full Text Search Systems en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Elasticsearch & Full Text Search Systems, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Elasticsearch & Full Text Search Systems incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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.
Preguntas frecuentes
¿La lección «Salud y monitorización del clúster» es gratis?
Sí — el texto completo de «Salud y monitorización del clúster» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Elasticsearch & Full Text Search Systems, actualiza a CoddyKit PRO. El curso de Elasticsearch & Full Text Search Systems incluye 4 lecciones en total.
¿Qué aprenderé en «Salud y monitorización del clúster»?
Aprenda a monitorizar la salud de su clúster, identificar problemas y utilizar las API esenciales para conocer su estado operativo. Practicas Elasticsearch & Full Text Search Systems con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Elasticsearch & Full Text Search Systems?
No se requiere experiencia previa. Elasticsearch & Full Text Search Systems en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Salud y monitorización del clúster»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Elasticsearch & Full Text Search Systems?
Sí. Cada lección de Elasticsearch & Full Text Search Systems incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Explicación de shards y réplicas
- Salud y monitorización del clúster
- Roles y arquitectura de los nodos
- Asignación y reequilibrado de shards