クラスターヘルスとモニタリング
クラスターの状態を監視し、問題を特定して、重要なAPIを使いながら稼働状況を把握する方法を学びます。
「クラスターヘルスとモニタリング」はCoddyKit上の無料Elasticsearch & Full Text Search Systemsレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはElasticsearch & Full Text Search Systems学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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.
よくある質問
「クラスターヘルスとモニタリング」レッスンは無料ですか?
はい。「クラスターヘルスとモニタリング」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Elasticsearch & Full Text Search Systemsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。
「クラスターヘルスとモニタリング」で何を学びますか?
クラスターの状態を監視し、問題を特定して、重要なAPIを使いながら稼働状況を把握する方法を学びます。 ブラウザで直接実行するハンズオンコードでElasticsearch & Full Text Search Systemsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Elasticsearch & Full Text Search Systemsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのElasticsearch & Full Text Search Systemsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「クラスターヘルスとモニタリング」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このElasticsearch & Full Text Search Systemsレッスンでコードを書いて実行できますか?
はい。すべてのElasticsearch & Full Text Search Systemsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- シャードとレプリカの仕組み
- クラスターヘルスとモニタリング
- ノードの役割とアーキテクチャ
- シャード割り当てとリバランシング