알림 정책 만들기

이 페이지에서는 Anthos clusters on bare metal 클러스터의 알림 정책을 만드는 방법을 보여줍니다.

시작하기 전에

알림 정책을 만들려면 다음 권한이 있어야 합니다.

  • monitoring.alertPolicies.create
  • monitoring.alertPolicies.delete
  • monitoring.alertPolicies.update

이러한 권한은 다음 역할 중 하나에 포함됩니다.

  • monitoring.alertPolicyEditor
  • monitoring.editor
  • 프로젝트 편집자
  • 프로젝트 소유자

역할을 확인하려면 Google Cloud 콘솔에서 IAM 페이지로 이동합니다.

정책 만들기: Anthos clusters on bare metal API 서버 사용 불가

이 연습에서는 클러스터의 Kubernetes API 서버에 대한 알림 정책을 만듭니다. 이 정책을 사용하면 클러스터의 API 서버가 사용 불가능할 때마다 알림을 받을 수 있습니다.

  1. 정책 구성 파일 apiserver-unavailable.json을 다운로드합니다.

  2. 정책을 만듭니다.

    gcloud alpha monitoring policies create --policy-from-file=POLICY_CONFIG
    

    POLICY_CONFIG를 바로 전에 다운로드한 구성 파일의 경로로 바꿉니다.

  3. 알림 정책을 확인합니다.

    콘솔

    1. Google Cloud 콘솔에서 Monitoring 페이지로 이동합니다.

      Monitoring으로 이동

    2. 왼쪽에서 알림을 선택합니다.

    3. 정책 아래에서 알림 정책 목록을 볼 수 있습니다.

      목록에서 Anthos clusters on bare metal API 서버 사용 불가(중요)를 선택하여 새 정책에 대한 세부정보를 확인합니다. 조건에서 정책에 대한 설명을 확인할 수 있습니다. 예를 들면 다음과 같습니다.

      Policy violates when ANY condition is met
      Anthos on baremetal cluster API server uptime is absent
      Anthos on baremetal cluster API server uptime is less than 99.99% per minute
      

    gcloud

    gcloud alpha monitoring policies list
    

    출력에 정책에 대한 자세한 정보가 표시됩니다. 예를 들면 다음과 같습니다.

    combiner: OR
    conditions:
    - conditionAbsent:
        aggregations:
        - alignmentPeriod: 60s
          crossSeriesReducer: REDUCE_MEAN
          groupByFields:
          - resource.label.project_id
          - resource.label.location
          - resource.label.cluster_name
          - resource.label.namespace_name
          - resource.label.container_name
          - resource.label.pod_name
          perSeriesAligner: ALIGN_MAX
        duration: 300s
        filter: resource.type = "k8s_container" AND resource.labels.namespace_name = "kube-system"
          AND metric.type = "kubernetes.io/anthos/container/uptime" AND resource.label."container_name"=monitoring.regex.full_match("kube-apiserver")
        trigger:
          count: 1
      displayName: Anthos on baremetal cluster API server uptime is absent
      name: projects/…/alertPolicies/12404845535868002666/conditions/12404845535868003603
    - conditionThreshold:
        aggregations:
        - alignmentPeriod: 120s
          crossSeriesReducer: REDUCE_MEAN
          groupByFields:
          - resource.label.project_id
          - resource.label.location
          - resource.label.cluster_name
          - resource.label.namespace_name
          - resource.label.container_name
          - resource.label.pod_name
          perSeriesAligner: ALIGN_MAX
        comparison: COMPARISON_LT
        duration: 300s
        filter: resource.type = "k8s_container" AND resource.labels.namespace_name = "kube-system"
          AND metric.type = "kubernetes.io/anthos/container/uptime" AND resource.label."container_name"=monitoring.regex.full_match("kube-apiserver")
        thresholdValue: 119.0
        trigger:
          count: 1
      displayName: Anthos on baremetal cluster API server uptime is less than 99.99% per
        minute
      name: projects/…/alertPolicies/12404845535868002666/conditions/12404845535868004540
    creationRecord:
      mutateTime: …
      mutatedBy: …
    displayName: Anthos on baremetal cluster API server unavailable (critical)
    enabled: true
    mutationRecord:
      mutateTime: …
      mutatedBy: …
    name: projects/…/alertPolicies/12404845535868002666
    

추가 알림 정책 만들기

이 섹션에서는 일련의 권장 알림 정책에 대한 설명과 구성 파일을 제공합니다.

정책을 만들려면 이전 연습에 사용한 것과 동일한 단계를 따릅니다.

  1. 구성 파일을 다운로드하려면 오른쪽 열의 링크를 클릭합니다.

  2. 정책을 만들려면 gcloud alpha monitoring policies create를 실행합니다.

다음 스크립트를 사용하여 이 문서에 설명된 모든 알림 정책 샘플을 다운로드하고 설치할 수 있습니다.

# 1. Create a directory named alert_samples:

