Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_windows_exporter_metrics: Add service metrics support #7597

Merged
merged 4 commits into from
Jul 3, 2023

Conversation

cosmo0920
Copy link
Contributor

@cosmo0920 cosmo0920 commented Jun 22, 2023

Fixes #6669

windows exporter should support service collector.
Our service collector should be WMI based collector for now.
Also, it has where clause support.

Not specifying where clause, service collector just retrieves entire service information on the local box.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
[SERVICE]
   flush_interval 10s

[INPUT]
   Name windows_exporter_metrics
   scrape_interval 10s
   metrics service
   # we.service.where Status!='OK'
   # we.service.where Name='docker' OR Name='WinRM' OR Name LIKE 'PenService%'
   # we.service.where (Name='docker' OR Name='WinRM')
   # we.service.where (Name='docker' OR Name LIKE '%Svc%' OR Name LIKE '%Service') AND (NOT Name LIKE 'UdkUserSvc%' AND NOT Name LIKE 'webthreatdefusersvc%' AND Name!='Steam Client Service')
   we.service.include {"Name":"docker","Name":"%Svc%", "Name":"%Service"}
   # we.service.exclude {"Name":"UdkUserSvc%","Name":"webthreatdefusersvc%","Name":"XboxNetApiSvc"}
   we.service.where NOT Name LIKE 'UdkUserSvc%' AND NOT Name LIKE 'webthreatdefusersvc%' AND Name!='XboxNetApiSvc'

[OUTPUT]
   Name stdout
  • Debug log output from testing the change
Fluent Bit v2.1.5
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/06/22 16:54:41] [ info] Configuration:
[2023/06/22 16:54:41] [ info]  flush time     | 1.000000 seconds
[2023/06/22 16:54:41] [ info]  grace          | 5 seconds
[2023/06/22 16:54:41] [ info]  daemon         | 0
[2023/06/22 16:54:41] [ info] ___________
[2023/06/22 16:54:41] [ info]  inputs:
[2023/06/22 16:54:41] [ info]      windows_exporter_metrics
[2023/06/22 16:54:41] [ info] ___________
[2023/06/22 16:54:41] [ info]  filters:
[2023/06/22 16:54:41] [ info] ___________
[2023/06/22 16:54:41] [ info]  outputs:
[2023/06/22 16:54:41] [ info]      stdout.0
[2023/06/22 16:54:41] [ info] ___________
[2023/06/22 16:54:41] [ info]  collectors:
[2023/06/22 16:54:41] [ info] [fluent bit] version=2.1.5, commit=41d3e17a43, pid=23324
[2023/06/22 16:54:41] [debug] [engine] coroutine stack size: 98302 bytes (96.0K)
[2023/06/22 16:54:41] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/06/22 16:54:41] [ info] [cmetrics] version=0.6.1
[2023/06/22 16:54:41] [ info] [ctraces ] version=0.3.1
[2023/06/22 16:54:41] [ info] [input:windows_exporter_metrics:windows_exporter_metrics.0] initializing
[2023/06/22 16:54:41] [ info] [input:windows_exporter_metrics:windows_exporter_metrics.0] storage_strategy='memory' (memory only)
[2023/06/22 16:54:41] [debug] [windows_exporter_metrics:windows_exporter_metrics.0] created event channels: read=876 write=880
[2023/06/22 16:54:41] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] enabled metrics service
[2023/06/22 16:54:41] [debug] [stdout:stdout.0] created event channels: read=904 write=1268
[2023/06/22 16:54:41] [ info] [sp] stream processor started
[2023/06/22 16:54:41] [ info] [output:stdout:stdout.0] worker #0 started
[2023/06/22 16:54:51] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] initializing WMI instance....)
[2023/06/22 16:54:51] [debug] [input:windows_exporter_metrics:windows_exporter_metrics.0] deinitializing WMI instance....
[2023/06/22 16:54:51] [debug] [input chunk] update output instances with new chunk size diff=294845, records=0, input=windows_exporter_metrics.0
[2023/06/22 16:54:52] [debug] [task] created task=0000012CC58DD420 id=0 OK
[2023/06/22 16:54:52] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
2023-06-22T07:54:51.121886700Z windows_service_info{name="AppIDSvc",display_name="Application Identity",process_id="0",run_as="NT Authority\LocalService"} = 1
2023-06-22T07:54:51.121886700Z windows_service_info{name="Apple Mobile Device Service",display_name="Apple Mobile Device Service",process_id="5972",run_as="LocalSystem"} = 1
2023-06-22T07:54:51.121886700Z windows_service_info{name="AppXSvc",display_name="AppX Deployment Service (AppXSVC)",process_id="2268",run_as="LocalSystem"} = 1
<snip>
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="stopped"} = 1
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="start pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="stop pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="running"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="continue pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="pause pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="paused"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppIDSvc",state="unknown"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="stopped"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="start pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="stop pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="running"} = 1
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="continue pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="pause pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="paused"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="Apple Mobile Device Service",state="unknown"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="stopped"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="start pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="stop pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="running"} = 1
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="continue pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="pause pending"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="paused"} = 0
2023-06-22T07:54:51.121886700Z windows_service_state{name="AppXSvc",state="unknown"} = 0
<snip>
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="ok"} = 1
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="error"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="degraded"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="unknown"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="pred fail"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="starting"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="stopping"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="service"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="stressed"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="nonrecover"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="no contact"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="PrintWorkflowUserSvc_25bc49",status="lost comm"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="ok"} = 1
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="error"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="degraded"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="unknown"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="pred fail"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="starting"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="stopping"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="service"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="stressed"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="nonrecover"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="no contact"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UnistoreSvc_25bc49",status="lost comm"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="ok"} = 1
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="error"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="degraded"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="unknown"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="pred fail"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="starting"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="stopping"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="service"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="stressed"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="nonrecover"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="no contact"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="UserDataSvc_25bc49",status="lost comm"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="ok"} = 1
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="error"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="degraded"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="unknown"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="pred fail"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="starting"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="stopping"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="service"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="stressed"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="nonrecover"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="no contact"} = 0
2023-06-22T07:54:51.121886700Z windows_service_status{name="docker",status="lost comm"} = 0
<snip>
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@cosmo0920 cosmo0920 temporarily deployed to pr June 22, 2023 08:54 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr June 22, 2023 08:54 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr June 22, 2023 08:54 — with GitHub Actions Inactive
@cosmo0920 cosmo0920 temporarily deployed to pr June 22, 2023 09:17 — with GitHub Actions Inactive
@edsiper edsiper merged commit a36f95e into master Jul 3, 2023
@edsiper edsiper deleted the cosmo0920-windows-service-metrics branch July 3, 2023 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

in_windows_exporter_metrics: add service collector
2 participants