grafana-agent内置了windows_exporter的实现,可以采集到windows平台的指标。

配置并启用windows_exporter

  1. # grafana-agent 本身的配置
  2. server:
  3. log_level: info
  4. http_listen_port: 12345
  5. # grafana-agent 抓取 metrics 的相关配置(类似于prometheus的scrape_configs)
  6. metrics:
  7. global:
  8. scrape_interval: 15s
  9. scrape_timeout: 10s
  10. remote_write:
  11. - url: https://n9e-server:19000/prometheus/v1/write
  12. basic_auth:
  13. username: <string>
  14. password: <string>
  15. integrations:
  16. windows_exporter:
  17. enabled: true

采集的关键指标列表

  1. windows_cpu_clock_interrupts_total: Total number of received and serviced clock tick interrupts(counter)
  2. windows_cpu_core_frequency_mhz: Core frequency in megahertz(gauge)
  3. windows_cpu_cstate_seconds_total: Time spent in low-power idle state(counter)
  4. windows_cpu_dpcs_total: Total number of received and serviced deferred procedure calls (DPCs)(counter)
  5. windows_cpu_idle_break_events_total: Total number of time processor was woken from idle(counter)
  6. windows_cpu_interrupts_total: Total number of received and serviced hardware interrupts(counter)
  7. windows_cpu_parking_status: Parking Status represents whether a processor is parked or not(gauge)
  8. windows_cpu_processor_performance: Processor Performance is the average performance of the processor while it is executing instructions, as a percentage of the nominal performance of the processor. On some processors, Processor Performance may exceed 100%(gauge)
  9. windows_cpu_time_total: Time that processor spent in different modes (idle, user, system, ...)(counter)
  10. windows_cs_hostname: Labeled system hostname information as provided by ComputerSystem.DNSHostName and ComputerSystem.Domain(gauge)
  11. windows_cs_logical_processors: ComputerSystem.NumberOfLogicalProcessors(gauge)
  12. windows_cs_physical_memory_bytes: ComputerSystem.TotalPhysicalMemory(gauge)
  13. windows_exporter_build_info: A metric with a constant '1' value labeled by version, revision, branch, and goversion from which windows_exporter was built.(gauge)
  14. windows_exporter_collector_duration_seconds: Duration of a collection.(gauge)
  15. windows_exporter_collector_success: Whether the collector was successful.(gauge)
  16. windows_exporter_collector_timeout: Whether the collector timed out.(gauge)
  17. windows_exporter_perflib_snapshot_duration_seconds: Duration of perflib snapshot capture(gauge)
  18. windows_logical_disk_free_bytes: Free space in bytes (LogicalDisk.PercentFreeSpace)(gauge)
  19. windows_logical_disk_idle_seconds_total: Seconds that the disk was idle (LogicalDisk.PercentIdleTime)(counter)
  20. windows_logical_disk_read_bytes_total: The number of bytes transferred from the disk during read operations (LogicalDisk.DiskReadBytesPerSec)(counter)
  21. windows_logical_disk_read_latency_seconds_total: Shows the average time, in seconds, of a read operation from the disk (LogicalDisk.AvgDiskSecPerRead)(counter)
  22. windows_logical_disk_read_seconds_total: Seconds that the disk was busy servicing read requests (LogicalDisk.PercentDiskReadTime)(counter)
  23. windows_logical_disk_read_write_latency_seconds_total: Shows the time, in seconds, of the average disk transfer (LogicalDisk.AvgDiskSecPerTransfer)(counter)
  24. windows_logical_disk_reads_total: The number of read operations on the disk (LogicalDisk.DiskReadsPerSec)(counter)
  25. windows_logical_disk_requests_queued: The number of requests queued to the disk (LogicalDisk.CurrentDiskQueueLength)(gauge)
  26. windows_logical_disk_size_bytes: Total space in bytes (LogicalDisk.PercentFreeSpace_Base)(gauge)
  27. windows_logical_disk_split_ios_total: The number of I/Os to the disk were split into multiple I/Os (LogicalDisk.SplitIOPerSec)(counter)
  28. windows_logical_disk_write_bytes_total: The number of bytes transferred to the disk during write operations (LogicalDisk.DiskWriteBytesPerSec)(counter)
  29. windows_logical_disk_write_latency_seconds_total: Shows the average time, in seconds, of a write operation to the disk (LogicalDisk.AvgDiskSecPerWrite)(counter)
  30. windows_logical_disk_write_seconds_total: Seconds that the disk was busy servicing write requests (LogicalDisk.PercentDiskWriteTime)(counter)
  31. windows_logical_disk_writes_total: The number of write operations on the disk (LogicalDisk.DiskWritesPerSec)(counter)
  32. windows_net_bytes_received_total: (Network.BytesReceivedPerSec)(counter)
  33. windows_net_bytes_sent_total: (Network.BytesSentPerSec)(counter)
  34. windows_net_bytes_total: (Network.BytesTotalPerSec)(counter)
  35. windows_net_current_bandwidth: (Network.CurrentBandwidth)(gauge)
  36. windows_net_packets_outbound_discarded_total: (Network.PacketsOutboundDiscarded)(counter)
  37. windows_net_packets_outbound_errors_total: (Network.PacketsOutboundErrors)(counter)
  38. windows_net_packets_received_discarded_total: (Network.PacketsReceivedDiscarded)(counter)
  39. windows_net_packets_received_errors_total: (Network.PacketsReceivedErrors)(counter)
  40. windows_net_packets_received_total: (Network.PacketsReceivedPerSec)(counter)
  41. windows_net_packets_received_unknown_total: (Network.PacketsReceivedUnknown)(counter)
  42. windows_net_packets_sent_total: (Network.PacketsSentPerSec)(counter)
  43. windows_net_packets_total: (Network.PacketsPerSec)(counter)
  44. windows_os_info: OperatingSystem.Caption, OperatingSystem.Version(gauge)
  45. windows_os_paging_free_bytes: OperatingSystem.FreeSpaceInPagingFiles(gauge)
  46. windows_os_paging_limit_bytes: OperatingSystem.SizeStoredInPagingFiles(gauge)
  47. windows_os_physical_memory_free_bytes: OperatingSystem.FreePhysicalMemory(gauge)
  48. windows_os_process_memory_limix_bytes: OperatingSystem.MaxProcessMemorySize(gauge)
  49. windows_os_processes: OperatingSystem.NumberOfProcesses(gauge)
  50. windows_os_processes_limit: OperatingSystem.MaxNumberOfProcesses(gauge)
  51. windows_os_time: OperatingSystem.LocalDateTime(gauge)
  52. windows_os_timezone: OperatingSystem.LocalDateTime(gauge)
  53. windows_os_users: OperatingSystem.NumberOfUsers(gauge)
  54. windows_os_virtual_memory_bytes: OperatingSystem.TotalVirtualMemorySize(gauge)
  55. windows_os_virtual_memory_free_bytes: OperatingSystem.FreeVirtualMemory(gauge)
  56. windows_os_visible_memory_bytes: OperatingSystem.TotalVisibleMemorySize(gauge)
  57. windows_service_info: A metric with a constant '1' value labeled with service information(gauge)
  58. windows_service_start_mode: The start mode of the service (StartMode)(gauge)
  59. windows_service_state: The state of the service (State)(gauge)
  60. windows_service_status: The status of the service (Status)(gauge)
  61. windows_system_context_switches_total: Total number of context switches (WMI source is PerfOS_System.ContextSwitchesPersec)(counter)
  62. windows_system_exception_dispatches_total: Total number of exceptions dispatched (WMI source is PerfOS_System.ExceptionDispatchesPersec)(counter)
  63. windows_system_processor_queue_length: Length of processor queue (WMI source is PerfOS_System.ProcessorQueueLength)(gauge)
  64. windows_system_system_calls_total: Total number of system calls (WMI source is PerfOS_System.SystemCallsPersec)(counter)
  65. windows_system_system_up_time: System boot time (WMI source is PerfOS_System.SystemUpTime)(gauge)
  66. windows_system_threads: Current number of threads (WMI source is PerfOS_System.Threads)(gauge)