mkdir alert_samples && cd alert_samples
declare -a alerts=("apiserver-unavailable.json" "scheduler-unavailable.json" "controller-manager-unavailable.json" "pod-crash-looping.json" "container-memory-usage-high-reaching-limit.json"
"container-cpu-usage-high-reaching-limit.json" "pod-not-ready-1h.json" "persistent-volume-usage-high.json" "node-not-ready-1h.json" "node-cpu-usage-high.json" "node-memory-usage-high.json"
"node-disk-usage-high.json" "api-server-error-ratio-10-percent.json" "api-server-error-ratio-5-percent.json" "etcd-leader-changes-too-frequent.json" "etcd-proposals-failed-too-frequent.json"
"etcd-server-not-in-quorum.json" "etcd-storage-usage-high.json")

# 2. Download all alert samples into the alert_samples/ directory:

for x in "${alerts[@]}"
do
  wget https://cloud.google.com/anthos/clusters/docs/bare-metal/1.12/samples/${x}
done

# 3. (optional) Uncomment and provide your project ID to set the default project
# for gcloud commands:

# gcloud config set project <PROJECT_ID>

# 4. Create alert policies for each of the downloaded samples:

for x in "${alerts[@]}"
do
  gcloud alpha monitoring policies create --policy-from-file=${x}
done

제어 영역 구성요소 가용성

알림 이름 설명 Cloud Monitoring의 알림 정책 정의
Anthos clusters on bare metal API 서버 사용 불가(중요) API 서버가 작동 중이 아니거나 분당 업타임이 99.99% 미만 apiserver-unavailable.json
Anthos clusters on bare metal 스케줄러 사용 불가(중요) 스케줄러가 작동 중이 아니거나 분당 업타임이 99.99% 미만 scheduler-unavailable.json
베어메탈용 Anthos 컨트롤러 관리자 사용 불가(중요) 컨트롤러 관리자가 측정항목 대상 검색에서 사라졌습니다. controller-manager-unavailable.json

Kubernetes 시스템

알림 이름 설명 Cloud Monitoring의 알림 정책 정의
Anthos on baremetal 포드 비정상 종료 루프(중요) 포드가 다시 시작되었으며 비정상 종료 루프 상태일 수 있음 pod-crash-looping.json
베어메탈용 Anthos 컨테이너 메모리 사용량 85% 초과(경고) 컨테이너 메모리 사용량이 한도의 85%를 초과했습니다. container-memory-usage-high-reaching-limit.json
베어메탈용 Anthos 컨테이너 CPU 사용량 80% 초과(경고) 컨테이너 CPU 사용량이 한도의 80%를 초과했습니다. container-cpu-usage-high-reaching-limit.json
Anthos on baremetal 포드가 1시간 넘게 준비되지 않음(중요) 포드가 1시간 이상 준비되지 않은 상태입니다. pod-not-ready-1h.json
Anthos on baremetal 영구 볼륨 사용량 높음(중요) 요청한 영구 볼륨이 채워질 것으로 예상됩니다. persistent-volume-usage-high.json
Anthos on baremetal 노드가 1시간 넘게 준비되지 않음(중요) 노드가 1시간 이상 준비되지 않은 상태입니다. node-not-ready-1h.json
Anthos on baremetal CPU 사용량 80% 초과(중요) 노드 CPU 사용량이 80%를 초과합니다. node-cpu-usage-high.json
Anthos on baremetal 메모리 사용량 80% 초과(중요) 노드 메모리 사용량이 80%를 초과합니다. node-memory-usage-high.json
Anthos on baremetal 노드 디스크 사용량 80% 초과(중요) 노드 디스크 사용량이 80%를 초과합니다. node-disk-usage-high.json

Kubernetes 성능

알림 이름 설명 Cloud Monitoring의 알림 정책 정의
Anthos on baremetal API 서버 오류 횟수 비율 10% 초과(중요) API 서버에서 요청의 10%가 넘는 오류를 반환하는 중입니다. api-server-error-ratio-10-percent.json
Anthos on baremetal API 서버 오류 횟수 비율 5% 초과(경고) API 서버에서 요청의 5%가 넘는 오류를 반환하는 중입니다. api-server-error-ratio-5-percent.json
Anthos on baremetal etcd 리더가 너무 자주 변경됨(중요) etcd 리더가 너무 자주 변경됨 etcd-leader-changes-too-frequent.json
Anthos on baremetal etcd 제안이 너무 자주 실패함(중요) etcd 제안이 너무 자주 실패함 etcd-proposals-failed-too-frequent.json
Anthos on baremetal etcd 서버가 쿼럼에 없음(중요) etcd 서버가 쿼럼에 없습니다. etcd-server-not-in-quorum.json
베어메탈용 Anthos etcd 스토리지 90% 한도 초과(중요) etcd 스토리지 사용량이 한도의 90%를 초과합니다. etcd-storage-usage-high.json

알림 받기

알림 정책을 만든 후 정책에 대해 하나 이상의 알림 채널을 정의할 수 있습니다. 알림 채널에는 여러 종류가 있습니다. 예를 들어 이메일, Slack 채널, 모바일 앱을 통해 알림을 받을 수 있습니다. 자신의 요구에 맞게 채널을 선택할 수 있습니다.

알림 채널을 구성하는 방법은 알림 채널 관리를 참조하세요.