열린 알림 쿼리 및 보기

이 페이지에서는 Cortex 엔드포인트의 GDC 콘솔과 curl 도구를 모두 사용하여 미해결 알림을 쿼리하고 시각화하여 문제를 파악하고 해결하는 방법을 자세히 설명합니다.

Google Distributed Cloud (GDC) 에어 갭 어플라이언스 환경의 로그 및 측정항목을 기반으로 알림 규칙을 만든 후 프로젝트에서 열린 알림을 모니터링할 수 있습니다. 시스템 이벤트가 트리거하는 알림을 GDC 콘솔에서 시각화하고 필터링하거나, curl 도구를 사용하여 Cortex에서 직접 액세스하여 유연한 스크립팅 및 자동화를 수행할 수 있습니다.

다음 두 가지 방법 중 하나로 열린 알림에 액세스할 수 있습니다.

  • GDC 콘솔: 특정 데이터 소스의 알림 수, 심각도 수준, 기간, 상태, 메시지, 라벨과 같은 정보가 포함된 통합 패널에서 알림 데이터를 시각화합니다. GDC 콘솔은 시스템 구성요소의 알림을 필터링하고 분석할 수 있는 사용자 친화적인 인터페이스를 제공합니다.
  • Cortex Alertmanager 엔드포인트: 고급 사용 사례의 경우 명령줄에서 curl 도구를 사용하여 프로젝트의 Cortex 인스턴스를 직접 쿼리합니다. Cortex는 프로젝트의 Alertmanager 알림을 저장하고 프로그래매틱 액세스를 위한 HTTP 엔드포인트를 제공합니다. 이 액세스 권한을 사용하면 데이터를 내보내고, 작업을 자동화하고, 크론 작업을 구성하고, 맞춤 통합을 빌드할 수 있습니다.

시작하기 전에

알림을 쿼리하고 시각화하는 데 필요한 권한을 얻으려면 프로젝트 IAM 관리자에게 프로젝트 네임스페이스에서 연결된 Project Cortex Alertmanager 역할 중 하나를 부여해 달라고 요청하세요. 필요한 액세스 수준 및 권한에 따라 프로젝트에서 이 리소스에 대한 편집자 또는 뷰어 역할을 획득할 수 있습니다.

로그를 내보내는 데 필요한 권한을 얻으려면 프로젝트 IAM 관리자에게 프로젝트 Grafana 뷰어 (project-grafana-viewer) 역할을 부여해 달라고 요청하세요. 이 역할 기반 액세스 제어 프로세스를 사용하면 데이터 시각화에 안전하게 액세스할 수 있습니다. 이러한 역할에 대한 자세한 내용은 IAM 권한 준비를 참고하세요.

Grafana 엔드포인트

애플리케이션 운영자 (AO):

다음 URL을 열어 프로젝트의 엔드포인트에 액세스합니다.

https://GDC_URL/PROJECT_NAMESPACE/grafana

다음을 바꿉니다.

  • GDC_URL: GDC의 조직 URL입니다.
  • PROJECT_NAMESPACE: 프로젝트의 네임스페이스입니다.

프로젝트의 UI에는 알림에 관한 정보가 포함된 알림 - 개요 대시보드와 같은 기본 대시보드가 포함되어 있습니다. UI에서 알림을 쿼리하면 프로젝트에서 알림 정보를 시각적으로 가져오고 리소스의 통합 뷰를 확인하여 문제를 파악하고 신속하게 해결할 수 있습니다.

플랫폼 관리자 (PA):

다음 URL을 열어 platform-obs 프로젝트의 엔드포인트에 액세스합니다.

https://GDC_URL/platform-obs/grafana

GDC_URL를 GDC의 조직 URL로 바꿉니다.

