4.4. モニタリングスタックの検証
モニタリングスタックが正しく機能していることを確認するには、サンプルサービスにアクセスし、収集したメトリクスを表示します。
前提条件
-
cluster-admin
クラスターロールを持つユーザーとして、または namespace の管理権限を持つユーザーとして、クラスターにアクセスできる。 - Cluster Observability Operator がインストールされている。
-
prometheus-coo-example-app
サンプルサービスをns1-coo
namespace にデプロイしている。 -
ns1-coo
namespace に、prometheus-coo-example-monitor
という名前のServiceMonitor
オブジェクトを作成している。 -
ns1-coo
namespace にexample-coo-monitoring-stack
という名前のMonitoringStack
オブジェクトを作成している。
手順
prometheus-coo-example-app
サービスのサンプルを公開するためのルートを作成します。ターミナルから、以下のコマンドを実行します。Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc expose svc prometheus-coo-example-app -n ns1-coo
$ oc expose svc prometheus-coo-example-app -n ns1-coo
- ブラウザーまたはコマンドラインからルートにアクセスし、メトリクスを生成します。
Prometheus Pod でクエリーを実行し、HTTP 要求メトリクスの合計を返します。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/query?query=http_requests_total'
$ oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/query?query=http_requests_total'
出力例 (便宜上
jq
を使用したフォーマット)Copy to Clipboard Copied! Toggle word wrap Toggle overflow { "status": "success", "data": { "resultType": "vector", "result": [ { "metric": { "__name__": "http_requests_total", "code": "200", "endpoint": "web", "instance": "10.129.2.25:8080", "job": "prometheus-coo-example-app", "method": "get", "namespace": "ns1-coo", "pod": "prometheus-coo-example-app-5d8cd498c7-9j2gj", "service": "prometheus-coo-example-app" }, "value": [ 1730807483.632, "3" ] }, { "metric": { "__name__": "http_requests_total", "code": "404", "endpoint": "web", "instance": "10.129.2.25:8080", "job": "prometheus-coo-example-app", "method": "get", "namespace": "ns1-coo", "pod": "prometheus-coo-example-app-5d8cd498c7-9j2gj", "service": "prometheus-coo-example-app" }, "value": [ 1730807483.632, "0" ] } ] } }
{ "status": "success", "data": { "resultType": "vector", "result": [ { "metric": { "__name__": "http_requests_total", "code": "200", "endpoint": "web", "instance": "10.129.2.25:8080", "job": "prometheus-coo-example-app", "method": "get", "namespace": "ns1-coo", "pod": "prometheus-coo-example-app-5d8cd498c7-9j2gj", "service": "prometheus-coo-example-app" }, "value": [ 1730807483.632, "3" ] }, { "metric": { "__name__": "http_requests_total", "code": "404", "endpoint": "web", "instance": "10.129.2.25:8080", "job": "prometheus-coo-example-app", "method": "get", "namespace": "ns1-coo", "pod": "prometheus-coo-example-app-5d8cd498c7-9j2gj", "service": "prometheus-coo-example-app" }, "value": [ 1730807483.632, "0" ] } ] } }