2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

初心者でもわかる!EKS道場【Day12】Prometheus + Grafana を用いたモニタリングとダッシュボード作成の道

Posted at

初心者でも構築できる!EKS道場【Day13】Prometheus + Grafana を用いたモニタリングとダッシュボード作成の道

🥋 前回の修行

Namespaceでリソースをチームごとに分離する術を身につけた我らは、
ついに「可視化」の道へと歩みを進める。

Kubernetesクラスタの中で何が起きているのか。
Podは健全か?リソースは足りているのか?
その問いに応えるため、PrometheusGrafana を導入し、己のクラスタを「見える化」する力を授けよう!

⛩️ 目次

  1. Prometheus + Grafana の概要
  2. Helm で kube-prometheus-stack をインストール
  3. Grafana に NodePort で外部アクセスする設定
  4. Grafana ダッシュボードの初期設定
  5. おまけ:おすすめの公式ダッシュボード
  6. 次回予告

1. 📈 Prometheus + Grafana の概要

  • Prometheus:KubernetesやNode、Podのメトリクスを収集する監視ツール
  • Grafana:Prometheusのデータを美しいダッシュボードで可視化するツール

この2つを組み合わせることで、CPU使用率、メモリ使用量、Pod数、エラー数…
すべてを一目で把握できるようになります。


2. 🛠 Prometheusスタックのインストール

Helmで「kube-prometheus-stack」をインストールします。
これはPrometheus + Grafana + Alertmanagerなどが統合されたパッケージです。

【Day5】でGrafanaをデプロイしていますが、そちらは使わないので削除してください!

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

kubectl create namespace monitoring

helm install monitoring prometheus-community/kube-prometheus-stack \
  --namespace monitoring

完了後、以下のようなリソースが立ち上がります:

kubectl get pods -n monitoring

image.png

3. 🌐 Grafanaに外部アクセス(NodePortで公開)

デフォルトでは ClusterIP のため、外部からアクセスできません。
NodePort に変えることで、任意のEC2ノードIP経由でアクセスできるようにします。

① Serviceのタイプ変更

kubectl edit svc monitoring-grafana -n monitoring

以下のように type: NodePort を追記します:

spec:
  type: NodePort

保存すると、NodePortが自動割り当てされます。

② NodePortを確認

kubectl get svc monitoring-grafana -n monitoring

出力例:

monitoring-grafana   NodePort   10.100.150.20   <none>   80:31234/TCP   ...

③ ブラウザでアクセス

以下のURLでアクセス可能です:

http://<EKSノードのパブリックIP>:31234

🔐 デフォルトのログイン情報:

ユーザー名:admin
パスワード:prom-operator(初期設定)

image.png

4. 🧭 Grafana ダッシュボード初期設定

左メニューの「+」→「Import」

ダッシュボードIDを入力(例:6417 はKubernetes Cluster Monitoring用)

Prometheus データソースを選択

5. 🌟 おまけ:おすすめのダッシュボード

ダッシュボード名 ID
Kubernetes Cluster Monitoring (via Prometheus) 6417
Node Exporter Full 1860
Kubernetes Pod Metrics 747

下記は1860の例です。
image.png

次回予告 📢:kubeconfigを極めよ!〜EKSとの対話をつかさどる秘伝の書〜

何気なく打っているkubectlコマンドはどうやって動いていると思いますか?
次回はその裏側にせまっていきます!

よければフォロー&いいねお願いします🙏

  • 「面白かった」「続きが気になる!」と思ったらLGTM👍
  • コメントで「聞きたい内容」「つまずきポイント」などもぜひ教えてください!

それではまた明日、EKS道場でお会いしましょう!押忍🔥

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?