시스템 모니터링 인스턴스의 사용자 인터페이스 (UI)에는 데이터 관측 가능성에 대한 알림 정보가 포함된 알림 - 개요 대시보드와 같은 기본 대시보드가 포함되어 있습니다. UI에서 알림을 쿼리하면 프로젝트에서 알림 정보를 시각적으로 가져오고 리소스의 통합 뷰를 확인하여 문제를 파악하고 신속하게 해결할 수 있습니다.

'알림 - 개요' 대시보드에는 특정 데이터 소스의 알림 수와 데이터 소스에 대해 시간당 열린 알림 수를 보여주는 알림 기록의 선 그래프가 표시됩니다.

그림 1. Grafana UI의 알림 - 개요 대시보드

열린 알림 보기 및 필터링

다음 방법 중 하나를 선택하여 프로젝트 네임스페이스에서 열린 알림을 쿼리하고 필터링합니다.

콘솔

GDC 콘솔에서 프로젝트의 미해결 알림을 확인합니다.

  1. GDC 콘솔에 로그인합니다.
  2. GDC 콘솔에서 프로젝트를 선택합니다.
  3. 탐색 메뉴에서 작업 > 알림을 선택합니다.
  4. 알림 탭을 선택합니다.
  5. 알림 목록을 확인합니다.
  6. 열린 알림 섹션에서 필터를 클릭하여 열린 알림만 표시합니다. 다른 속성 이름이나 값으로 알림을 필터링할 수도 있습니다.
  7. 알림 이름을 클릭하여 알림 세부정보를 확인합니다.

Cortex 엔드포인트

이 섹션에서는 Cortex Alertmanager 엔드포인트를 사용하여 알림에 액세스하는 방법을 설명합니다.

Cortex 엔드포인트 확인

다음 URL은 프로젝트의 Cortex 인스턴스 엔드포인트입니다.

  https://GDC_URL/PROJECT_NAMESPACE/cortex/alertmanager/

다음을 바꿉니다.

  • GDC_URL: GDC의 조직 URL입니다.
  • PROJECT_NAMESPACE: 프로젝트 네임스페이스

    예를 들어 org-1 조직의 platform-obs 프로젝트에 대한 Cortex 엔드포인트는 https://org-1/platform-obs/cortex/alertmanager/입니다.

curl 요청 인증

  1. gdcloud CLI를 다운로드하고 설치합니다.
  2. gdcloud core/organization_console_url 속성을 설정합니다.

    gdcloud config set core/organization_console_url
    https://GDC_URL
    
  3. 구성된 ID 공급업체로 로그인:

    gdcloud auth login
    
  4. 사용자 이름과 비밀번호를 사용하여 인증하고 로그인합니다.

    로그인이 성공하면 gdcloud auth print-identity-token 명령어를 통해 cURL 요청에서 승인 헤더를 사용할 수 있습니다. 자세한 내용은 gdcloud auth를 참고하세요.

Cortex 엔드포인트 호출