完整地配置项说明

  1. # Enables the windows_exporter integration, allowing the Agent to automatically
  2. # collect system metrics from the local windows instance
  3. [enabled: <boolean> | default = false]
  4. # Sets an explicit value for the instance label when the integration is
  5. # self-scraped. Overrides inferred values.
  6. #
  7. # The default value for this integration is inferred from the agent hostname
  8. # and HTTP listen port, delimited by a colon.
  9. [instance: <string>]
  10. # Automatically collect metrics from this integration. If disabled,
  11. # the consul_exporter integration will be run but not scraped and thus not
  12. # remote-written. Metrics for the integration will be exposed at
  13. # /integrations/windows_exporter/metrics and can be scraped by an external
  14. # process.
  15. [scrape_integration: <boolean> | default = <integrations_config.scrape_integrations>]
  16. # How often should the metrics be collected? Defaults to
  17. # prometheus.global.scrape_interval.
  18. [scrape_interval: <duration> | default = <global_config.scrape_interval>]
  19. # The timeout before considering the scrape a failure. Defaults to
  20. # prometheus.global.scrape_timeout.
  21. [scrape_timeout: <duration> | default = <global_config.scrape_timeout>]
  22. # Allows for relabeling labels on the target.
  23. relabel_configs:
  24. [- <relabel_config> ... ]
  25. # Relabel metrics coming from the integration, allowing to drop series
  26. # from the integration that you don't care about.
  27. metric_relabel_configs:
  28. [ - <relabel_config> ... ]
  29. # How frequent to truncate the WAL for this integration.
  30. [wal_truncate_frequency: <duration> | default = "60m"]
  31. # Monitor the exporter itself and include those metrics in the results.
  32. [include_exporter_metrics: <bool> | default = false]
  33. #
  34. # Exporter-specific configuration options
  35. #
  36. # List of collectors to enable. Any non-experimental collector from the
  37. # embeded version of windows_exporter can be enabeld here.
  38. [enabled_collectors: <string> | default = "cpu,cs,logical_disk,net,os,service,system,textfile"]
  39. # Settings for collectors which accept configuration. Settings specified here
  40. # are only used if the corresponding collector is enabled in
  41. # enabled_collectors.
  42. # Configuration for Exchange Mail Server
  43. exchange:
  44. # Comma-separated List of collectors to use. Defaults to all, if not specified.
  45. # Maps to collectors.exchange.enabled in windows_exporter
  46. [enabled_list: <string>]
  47. # Configuration for the IIS web server
  48. iis:
  49. # Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included.
  50. # Maps to collector.iis.site-whitelist in windows_exporter
  51. [site_whitelist: <string> | default = ".+"]
  52. # Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.
  53. # Maps to collector.iis.site-blacklist in windows_exporter
  54. [site_blacklist: <string> | default = ""]
  55. # Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included.
  56. # Maps to collector.iis.app-whitelist in windows_exporter
  57. [app_whitelist: <string> | default=".+"]
  58. # Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.
  59. # Maps to collector.iis.app-blacklist in windows_exporter
  60. [app_blacklist: <string> | default=".+"]
  61. # Configuration for reading metrics from a text files in a directory
  62. text_file:
  63. # Directory to read text files with metrics from.
  64. # Maps to collector.textfile.directory in windows_exporter
  65. [text_file_directory: <string> | default="C:\Program Files\windows_exporter\textfile_inputs"]
  66. # Configuration for SMTP metrics
  67. smtp:
  68. # Regexp of virtual servers to whitelist. Server name must both match whitelist and not match blacklist to be included.
  69. # Maps to collector.smtp.server-whitelist in windows_exporter
  70. [whitelist: <string> | default=".+"]
  71. # Regexp of virtual servers to blacklist. Server name must both match whitelist and not match blacklist to be included.
  72. # Maps to collector.smtp.server-blacklist in windows_exporter
  73. [blacklist: <string> | default=""]
  74. # Configuration for Windows Services
  75. service:
  76. # "WQL 'where' clause to use in WMI metrics query. Limits the response to the services you specify and reduces the size of the response.
  77. # Maps to collector.service.services-where in windows_exporter
  78. [where_clause: <string> | default=""]
  79. # Configuration for Windows Processes
  80. process:
  81. # Regexp of processes to include. Process name must both match whitelist and not match blacklist to be included.
  82. # Maps to collector.process.whitelist in windows_exporter
  83. [whitelist: <string> | default=".+"]
  84. # Regexp of processes to exclude. Process name must both match whitelist and not match blacklist to be included.
  85. # Maps to collector.process.blacklist in windows_exporter
  86. [blacklist: <string> | default=""]
  87. # Configuration for NICs
  88. network:
  89. # Regexp of NIC's to whitelist. NIC name must both match whitelist and not match blacklist to be included.
  90. # Maps to collector.net.nic-whitelist in windows_exporter
  91. [whitelist: <string> | default=".+"]
  92. # Regexp of NIC's to blacklist. NIC name must both match whitelist and not match blacklist to be included.
  93. # Maps to collector.net.nic-blacklist in windows_exporter
  94. [blacklist: <string> | default=""]
  95. # Configuration for Microsoft SQL Server
  96. mssql:
  97. # Comma-separated list of mssql WMI classes to use.
  98. # Maps to collectors.mssql.classes-enabled in windows_exporter
  99. [enabled_classes: <string> | default="accessmethods,availreplica,bufman,databases,dbreplica,genstats,locks,memmgr,sqlstats,sqlerrors,transactions"]
  100. # Configuration for Microsoft Queue
  101. msqm:
  102. # WQL 'where' clause to use in WMI metrics query. Limits the response to the msmqs you specify and reduces the size of the response.
  103. # Maps to collector.msmq.msmq-where in windows_exporter
  104. [where_clause: <string> | default=""]
  105. # Configuration for disk information
  106. logical_disk:
  107. # Regexp of volumes to whitelist. Volume name must both match whitelist and not match blacklist to be included.
  108. # Maps to collector.logical_disk.volume-whitelist in windows_exporter
  109. [whitelist: <string> | default=".+"]
  110. # Regexp of volumes to blacklist. Volume name must both match whitelist and not match blacklist to be included.
  111. # Maps to collector.logical_disk.volume-blacklist in windows_exporter
  112. [blacklist: <string> | default=".+"]