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

[8.x](backport #42017) [Metricbeat] Windows Module add wmi metricset #42505

Open
wants to merge 1 commit into
base: 8.x
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jan 30, 2025

Proposed commit message

[Metricbeat][Windows] Add experimental wmi metricset

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

This PR does not have impact to existing use-cases

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

As a windows user I want to leverage WMI (and in particular WQL, SQL for WMI) to extract detailed system information and metrics.

Screenshots

Logs


This is an automatic backport of pull request #42017 done by [Mergify](https://mergify.com).

* Add stub for wmi module

* Execute mage update

* Add first draft of wmi metricset

* Add first draft of wmi windows module

* Add config unit test

* Add unit test for the config class

* Add license notice mage fmt

* Add License to wmi/wmi.go

* Update example

* Use wrapping fromat verb for fmt.Errorf

* Fix mispelled comment

* Add first draft of the documentation

* Add the config reference and config file

* Bump microsfot/wmi to 0.25.1

* Make sure the wmi metricset is only used on windows

* Run mage update

* Add License for microsoft/wmi library in Notice.txt

* Add Timeout configuration

* Introduce the ExecuteGuardedQueryInstances to wait for at most a timeout for the result

* Add invokation of CloseAllInstances() to make sure to free resources after need

* Add license header to utils.go

* Rename timeout to warning_threshold to conceive the message that the query is not actually cancelled

* Refactor the ExecuteGuardedQueryInstances to use the context.WithTimeout

* Add unit test for ExecuteGuardedQueryInstances
Add an interface WmiQueryInterface to allow mocking the session object

* Add parameter IncludeEmptyString. Create function to check skip conditions and add a test

* Add namespace at the query level and add a structure to index queries on the namespace. Add logic to create a single connection per Namespace

* Rename the config method to be more explicit

* Add Primitives to deal with the type convrsion for strings

* Add unit test for the conversion function

* Add heuristic to determine if fetching the CIMType is needed

* Add type conversion

* Improve comments to explicitly state what are the config parameters used for

* Add license header to wmi and utils test

* Run mage fmt

* Update the reference config after the final implementation

* Remove the dummy field definition

* Add sample data in the data.json file

* Fix go.mod and change NOTICE.txt to reflect the fact that go-ole is now directly used in the WMI module

* Make sure that the wmi tests run only on windows

* Improve the error message to prepare a Troubleshooting Guide

* Fix test to use right function

* Add doc.go file

* Add pragma to avoid compiling utils.go on platforms other than windows

* Run make update BEATS=metricbeat

* Use Metricset Logger instead of generic one in wmi.go

* Make sure that we are using the Metricset logger everywhere. Address linting error caused by not checking the return of rawResult.Clear()

* Run make updates BEATS=metricbeat

* Get rid of duplicated rawResult.Clear()

* Review: remove redundant multiplication by time.Second

* Review: Fix grammar of error

* Review: Get rid of the panic

* Review: Remove redundant check

* Review: Make the namespace settings easier to understand

* Review: Honor the query-level namespace in the output document and move the field type caching at the query level rather than namespace level

* Add a warning if a given query is not producing results

* Fix golint warning

* add results of 'make update'

* Add changelog entry for the wmi metricset

* Fix pull request number

* Add an explicit variable for the converted field and double check if the cast is safe

* Make warning easier to read

* Add empty newline in the config.yml

* Add codeowners entry for wmi

* Add windows.yml.disabled

* Modify codeowners at the dataset level

* Fix test after renaming of the error message

* Update metricbeat/docs/modules/windows.asciidoc

Co-authored-by: Liam Thompson <[email protected]>

* Fix config reference to generate correct doc

* Update xpack metricbeat.reference.yml

---------

Co-authored-by: tommyers-elastic <[email protected]>
Co-authored-by: Ishleen Kaur <[email protected]>
Co-authored-by: Liam Thompson <[email protected]>
(cherry picked from commit 35fbdce)
@mergify mergify bot requested review from a team as code owners January 30, 2025 15:25
@mergify mergify bot added the backport label Jan 30, 2025
@mergify mergify bot requested review from AndersonQ and khushijain21 and removed request for a team January 30, 2025 15:25
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 30, 2025
@botelastic
Copy link

botelastic bot commented Jan 30, 2025

This pull request doesn't have a Team:<team> label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant