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

Windows 익스포터 메트릭 (Windows exporter metrics)

원문 보기 위키 갱신

Prometheus Windows Exporter를 기반으로 시스템 및 호스트 레벨 메트릭을 수집하는 플러그인이에요.

지원 이벤트 유형: metrics

Prometheus Windows exporter는 CPU, 디스크, 네트워크, 프로세스 통계 같은 시스템 레벨 메트릭을 Microsoft Windows에서 수집하는 인기 있는 방법이에요. Fluent Bit 1.9.0 이상에는 Prometheus 설계를 기반으로 하는 Windows Exporter metrics 플러그인이 포함되어 있는데, 이 플러그인은 두 개의 별도 프로세스나 에이전트를 관리하지 않고도 시스템 레벨 메트릭을 수집해 줘요.

Windows Exporter metrics의 초기 릴리스에는 Prometheus Windows Exporter에서 제공하는 단일 컬렉터(collector)가 포함되어 있어요.

참고 — Windows Exporter metrics로 수집된 메트릭은 로그와 별도의 파이프라인을 통해 흐르며, 기존 필터는 메트릭 위에서 동작하지 않아요. 이 플러그인은 관련 메트릭에 접근하기 위해 Windows Management Instrumentation(WMI)을 사용하므로 Windows 운영체제에서만 지원돼요.

출처: 문서

본문

구성

scrape_interval은 모든 스크레이프의 기본값을 설정해요. 세분화된 스크레이프 간격을 설정하려면 특정 간격을 설정하면 돼요. 예를 들어 collector.cpu.scrape_interval처럼요. 세분화된 스크레이프 간격을 사용할 때 0보다 큰 값이면 전역 기본값을 덮어써요. 그렇지 않으면 전역 기본값이 사용돼요.

플러그인의 최상위 scrape_interval 설정이 전역 기본값이에요. 개별 scrape_intervals에 대한 커스텀 설정이 해당 메트릭 스크레이핑 간격을 덮어써요.

각 collector.xxx.scrape_interval 옵션은 해당 컬렉터의 간격만 덮어쓰고 관련된 메트릭 집합을 업데이트해요.

덮어쓴 간격은 수집 간격만 바꾸고, 메트릭을 게시하는 간격은 바꾸지 않아요. 게시 간격은 전역 설정에서 가져와요.

예를 들어 전역 간격이 1로 설정되고 덮어쓰기 간격이 60이면 게시된 메트릭은 매 초마다 보고돼요. 하지만 해당 컬렉터는 다시 수집될 때까지 60초 동안 동일하게 유지돼요.

이렇게 하면 메트릭 수집 시 다운샘플링(down-sampling)에 도움이 돼요.

Key Description Default
scrape_interval The rate in seconds at which metrics are collected from the Windows host. 1
enable_collector Enable one collector by name. This key can be specified multiple times to build an allow-list of collectors to run. none
we.logical_disk.allow_disk_regex Specify the regular expression for logical disk metrics to allow collection of. "/.+/" (all)
we.logical_disk.deny_disk_regex Specify the regular expression for logical disk metrics to prevent collection of or ignore. NULL (all)
we.net.allow_nic_regex Specify the regular expression for network metrics captured by the name of the NIC. "/.+/" (all)
we.service.where Specify the WHERE clause for retrieving service metrics. NULL
we.service.include Specify the key-value pairs for the include condition for the WHERE clause of service metrics. NULL
we.service.exclude Specify the key value pairs for the exclude condition for the WHERE clause of service metrics. NULL
we.process.allow_process_regex Specify the regular expression covering the process metrics to collect. "/.+/" (all)
we.process.deny_process_regex Specify the regular expression for process metrics to prevent collection of or ignore. NULL (all)
collector.cpu.scrape_interval The rate in seconds at which cpu metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.net.scrape_interval The rate in seconds at which net metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.logical_disk.scrape_interval The rate in seconds at which logical_disk metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.cs.scrape_interval The rate in seconds at which cs metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.os.scrape_interval The rate in seconds at which os metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.thermalzone.scrape_interval The rate in seconds at which thermalzone metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.cpu_info.scrape_interval The rate in seconds at which cpu_info metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.logon.scrape_interval The rate in seconds at which logon metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.system.scrape_interval The rate in seconds at which system metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.service.scrape_interval The rate in seconds at which service metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.memory.scrape_interval The rate in seconds at which memory metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.paging_file.scrape_interval The rate in seconds at which paging_file metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.process.scrape_interval The rate in seconds at which process metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.tcp.scrape_interval The rate in seconds at which tcp metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.cache.scrape_interval The rate in seconds at which cache metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
collector.performancecounter.scrape_interval The rate in seconds at which performancecounter metrics are collected. Values greater than 0 override the global default. Otherwise, the global default is used. 0
performancecounter Define a Windows Performance Counter to collect. This key can be specified multiple times. Use the metric_name=counter_path form, where metric_name is user-defined. none
metrics Specify which metrics are collected. Comma-separated list of collector names. "cpu,cpu_info,os,net,logical_disk,cs,cache,thermalzone,logon,system,service,tcp"

