본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Elasticsearch와 Fluentd 메트릭

원문 보기 위키 갱신

Prometheus로 Fluentd와 Elasticsearch 메트릭을 감시해 로그 수집·저장 장애를 미리 잡아 내는 방법이에요. 플로우 로그와 DNS 로그가 끊기면 네트워크 가시성이 그대로 끊기기 때문에, 로그 파이프라인 자체를 모니터링 대상으로 삼는 접근이에요. 바로 쓸 수 있는 PrometheusRule 예제 두 개를 담고 있어요.

출처: 문서

본문

전체 그림

Fluentd와 Elasticsearch 메트릭에 Prometheus 모니터링·알림 도구를 사용해 네트워크 가시성이 끊기지 않게 유지해요.

가치

플랫폼 엔지니어링 팀은 플로우 로그, DNS 로그 같은 로그에 의존해 네트워크를 들여다봐요. 로그 수집이나 저장이 끊기면 네트워크 가시성도 함께 흔들려요. Prometheus가 로그 수집·저장 메트릭을 감시하면, 플랫폼 엔지니어링 팀은 문제가 터지기 전에 알림을 받을 수 있어요.

개념

컴포넌트 설명
Prometheus 인스트루먼트된(instrumented) 잡에서 메트릭을 긁어 와 시계열 데이터를 시각화 도구(예: Grafana)로 보여 주는 모니터링 도구예요. Calico Enterprise에서 Prometheus가 메트릭을 수집할 수 있는 "잡"은 Elasticsearch와 Fluentd 컴포넌트예요.
Elasticsearch Calico Enterprise 로그를 저장해요.
Fluentd Calico Enterprise 로그를 저장을 위해 Elasticsearch로 보내요.

멀티클러스터 관리 사용자: Elasticsearch 메트릭은 관리(management) 클러스터에서만 수집돼요. 관리 대상(managed) 클러스터에는 Elasticsearch 클러스터가 없으므로, 관리 대상 클러스터에 대해 Elasticsearch를 감시하지 마세요. 다만 관리 대상 클러스터도 Fluentd 로그를 Elasticsearch로 흘려 보내므로, 관리 대상 클러스터에는 fluentd를 감시해야 해요.

방법

Elasticsearch용 Prometheus 알림 만들기

다음 예제는 중요한 Elasticsearch 메트릭 몇 가지를 감시하고, 임계값을 넘으면 알림을 주는 Prometheus 규칙을 만들어요:

참고(SECONDARY): Elasticsearch Prometheus 규칙은 standalone과 management 클러스터 타입에만 적용되고, managed 클러스터 타입에는 적용되지 않아요.

참고(SECONDARY): ElasticsearchHighMemoryUsage 알림은 절대값이에요. 규칙을 적용하기 전에 반드시 이 값을 설정하세요.

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: tigera-prometheus-log-storage-monitoring
  namespace: tigera-prometheus
  labels:
    role: tigera-prometheus-rules
    prometheus: calico-node-prometheus
spec:
  groups:
  - name: tigera-elasticsearch.rules
    rules:
    - alert: ElasticsearchClusterStatusRed
      expr: elasticsearch_cluster_health_status{color="red"} == 1
      labels:
        severity: Critical
      annotations:
        summary: "Elasticsearch cluster {{$labels.cluster}}'s status is red"
        description: "The Elasticsearch cluster {{$labels.cluster}} is very unhealthy and immediate action must be
taken. Check the pod logs for the {{$labels.cluster}} Elasticsearch cluster to start the investigation."
    - alert: ElasticsearchClusterStatusYellow
      expr: elasticsearch_cluster_health_status{color="yellow"} == 1
      labels:
        severity: Warning
      annotations:
        summary: "Elasticsearch cluster {{$labels.cluster}} status is yellow"
        description: "The Elasticsearch cluster {{$labels.cluster}} may be unhealthy and could become very unhealthy if
the issue isn't resolved. Check the pod logs for the {{$labels.cluster}} Elasticsearch cluster to start the
investigation."
    - alert: ElasticsearchPodCriticallyLowDiskSpace
      expr: elasticsearch_filesystem_data_available_bytes / elasticsearch_filesystem_data_size_bytes < 0.10
      labels:
        severity: Critical
      annotations:
        summary: "Elasticsearch pod {{$labels.name}}'s disk space is critically low."
        description: "Elasticsearch pod {{$labels.name}} in Elasticsearch cluster {{$labels.name}} has less than 10% of
free disk space left. To avoid service disruption review the LogStorage resource limits and curation settings."
    - alert: ElasticsearchPodLowDiskSpace
      expr: elasticsearch_filesystem_data_available_bytes / elasticsearch_filesystem_data_size_bytes < 0.25
      labels:
        severity: Warning
      annotations:
        summary: "Elasticsearch pod {{$labels.name}}'s disk space is getting low."
        description: "Elasticsearch pod {{$labels.name}} in Elasticsearch cluster {{$labels.name}} has less than 25% of