curl 도구를 사용하여 Cortex 엔드포인트에 도달하려면 다음 단계를 완료하세요.

  1. curl 요청 인증
  2. curl를 사용하여 Cortex 엔드포인트를 호출하고 표준 Alertmanager API 사양(https://prometheus.io/docs/prometheus/latest/querying/api/#alertmanagers)을 사용하여 URL을 확장하여 알림을 쿼리합니다.

    다음은 curl 요청의 예시입니다.

      curl https://GDC_URL/PROJECT_NAME/cortex/alertmanager/api/v1/alertmanagers \
      -H "Authorization: Bearer $(gdcloud auth print-identity-token \
      --audiences=https://GDC_URL)"
    

    명령어에 따라 출력을 가져옵니다. API 응답은 JSON 형식입니다.

Alertmanager

Alertmanager를 사용하면 클라이언트 애플리케이션의 경고 알림을 모니터링할 수 있습니다. Alertmanager를 사용하여 알림을 검사하고 무음으로 설정할 수 있으며, 알림을 필터링하거나 그룹화할 수 있습니다.

루트 관리자 클러스터에서 Loki 거부 감사 로그 알림 무시

그림 2. Alertmanager에서 감사 로그를 쿼리하는 메뉴 옵션

사전 정의된 알림 정책

다음 표에는 Prometheus에 사전 설치된 알림 규칙이 나와 있습니다.

이름 설명
KubeAPIDown(심각) KubeAPI가 Prometheus 대상 검색에서 15분 동안 사라졌습니다.
KubeClientErrors(경고) Kubernetes API 서버 클라이언트 오류율이 15분 동안 0.01을 초과합니다.
KubeClientErrors(심각) Kubernetes API 서버 클라이언트 오류율이 15분 동안 0.1을 초과합니다.
KubePodCrashLooping(경고) 포드가 15분 이상 비정상 종료되는 루프 상태입니다.
KubePodNotReady(경고) 포드가 15분 이상 준비되지 않은 상태입니다.
KubePersistentVolumeFillingUp (심각) 클레임된 PersistentVolume의 무료 바이트가 0.03 미만입니다.
KubePersistentVolumeFillingUp (경고) 클레임된 PersistentVolume의 무료 바이트가 0.15 미만입니다.
KubePersistentVolumeErrors (심각) 영구 볼륨이 5분 동안 실패 또는 대기 단계에 있습니다.
KubeNodeNotReady(경고) 노드가 15분 이상 응답하지 않습니다.
KubeNodeCPUUsageHigh(심각) 노드 CPU 사용량이 80%를 초과합니다.
KubeNodeMemoryUsageHigh(심각) 노드 메모리 사용량이 80%를 초과합니다.
NodeFilesystemSpaceFillingUp (경고) 노드 파일 시스템 사용량이 60%를 초과합니다.
NodeFilesystemSpaceFillingUp (심각) 노드 파일 시스템 사용량이 85%를 초과합니다.
CertManagerCertExpirySoon(경고) 인증서가 21일 후 만료됩니다.
CertManagerCertNotReady(심각) 10분 후 트래픽을 처리하는 데 사용할 인증서가 준비되지 않았습니다.
CertManagerHittingRateLimits (심각) 5분 동안 인증서 생성 및 갱신 비율 제한에 도달했습니다.
DeploymentNotReady(심각) 조직 관리자 클러스터의 배포가 15분 이상 준비되지 않은 상태입니다.

alertmanagerConfigurationConfigmaps 샘플

alertmanagerConfigurationConfigmaps에 나열된 ConfigMap의 구성 구문은 https://prometheus.io/docs/alerting/latest/configuration/을 따라야 합니다.

apiVersion: observability.gdc.goog/v1alpha1
kind: ObservabilityPipeline
metadata:
  # Choose namespace that matches the project's namespace
  namespace: kube-system
  name: observability-config
# Configure Alertmanager
 alerting:
  # Storage size for alerting data within organization
  # Permission: PA
  localStorageSize: 1Gi

  # Permission: PA & AO
  # alertmanager config must be under the key "alertmanager.yml" in the configMap
  alertmanagerConfig: <configmap-for-alertmanager-config>

  # Permission: PA
  volumes:
    - <volume referenced in volumeMounts>

  # Permission: PA
  volumeMounts:
    - <volumeMount referenced in alertmanagerConfig>

샘플 규칙 구성

# Configures either an alert or a target record for precomputation
apiVersion: monitoring.gdc.goog/v1alpha1
kind: MonitoringRule
metadata:
  # Choose namespace that contains the metrics that rules are based on
  # Note: alert/record will be produced in the same namespace
  namespace: g-fleetns-a
  name: alerting-config
spec:
  # Rule evaluation interval
  interval: <duration>

  # Configure limit for number of alerts (0: no limit)
  # Optional, Default: 0 (no limit)
  limit: <int>

  # Configure record rules
  recordRules:
    # Define which timeseries to write to (must be a valid metric name)
  - record: <string>

    # Define PromQL expression to evaluate for this rule
    expr: <string>

    # Define labels to add or overwrite
    # Optional, Map of {key, value} pairs
    labels:
      <labelname>: <labelvalue>

  # Configure alert rules
  alertRules:
    # Define alert name 
  - alert: <string>

    # Define PromQL expression to evaluate for this rule
    # https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
    expr: <string>

    # Define when an active alert moves from pending to firing
    # Optional, Default: 0s
    for: <duration>

    # Define labels to add or overwrite
    # Required, Map of {key, value} pairs
    # Required labels: 
    #     severity: [error, critical, warning, info]
    #     code: 
    #     resource: component/service/hardware related to alert
    #     additional labels are optional
    labels:
      severity: <enum: [error, critical, warning, info]>
      code: 
      resource: <Short name of the related operable component>
      <labelname>: <tmpl_string>

    # Define annotations to add
    # Optional, Map of {key, value} pairs
    # Recommended annotations:
    #     message: value of Message field in UI
    #     expression: value of Rule field in UI
    #     runbookurl: URL for link in Actions to take field in UI
    annotations:
      <labelname>: <tmpl_string>
# Configures either an alert or a target record for precomputation
apiVersion: logging.gdc.goog/v1alpha1
kind: LoggingRule
metadata:
  # Choose namespace that contains the logs that rules are based on
  # Note: alert/record will be produced in the same namespace
  namespace: g-fleetns-a
  name: alerting-config
spec:
  # Choose which log source to base alerts on (Operational/Audit/Security Logs)
  # Optional, Default: Operational
  source: <string>

  # Rule evaluation interval
  interval: <duration>

  # Configure limit for number of alerts (0: no limit)
  # Optional, Default: 0 (no limit)
  limit: <int>

  # Configure record rules
  recordRules:
    # Define which timeseries to write to (must be a valid metric name)
  - record: <string>

    # Define LogQL expression to evaluate for this rule
    # https://grafana.com/docs/loki/latest/rules/
    expr: <string>

    # Define labels to add or overwrite
    # Optional, Map of {key, value} pairs
    labels:
      <labelname>: <labelvalue>

  # Configure alert rules
  alertRules:
    # Define alert name
  - alert: <string>

    # Define LogQL expression to evaluate for this rule
    expr: <string>

    # Define when an active alert moves from pending to firing
    # Optional, Default: 0s
    for: <duration>

    # Define labels to add or overwrite
    # Required, Map of {key, value} pairs
    # Required labels: 
    #     severity: [error, critical, warning, info]
    #     code: 
    #     resource: component/service/hardware related to alert
    #     additional labels are optional
    labels:
      severity: <enum: [error, critical, warning, info]>
      code:
      resource: <Short name of the related operable component>
      <labelname>: <tmpl_string>

    # Define annotations to add
    # Optional, Map of {key, value} pairs
    # Recommended annotations:
    #     message: value of Message field in UI
    #     expression: value of Rule field in UI
    #     runbookurl: URL for link in Actions to take field in UI
    annotations:
      <labelname>: <tmpl_string>

HTTP API에서 알림 쿼리

관측 가능성 플랫폼은 시스템 모니터링을 위해 프로젝트에서 측정항목, 알림, 기타 시계열 데이터를 쿼리하고 읽기 위한 HTTP API 엔드포인트를 노출합니다.

관측 가능성 HTTP API에서 직접 쿼리 알림을 통해 자동화된 작업을 설정하고, 사용 사례에 따라 응답을 조정하고, 통합을 빌드하세요. 예를 들어 출력을 다른 명령어에 삽입하거나, 세부정보를 텍스트 파일 형식으로 내보내거나, Linux cron 작업을 구성할 수 있습니다. 명령줄 인터페이스 (CLI) 또는 웹브라우저에서 Observability HTTP API를 호출하고 결과를 JSON 형식으로 가져올 수 있습니다.

이 섹션에서는API 사양을 사용하여 CLI에서 Observability HTTP API 엔드포인트를 호출하여 알림을 쿼리하는 방법을 설명합니다.

관측 가능성 HTTP API에서 직접 쿼리 알림을 통해 자동화된 작업을 설정하고, 사용 사례에 따라 응답을 조정하고, 통합을 빌드하세요. 예를 들어 출력을 다른 명령어에 삽입하거나, 세부정보를 텍스트 파일 형식으로 내보내거나, Linux cron 작업을 구성할 수 있습니다. 명령줄 인터페이스 (CLI) 또는 웹브라우저에서 Observability HTTP API를 호출하고 결과를 JSON 형식으로 가져올 수 있습니다.

이 섹션에서는 Alertmanager API 사양을 사용하여 측정항목을 쿼리하기 위해 CLI에서 관측 가능성 HTTP API 엔드포인트를 호출하는 방법을 설명합니다.

시작하기 전에

관측 가능성 HTTP API 엔드포인트에 액세스하는 데 필요한 권한을 얻으려면 프로젝트 IAM 관리자에게 프로젝트 네임스페이스에서 Project Cortex Alertmanager 뷰어 (project-cortex-alertmanager-viewer) 역할을 부여해 달라고 요청하세요.

프로젝트 IAM 관리자는 역할 바인딩을 만들어 액세스 권한을 부여할 수 있습니다.

a. 인프라 운영자 (IO) 루트 관리자 - Project Cortex Alertmanager Viewer:

kubectl --kubeconfig $HOME/root-admin-kubeconfig create rolebinding 
io-cortex-alertmanager-viewer-binding -n infra-obs 
--user=fop-infrastructure-operator@example.com 
--role=project-cortex-alertmanager-viewer

b. 플랫폼 관리자 (PA) 루트 관리자 - Project Cortex Alertmanager Viewer:

kubectl --kubeconfig $HOME/root-admin-kubeconfig create rolebinding
pa-cortex-alertmanager-viewer-binding -n platform-obs 
--user=fop-platform-admin@example.com 
--role=project-cortex-alertmanager-viewer

c. 애플리케이션 운영자 (AO) 루트 관리자 - Project Cortex Alertmanager 뷰어: 프로젝트: $AO_PROJECT AO 사용자 이름: $AO_USER

kubectl --kubeconfig $HOME/root-admin-kubeconfig create rolebinding 
project-cortex-alertmanager-viewer-binding -n $AO_PROJECT 
--user=$AO_USER 
--role=project-cortex-alertmanager-viewer

역할 바인딩이 생성되면 로그인 사용자 이름으로 해당 Alertmanager에 액세스할 수 있습니다.

역할 바인딩 확인

kubectl --kubeconfig $HOME/org-1-admin-kubeconfig get rolebinding -n platform-obs

GDC 콘솔에서 역할 바인딩을 설정하는 방법에 대한 자세한 내용은 리소스에 대한 액세스 권한 부여를 참고하세요.

Cortex 엔드포인트

다음 URL은 알림에 액세스하기 위한 Cortex 엔드포인트입니다.

https://GDC_URL/PROJECT_NAME/cortex/alertmanager/

다음을 바꿉니다.

  • GDC_URL: GDC의 조직 URL입니다.
  • PROJECT_NAME: 프로젝트의 이름입니다.

API 엔드포인트 호출

CLI에서 Cortex API 엔드포인트에 연결하고 알림을 쿼리하려면 다음 단계를 따르세요.

  1. 기본 요건을 충족하는지 확인합니다.
  2. CLI를 엽니다.
  3. curl 도구를 사용하여 Cortex 엔드포인트 URL을 호출하고 표준 https://prometheus.io/docs/prometheus/latest/querying/api/#alertmanagers를 사용하여 URL을 확장하여 알림을 쿼리합니다. 예를 들면 다음과 같습니다.

    curl https://console.org-1.zone1.google.gdch.test/alice/cortex/alertmanager/api/v1/alertmanagers
    

명령어 다음에 CLI에서 출력을 가져옵니다. API 응답 형식은 JSON입니다.