사용 가능한 컬렉터

다음 표는 이 플러그인의 일부로 사용 가능한 컬렉터들을 설명해요. 모든 컬렉터는 기본적으로 활성화되어 있고 원래 Prometheus Windows Exporter의 메트릭 이름, 설명, 타입을 그대로 따르기 때문에 문제없이 기존 대시보드를 그대로 사용할 수 있어요.

Version 열은 해당 컬렉터가 사용 가능한 Fluent Bit 버전을 나타내요.

Name Description OS Version
cpu Exposes CPU statistics including utilization, interrupts, and DPCs. Windows v1.9
net Exposes network interface statistics such as bytes transferred, packets, and errors. Windows v2.0.8
logical_disk Exposes logical disk statistics including read/write operations, latency, and free space. Windows v2.0.8
cs Exposes computer system statistics including model, manufacturer, and system type. Windows v2.0.8
os Exposes operating system statistics including version, build number, and service pack information. Windows v2.0.8
thermalzone Exposes thermal zone statistics including temperature readings. Windows v2.0.8
cpu_info Exposes CPU information including model, cores, threads, and clock speed. Windows v2.0.8
logon Exposes logon session statistics including active sessions and session types. Windows v2.0.8
system Exposes system-level statistics including uptime, processes, and threads. Windows v2.0.8
service Exposes Windows service statistics including service state, start mode, and status. Windows v2.1.6
memory Exposes memory statistics including available, cached, and committed bytes. Windows v2.1.9
paging_file Exposes paging file statistics including usage, peak usage, and allocation. Windows v2.1.9
process Exposes process-level statistics including CPU usage, memory consumption, handles, and threads per process. Windows v2.1.9
tcp Exposes TCP connection statistics including active connections, segments, and errors. Windows v4.1.0
cache Exposes cache statistics including cache hits, misses, and utilization. Windows v4.1.0
performancecounter Exposes user-defined Windows Performance Counters through Performance Data Helper. Windows v5.0.8

스레딩

이 입력은 항상 자체 스레드에서 실행돼요.

시작하기 (Get started)

설정 파일

다음 설정 파일에서 windows_exporter_metrics 입력 플러그인은 metrics를 2초마다 수집하고 HTTP/TCP 포트 2021의 Prometheus Exporter 출력 플러그인을 통해 노출해요.

fluent-bit.yaml:

# Windows Exporter Metrics + Prometheus Exporter
# -------------------------------------------
# The following example collects Windows host metrics and exposes
# them through a Prometheus HTTP endpoint.
#
# After starting the service try it with:
#
# $ curl http://127.0.0.1:2021/metrics
#
service:
  flush: 1
  log_level: info

pipeline:
  inputs:
    - name: windows_exporter_metrics
      tag: node_metrics
      scrape_interval: 2

  outputs:
    - name: prometheus_exporter
      match: node_metrics
      port: 2021

fluent-bit.conf:

