4.4. 모니터링 스택 검증
모니터링 스택이 올바르게 작동하는지 확인하려면 예제 서비스에 액세스한 다음 수집된 지표를 확인합니다.
사전 요구 사항
-
cluster-admin
클러스터 역할의 사용자로 또는 네임스페이스에 대한 관리 권한이 있는 사용자로 클러스터에 액세스할 수 있습니다. - Cluster Observability Operator가 설치되어 있습니다.
-
prometheus-coo-example-app
샘플 서비스를ns1-coo
네임스페이스에 배포했습니다. -
ns1-coo
네임스페이스에prometheus-coo-example-monitor
라는ServiceMonitor
오브젝트를 생성했습니다. -
ns1-coo
네임스페이스에example-coo-monitoring-stack
이라는MonitoringStack
오브젝트를 생성했습니다.
프로세스
example
prometheus-coo-example-app
서비스를 노출할 경로를 생성합니다. 터미널에서 다음 명령을 실행합니다.$ oc expose svc prometheus-coo-example-app -n ns1-coo
- 브라우저 또는 명령줄에서 경로에 액세스하여 메트릭을 생성합니다.
Prometheus Pod에서 쿼리를 실행하여 총 HTTP 요청 지표를 반환합니다.
$ 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
를 사용하여 포맷됨){ "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" ] } ] } }