free disk space left. To avoid service disruption review the LogStorage resource limits and curation settings."
    - alert: ElasticsearchConsistentlyHighCPUUsage
      expr: avg_over_time(elasticsearch_os_cpu_percent[10m]) > 90
      labels:
        severity: Warning
      annotations:
        summary: "Elasticsearch pod {{$labels.name}}'s CPU usage is consistently high."
        description: "Elasticsearch pod {{$labels.name}} in Elasticsearch cluster {{$labels.cluster}} has been using
above 90% of it's available CPU for the last 10 minutes. To avoid service disruption review the LogStorage resource
limits."
    - alert: ElasticsearchHighMemoryUsage
      expr: avg_over_time(elasticsearch_jvm_memory_pool_used_bytes[10m]) > 1000000000
      labels:
        severity: Warning
      annotations:
        summary: "Elasticsearch pod {{$labels.name}}'s memory usage is consistently high."
        description: "Elasticsearch pod {{$labels.name}} in Elasticsearch cluster {{$labels.cluster}} has been using
an average of {{$labels.value}} bytes of memory over the past 10 minutes. To avoid service disruption review the
LogStorage resource limits."

예제에서 만든 알림은 다음 표에 설명되어 있어요:

알림 심각도 필요한 조치 문제/원인
ElasticsearchClusterStatusRed Critical 서비스 중단을 피하고 서비스를 회복하려면 즉시 조치가 필요해요. Elasticsearch 클러스터가 unhealthy 상태예요.
ElasticsearchPodCriticallyLowDiskSpace Critical 파드의 디스크 공간이 전체 가용 공간의 10% 미만이에요. LogStorage 리소스의 디스크 공간 설정이 충분하지 않거나 로그가 제대로 큐레이션되지 않고 있어요.
ElasticsearchClusterStatusYellow Non-critical, warning 치명적 문제를 배제하려면 즉시 조사가 필요해요. 클러스터 문제의 초기 경고예요.
ElasticsearchPodLowDiskSpace Non-critical, warning Elasticsearch 파드의 디스크 공간이 전체 가용 공간의 25% 미만이에요. LogStorage 리소스의 디스크 공간 설정이 충분하지 않거나 로그가 제대로 큐레이션되지 않고 있어요.
ElasticsearchPodConsistentlyHighCPUUsage Non-critical, warning Elasticsearch 파드가 지난 10분 동안 평균 90%를 넘는 CPU를 쓰고 있어요.
ElasticsearchPodConsistentlyHighMemoryUsage Non-critical, warning Elasticsearch 파드가 지난 10분 동안 설정된 메모리 임계값을 넘는 평균을 기록하고 있어요.

Fluentd용 Prometheus 알림 만들기

다음 예제는 중요한 Fluentd 메트릭 몇 가지를 감시하고, 임계값을 넘으면 알림을 주는 Prometheus 규칙을 만들어요:

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: tigera-prometheus-log-collection-monitoring
  namespace: tigera-prometheus
  labels:
    role: tigera-prometheus-rules
    prometheus: calico-node-prometheus
spec:
  groups:
  - name: tigera-log-collection.rules
    rules:
    - alert: FluentdPodConsistentlyLowBufferSpace
      expr: avg_over_time(fluentd_output_status_buffer_available_space_ratio[5m]) < 75
      labels:
        severity: Warning
      annotations:
        summary: "Fluentd pod {{$labels.pod}}'s buffer space is consistently below 75 percent capacity."
        description: "Fluentd pod {{$labels.pod}} has very low buffer space. There may be connection issues between Elasticsearch
and Fluentd or there are too many logs to write out, check the logs for the Fluentd pod."

예제에서 만든 알림은 다음과 같이 설명돼요:

알림 심각도 필요한 조치 문제/원인
FluentdPodConsistentlyLowBufferSpace Non-critical, warning 로그가 제대로 수집되고 있는지 확인하려면 즉시 조사가 필요해요. Fluentd 파드의 가용 버퍼 크기가 지난 5분 동안 평균 75% 미만이었어요. 이는 Fluentd가 Elasticsearch 클러스터와 통신하는 데 어려움을 겪거나, Elasticsearch 클러스터가 내려갔거나, 단순히 처리할 로그가 너무 많다는 뜻일 수 있어요.

더 알아보기 (Learn more)

이 문서의 핵심은 로그 파이프라인 자체를 감시 대상으로 삼는 거예요. 로그가 끊기면 그 순간부터 네트워크 이상 징후가 보이지 않으니, 알림 규칙을 클러스터에 적용해 두는 것만으로 가시성의 신뢰도가 크게 올라가요. LogStorage 리소스 한도와 큐레이션 설정도 함께 점검해 두세요.