0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GemFire for KubernetesのメトリクスをPrometheusで可視化する

Posted at

以前、こちらでVMware GemFire for Kubernetesを構築してAria Operations for Applications(以下AOA)で可視化するところまで確認した。
AOAでの連携は非常に簡単だったが、Kubernetesの監視だとPrometheusを使うことも多いので、今回は前回の続きとしてPrometheusでメトリクスを見るところを確認する。
なお、前回の続きのため、GemFire Clusterは構築済みとして進める。

最初にPrometheusを構築するためにHelmのChartリポジトリを追加する。

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

Prometheusをインストールする。外部からアクセスしたかったのでPrometheusとGrafanaそれぞれでtype: LoadBalancerを設定した。

helm install prometheus prometheus-community/kube-prometheus-stack -n prometheus --create-namespace --set grafana.service.type=LoadBalancer --set prometheus.service.type=LoadBalancer

次にGemFireのEndpointを伝えるためにkind: ServiceMonitorを作るが、その前にPrometheusの検出ルールを確認する。

$ kubectl get prometheus -o yaml prometheus-kube-prometheus-prometheus -n prometheus
:(省略)
  serviceMonitorSelector:
    matchLabels:
      release: prometheus
:(省略)

Labelにrelease: prometheusがあればいいので、これを含むServiceMonitorのManifestを作成し、applyする。

cat << EOF > ./gemfire-svcmonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: gemfire-svcmonitor
  namespace: gemfire-dev
  labels:
    release: prometheus
spec:
  endpoints:
  - interval: 10s
    port: locator-metrics
    scheme: http
    path: /
  - interval: 10s
    port: server-metrics
    scheme: http
    path: /
  selector:
    matchLabels:
      app.kubernetes.io/name: gemfire
  namespaceSelector:
    matchNames:
    - gemfire-dev
EOF
kubectl apply -f gemfire-svcmonitor.yaml

GemFireはメトリクスを/meticsではなく/で公開しているため、パスを変更している。
また、targetPortでLocatorとServerのEndpointを纏めて指定できないか試してみたが、上手く動かなかったのでportでport名をそれぞれ指定している。
問題なければ、Podの再起動とかはせずに少し待てばPrometheus側で以下のようにService Discoveryに表示される。
1696583394019.png
メトリクスも問題なく取れているようだ。
1696585503328.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?