# Windows Exporter Metrics + Prometheus Exporter
# -------------------------------------------
# The following example collects Windows host metrics and exposes
# them through a Prometheus HTTP endpoint.
#
# After starting the service try it with:
#
# $ curl http://127.0.0.1:2021/metrics
#
[SERVICE]
  Flush           1
  Log_Level       info

[INPUT]
  Name            windows_exporter_metrics
  Tag             node_metrics
  Scrape_Interval 2

[OUTPUT]
  Name            prometheus_exporter
  Match           node_metrics
  Host            0.0.0.0
  Port            2021

curl을 사용해 메트릭 노출을 테스트할 수 있어요.

curl http://127.0.0.1:2021/metrics

디스크 및 네트워크 메트릭 필터링

Windows Exporter metrics 플러그인은 정규 표현식을 사용해 논리 디스크와 네트워크 인터페이스 메트릭을 필터링하는 것을 지원해요.

논리 디스크 필터링

we.logical_disk.allow_disk_regex와 we.logical_disk.deny_disk_regex를 사용해 메트릭에 포함할 논리 디스크를 제어해요.

C:와 D: 드라이브에서만 메트릭을 수집하는 예시 구성은 다음과 같아요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: windows_exporter_metrics
      tag: windows_metrics
      we.logical_disk.allow_disk_regex: "^(C|D):$"

fluent-bit.conf:

[INPUT]
  Name                        windows_exporter_metrics
  Tag                         windows_metrics
  we.logical_disk.allow_disk_regex ^(C|D):$

네트워크 인터페이스 필터링

we.net.allow_nic_regex를 사용해 이름별로 네트워크 인터페이스를 필터링해요.

Ethernet과 Wi-Fi 어댑터에서만 메트릭을 수집하는 예시 구성은 다음과 같아요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: windows_exporter_metrics
      tag: windows_metrics
      we.net.allow_nic_regex: "(Ethernet|Wi-Fi)"

fluent-bit.conf:

[INPUT]
  Name            windows_exporter_metrics
  Tag             windows_metrics
  we.net.allow_nic_regex (Ethernet|Wi-Fi)

프로세스 필터링

we.process.allow_process_regex와 we.process.deny_process_regex를 사용해 메트릭에 포함할 프로세스를 제어해요.

시스템 프로세스를 제외하는 예시 구성은 다음과 같아요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: windows_exporter_metrics
      tag: windows_metrics
      we.process.deny_process_regex: "(System|Idle|svchost)"

fluent-bit.conf:

[INPUT]
  Name                      windows_exporter_metrics
  Tag                       windows_metrics
  we.process.deny_process_regex (System|Idle|svchost)

서비스 WHERE 절

Windows service 컬렉터는 로컬 노드나 컨테이너의 모든 서비스 정보를 가져와요. we.service.where, we.service.include, we.service.exclude를 사용해 서비스 메트릭을 필터링할 수 있어요.

이 메트릭들을 필터링하려면 WHERE 절을 지정해야 해요. 이 문법은 WMI Query Language (WQL)에 정의되어 있어요.

이 파라미터들이 어떻게 동작하는지는 다음과 같아요.

we.service.where

we.service.where는 원시(raw) WHERE 절로 처리돼요. 예를 들어 사용자가 다음과 같이 파라미터를 지정하면:

we.service.where Status!='OK'

다음과 같은 WMI 쿼리가 생성돼요.

SELECT * FROM Win32_Service WHERE Status!='OK'

그러면 WMI 메커니즘이 이를 처리하고, 이 예시에서는 not OK 상태를 가진 정보를 반환해요.

we.service.include

정의되면 we.service.include는 WHERE 절로 해석돼요. 여러 키-값 쌍이 지정되면 값들은 OR로 연결돼요. 또한 값에 % 문자가 포함되면 절에서 = 연산자 대신 LIKE 연산자가 사용돼요. 사용자가 다음과 같이 파라미터를 지정하면:

we.service.include {"Name":"docker","Name":"%Svc%", "Name":"%Service"}

파라미터는 다음과 같이 해석돼요.

(Name='docker' OR Name LIKE '%Svc%' OR Name LIKE '%Service')

