Trident Protect 리소스를 모니터링하세요
kube-state-metrics, Prometheus 및 Alertmanager 오픈 소스 도구를 사용하여 Trident Protect로 보호되는 리소스의 상태를 모니터링할 수 있습니다.
kube-state-metrics 서비스는 Kubernetes API 통신에서 메트릭을 생성합니다. 이 서비스를 Trident Protect와 함께 사용하면 환경 내 리소스 상태에 대한 유용한 정보를 확인할 수 있습니다.
Prometheus는 kube-state-metrics에서 생성된 데이터를 수집하여 해당 객체에 대한 읽기 쉬운 정보로 제공하는 툴킷입니다. kube-state-metrics와 Prometheus를 함께 사용하면 Trident Protect로 관리하는 리소스의 상태를 모니터링할 수 있습니다.
Alertmanager는 Prometheus와 같은 도구에서 전송된 알림을 수집하여 구성한 대상으로 라우팅하는 서비스입니다.
|
|
이 단계에 포함된 구성 및 지침은 예시일 뿐이며, 사용자의 환경에 맞게 수정해야 합니다. 구체적인 지침 및 지원은 다음 공식 문서를 참조하십시오: |
1단계: 모니터링 도구 설치
Trident Protect에서 리소스 모니터링을 활성화하려면 kube-state-metrics, Prometheus 및 Alertmanager를 설치하고 구성해야 합니다.
kube-state-metrics 설치
Helm을 사용하여 kube-state-metrics를 설치할 수 있습니다.
-
kube-state-metrics Helm 차트를 추가합니다. 예:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update -
클러스터에 Prometheus ServiceMonitor CRD를 적용합니다.
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml -
Helm 차트용 구성 파일을 생성합니다(예:
metrics-config.yaml). 다음 예시 구성을 환경에 맞게 사용자 지정할 수 있습니다.metrics-config.yaml: kube-state-metrics Helm 차트 구성--- extraArgs: # Collect only custom metrics - --custom-resource-state-only=true customResourceState: enabled: true config: kind: CustomResourceStateMetrics spec: resources: - groupVersionKind: group: protect.trident.netapp.io kind: "Backup" version: "v1" labelsFromPath: backup_uid: [metadata, uid] backup_name: [metadata, name] creation_time: [metadata, creationTimestamp] metrics: - name: backup_info help: "Exposes details about the Backup state" each: type: Info info: labelsFromPath: appVaultReference: ["spec", "appVaultRef"] appReference: ["spec", "applicationRef"] rbac: extraRules: - apiGroups: ["protect.trident.netapp.io"] resources: ["backups"] verbs: ["list", "watch"] # Collect metrics from all namespaces namespaces: "" # Ensure that the metrics are collected by Prometheus prometheus: monitor: enabled: true -
Helm 차트를 배포하여 kube-state-metrics를 설치하세요. 예를 들면 다음과 같습니다.
helm install custom-resource -f metrics-config.yaml prometheus-community/kube-state-metrics --version 5.21.0 -
"kube-state-metrics 사용자 정의 리소스 문서"의 지침에 따라 Trident Protect에서 사용하는 사용자 지정 리소스에 대한 메트릭을 생성하도록 kube-state-metrics를 구성합니다.
Prometheus 설치
https://prometheus.io/docs/prometheus/latest/installation/["Prometheus 문서"^]의 지침에 따라 Prometheus를 설치할 수 있습니다.
Alertmanager 설치
https://github.com/prometheus/alertmanager?tab=readme-ov-file#install["Alertmanager 문서"^]의 지침에 따라 Alertmanager를 설치할 수 있습니다.
2단계: 모니터링 도구가 함께 작동하도록 구성합니다
모니터링 도구를 설치한 후에는 함께 작동하도록 구성해야 합니다.
-
kube-state-metrics를 Prometheus와 통합합니다. Prometheus 구성 파일(`prometheus.yaml`을 편집하고 kube-state-metrics 서비스 정보를 추가합니다. 예를 들면 다음과 같습니다.
prometheus.yaml: Prometheus와 kube-state-metrics 서비스 통합--- apiVersion: v1 kind: ConfigMap metadata: name: prometheus-config namespace: trident-protect data: prometheus.yaml: | global: scrape_interval: 15s scrape_configs: - job_name: 'kube-state-metrics' static_configs: - targets: ['kube-state-metrics.trident-protect.svc:8080'] -
Prometheus가 Alertmanager로 알림을 라우팅하도록 구성합니다. Prometheus 구성 파일(`prometheus.yaml`을 편집하고 다음 섹션을 추가합니다.
prometheus.yaml: Alertmanager로 알림 전송alerting: alertmanagers: - static_configs: - targets: - alertmanager.trident-protect.svc:9093
이제 Prometheus는 kube-state-metrics에서 메트릭을 수집하고 Alertmanager로 알림을 보낼 수 있습니다. 이제 알림을 트리거하는 조건과 알림을 보낼 위치를 구성할 준비가 되었습니다.
3단계: 알림 및 알림 대상 구성
도구들을 연동하도록 구성한 후에는 어떤 유형의 정보가 알림을 발생시키는지, 그리고 알림을 어디로 보내야 하는지를 구성해야 합니다.
알림 예: 백업 실패
다음 예제는 백업 사용자 지정 리소스의 상태가 Error`5초 이상 설정될 때 트리거되는 중요 경고를 정의합니다. 이 예제를 환경에 맞게 사용자 지정하고 이 YAML 코드 조각을 `prometheus.yaml 구성 파일에 포함할 수 있습니다.
rules.yaml: |
groups:
- name: fail-backup
rules:
- alert: BackupFailed
expr: kube_customresource_backup_info{status="Error"}
for: 5s
labels:
severity: critical
annotations:
summary: "Backup failed"
description: "A backup has failed."
Alertmanager가 다른 채널로 알림을 보내도록 구성합니다
Alertmanager를 구성하여 이메일, PagerDuty, Microsoft Teams 또는 기타 알림 서비스와 같은 다른 채널로 알림을 보낼 수 있습니다. 이를 위해서는 alertmanager.yaml 파일에 해당 구성을 지정하면 됩니다.
다음 예제는 Alertmanager가 Slack 채널로 알림을 보내도록 구성합니다. 이 예제를 사용자 환경에 맞게 사용자 지정하려면 api_url 키의 값을 사용자 환경에서 사용하는 Slack 웹훅 URL로 바꾸십시오.
data:
alertmanager.yaml: |
global:
resolve_timeout: 5m
route:
receiver: 'slack-notifications'
receivers:
- name: 'slack-notifications'
slack_configs:
- api_url: '<your-slack-webhook-url>'
channel: '#failed-backups-channel'
send_resolved: false