5장. Prometheus Adapter의 감사 로그 수준 설정

기본 플랫폼 모니터링에서는 Prometheus Adapter에 대한 감사 로그 수준을 구성할 수 있습니다.

사전 요구 사항

  • OpenShift CLI(oc)가 설치되어 있습니다.
  • cluster-admin 클러스터 역할의 사용자로 클러스터에 액세스할 수 있습니다.
  • cluster-monitoring-config ConfigMap 오브젝트를 생성하셨습니다.

절차

기본 openshift-monitoring 프로젝트에서 Prometheus Adapter에 대한 감사 로그 수준을 설정할 수 있습니다.

  1. openshift-monitoring 프로젝트에서 cluster-monitoring-config ConfigMap 오브젝트를 편집합니다.

    $ oc -n openshift-monitoring edit configmap cluster-monitoring-config
  2. data/config.yaml 아래의 k8sPrometheusAdapter/audit 섹션에 profile: 을 추가합니다.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cluster-monitoring-config
      namespace: openshift-monitoring
    data:
      config.yaml: |
        k8sPrometheusAdapter:
          audit:
            profile: <audit_log_level> 1
    1
    Prometheus Adapter에 적용할 감사 로그 수준입니다.
  3. profile: 매개변수에 다음 값 중 하나를 사용하여 감사 로그 수준을 설정합니다.

    • none: 이벤트를 기록하지 마십시오.
    • metadata: 사용자, 타임스탬프 등과 같은 요청에 대한 메타데이터만 기록합니다. 요청 텍스트와 응답 텍스트를 기록하지 마십시오. 메타데이터 는 기본 감사 로그 수준입니다.
    • Request: 메타데이터와 요청 텍스트만 기록하지만 응답 텍스트는 기록하지 않습니다. 이 옵션은 리소스가 아닌 요청에는 적용되지 않습니다.
    • RequestResponse: 로그 이벤트 메타데이터, 요청 텍스트 및 응답 텍스트입니다. 이 옵션은 리소스가 아닌 요청에는 적용되지 않습니다.
  4. 파일을 저장하여 변경 사항을 적용합니다. 변경을 적용하면 Prometheus Adapter의 Pod가 자동으로 다시 시작됩니다.

    주의

    모니터링 구성 맵에 변경 사항이 저장되면 관련 프로젝트의 Pod 및 기타 리소스가 재배포될 수 있습니다. 해당 프로젝트에서 실행 중인 모니터링 프로세스도 다시 시작할 수 있습니다.

검증

  1. 구성 맵의 k8sPrometheusAdapter/audit/profile 에서 로그 수준을 Request 로 설정하고 파일을 저장합니다.
  2. Prometheus Adapter의 Pod가 실행 중인지 확인합니다. 다음 예제에서는 openshift-monitoring 프로젝트의 Pod 상태를 나열합니다.

    $ oc -n openshift-monitoring get pods
  3. 감사 로그 수준 및 감사 로그 파일 경로가 올바르게 구성되었는지 확인합니다.

    $ oc -n openshift-monitoring get deploy prometheus-adapter -o yaml

    출력 예

    ...
      - --audit-policy-file=/etc/audit/request-profile.yaml
      - --audit-log-path=/var/log/adapter/audit.log

  4. openshift-monitoring 프로젝트의 prometheus-adapter 배포에 올바른 로그 수준이 적용되었는지 확인합니다.

    $ oc -n openshift-monitoring exec deploy/prometheus-adapter -c prometheus-adapter -- cat /etc/audit/request-profile.yaml

    출력 예

    "apiVersion": "audit.k8s.io/v1"
    "kind": "Policy"
    "metadata":
      "name": "Request"
    "omitStages":
    - "RequestReceived"
    "rules":
    - "level": "Request"

    참고

    ConfigMap 오브젝트에서 Prometheus Adapter에 인식할 수 없는 프로필 값을 입력하면 Prometheus Adapter에 대한 변경 사항이 없으며 Cluster Monitoring Operator에 의해 오류가 기록됩니다.

  5. Prometheus Adapter의 감사 로그를 확인합니다.

    $ oc -n openshift-monitoring exec -c <prometheus_adapter_pod_name> -- cat /var/log/adapter/audit.log

추가 리소스

5.1. 로컬 Alertmanager 비활성화

OpenShift Container Platform 모니터링 스택의 openshift-monitoring 프로젝트에서 Prometheus 인스턴스에서 경고를 라우팅하는 로컬 Alertmanager가 기본적으로 활성화되어 있습니다.

로컬 Alertmanager가 필요하지 않은 경우 openshift-monitoring 프로젝트에서 cluster-monitoring-config 구성 맵을 구성하여 비활성화할 수 있습니다.

사전 요구 사항

  • cluster-admin 클러스터 역할의 사용자로 클러스터에 액세스할 수 있습니다.
  • cluster-monitoring-config 구성 맵을 생성했습니다.
  • OpenShift CLI(oc)가 설치되어 있습니다.

절차

  1. openshift-monitoring 프로젝트에서 cluster-monitoring-config 구성 맵을 편집합니다.

    $ oc -n openshift-monitoring edit configmap cluster-monitoring-config
  2. data/config.yaml 아래의 alertmanagerMain 구성 요소에 대해 enabled: false를 추가합니다.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cluster-monitoring-config
      namespace: openshift-monitoring
    data:
      config.yaml: |
        alertmanagerMain:
          enabled: false
  3. 파일을 저장하여 변경 사항을 적용합니다. 변경 사항을 적용하면 Alertmanager 인스턴스가 자동으로 비활성화됩니다.

추가 리소스