WMI 쿼리는 변환된 파라미터로 다음과 같이 호출돼요.

SELECT * FROM Win32_Service WHERE (Name='docker' OR Name LIKE '%Svc%' OR Name LIKE '%Service')

we.service.exclude

정의되면 we.service.exclude는 WHERE 절로 해석돼요. 여러 키-값 쌍이 지정되면 값들은 AND로 연결돼요.

또한 값에 % 문자가 포함되면 변환된 절에서 != 연산자 대신 LIKE 연산자가 사용돼요. 사용자가 다음과 같이 파라미터를 지정하면:

we.service.exclude {"Name":"UdkUserSvc%","Name":"webthreatdefusersvc%","Name":"XboxNetApiSvc"}

파라미터는 다음과 같이 해석돼요.

(NOT Name LIKE 'UdkUserSvc%' AND NOT Name LIKE 'webthreatdefusersvc%' AND Name!='XboxNetApiSvc')

WMI 쿼리는 변환된 파라미터로 다음과 같이 호출돼요.

SELECT * FROM Win32_Service WHERE (NOT Name LIKE 'UdkUserSvc%' AND NOT Name LIKE 'webthreatdefusersvc%' AND Name!='XboxNetApiSvc')

고급 사용법

we.service.where, we.service.include, we.service.exclude는 다음 규칙에 따라 모두 동시에 사용할 수 있어요.

  1. we.service.include가 변환되어 service 컬렉터의 where 절에 적용돼요.
  2. we.service.exclude가 변환되어 service 컬렉터의 where 절에 적용돼요.
    1. we.service.include가 적용되면, 변환된 we.service.include와 we.service.exclude 조건이 AND로 연결돼요.
  3. we.service.where는 그대로 service 컬렉터의 where 절에 적용돼요.
    1. 앞선 파라미터 중 하나라도 적용되면, 절은 AND ( we.service.where의 값 )로 적용돼요.

예를 들어 사용자가 다음과 같이 파라미터를 지정하면:

we.service.include {"Name":"docker","Name":"%Svc%", "Name":"%Service"}
we.service.exclude {"Name":"UdkUserSvc%","Name":"XboxNetApiSvc"}
we.service.where NOT Name LIKE 'webthreatdefusersvc%'

WMI 쿼리는 변환된 파라미터로 다음과 같이 호출돼요.

 SELECT * FROM Win32_Service WHERE (Name='docker' OR Name LIKE '%Svc%' OR Name LIKE '%Service') AND (NOT Name LIKE 'UdkUserSvc%' AND Name!='XboxNetApiSvc') AND (NOT Name LIKE 'webthreatdefusersvc%')

특정 컬렉터 선택

metrics 파라미터를 사용해 특정 메트릭만 수집하도록 플러그인을 구성할 수 있어요. 이를 사용해 리소스 사용을 줄이거나 특정 시스템 구성 요소에 집중할 수 있어요.

CPU, 메모리, 디스크 메트릭만 수집하는 예시 구성은 다음과 같아요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: windows_exporter_metrics
      tag: windows_metrics
      metrics: "cpu,memory,logical_disk"
      scrape_interval: 5

fluent-bit.conf:

[INPUT]
  Name            windows_exporter_metrics
  Tag             windows_metrics
  Metrics         cpu,memory,logical_disk
  Scrape_Interval 5

컬렉터별 커스텀 스크레이프 간격

개별 컬렉터에 대해 서로 다른 스크레이프 간격을 설정해 리소스 사용을 최적화할 수 있어요. 예를 들어 CPU 메트릭을 시스템 정보보다 더 자주 수집하고 싶을 수 있어요.

커스텀 간격이 있는 예시 구성은 다음과 같아요.

fluent-bit.yaml:

pipeline:
  inputs:
    - name: windows_exporter_metrics
      tag: windows_metrics
      scrape_interval: 10
      collector.cpu.scrape_interval: 5
      collector.memory.scrape_interval: 5
      collector.system.scrape_interval: 60

fluent-bit.conf:

[INPUT]
  Name                        windows_exporter_metrics
  Tag                         windows_metrics
  Scrape_Interval             10
  collector.cpu.scrape_interval 5
  collector.memory.scrape_interval 5
  collector.system.scrape_interval 60

이 예시에서 CPU와 메모리 메트릭은 5초마다, 시스템 메트릭은 60초마다 수집돼요. 전역 scrape_interval 10초는 메트릭이 출력에 게시되는 빈도를 결정해요.

커스텀 성능 카운터

performancecounter 컬렉터는 내장 컬렉터가 다루지 않는 Windows 성능 카운터를 노출해요. 성능 데이터 헬퍼(PDH)를 통해 카운터를 게시하는 Windows Server 역할, 애플리케이션, 드라이버, 또는 커스텀 구성 요소에 사용해요. 예로 Internet Information Services(IIS), Microsoft SQL Server(MSSQL), .NET Framework, GPU 엔진, 그리고 애플리케이션별 카운터 집합이 있어요.

이 컬렉터는 기본적으로 활성화되지 않아요. metrics에 performancecounter를 추가하고 하나 이상의 PerformanceCounter 항목을 정의해요. 각 항목은 name=counter_path 형식을 사용해요.

PerformanceCounter metric_name=\Object(instance)\Counter

Fluent Bit는 구성된 각 카운터를 windows_performancecounter_<metric_name>이라는 이름의 gauge로 내보내요.

예시 구성:

[SERVICE]
    Flush_Interval 3
    HTTP_Server    on
    HTTP_Port      2020
    Log_Level      debug

[INPUT]
    Name             windows_exporter_metrics
    Tag              windows
    Scrape_Interval  2
    Metrics          cpu,logical_disk,memory,performancecounter

    PerformanceCounter process_fluent_bit_thread_count=\Process(fluent-bit)\Thread Count
    PerformanceCounter gpu_3d_utilization=\GPU Engine(*engtype_3D)\Utilization Percentage
    PerformanceCounter gpu_copy_utilization=\GPU Engine(*engtype_Copy)\Utilization Percentage
    PerformanceCounter gpu_video_decode_utilization=\GPU Engine(*engtype_VideoDecode)\Utilization Percentage

[OUTPUT]
    Name stdout

이 구성은 다음과 같은 메트릭을 만들어요.

windows_performancecounter_process_fluent_bit_thread_count
windows_performancecounter_gpu_3d_utilization
windows_performancecounter_gpu_copy_utilization
windows_performancecounter_gpu_video_decode_utilization

와일드카드 카운터 경로는 컬렉터가 시작될 때 확장돼요. 카운터 경로에 인스턴스가 포함되면 Fluent Bit는 인스턴스 이름을 instance 라벨로 추가해요.

windows_performancecounter_gpu_3d_utilization{instance="pid_2660_luid_0x00000000_0x0001406D_phys_0_eng_0_engtype_3D#0"} = 14.387620901817147

요구 사항 및 권한

Windows Exporter metrics 플러그인은 Windows Management Instrumentation(WMI)과 Performance Data Helper(PDH)를 사용해 메트릭을 수집해요. 다음 요구 사항이 적용돼요.

  • 운영체제: Windows 전용(Windows 7/Server 2008 R2 이상)
  • 권한: Fluent Bit 프로세스는 WMI와 구성된 성능 카운터를 쿼리할 수 있는 적절한 권한이 있어야 해요. 대부분의 메트릭은 표준 사용자 권한으로 수집할 수 있지만, 일부 컬렉터는 상승된 권한이 필요할 수 있어요.
  • WMI 서비스: Windows Management Instrumentation 서비스가 실행 중이어야 해요.

권한 오류가 발생하면 관리자 권한으로 Fluent Bit를 실행해 보거나, 서비스 계정에 필요한 WMI 쿼리 권한이 있는지 확인해요.

개선 요청

이 플러그인은 원래 Prometheus Windows Exporter에 있는 컬렉터 중 일부만 구현해요. 특정 컬렉터를 우선시하고 싶다면 다음 템플릿을 사용해 GitHub 이슈를 열어 줘요.

더 알아보기 (Learn more)