Skip to content

Commit 567e4d5

Browse files
mergify[bot]herrBezvishaangelova
authored
[8.19](backport #45068) Wmi fix doc based on feedback (#47155)
* Wmi fix doc based on feedback (#45068) * Add windows 11 to compatibility section * WIP: Improve documentation after support feedback + Improve cache explanation * Use tag note instead of info * Improve wording * Make sure the warning is marked as such, use a more precise link * Fix comma * Fix some wording * Update docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md Co-authored-by: Visha Angelova <[email protected]> * Update docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md Co-authored-by: Visha Angelova <[email protected]> * Update docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md Co-authored-by: Visha Angelova <[email protected]> * Update docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md Co-authored-by: Visha Angelova <[email protected]> * Update docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md Co-authored-by: Visha Angelova <[email protected]> * Update docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md Co-authored-by: Visha Angelova <[email protected]> * Clarify the wmi.schema_cache_size based on the comments * Make sure to update docs.md as well * Remove erronously added line --------- Co-authored-by: Visha Angelova <[email protected]> (cherry picked from commit f23a53a) # Conflicts: # docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md # metricbeat/module/windows/wmi/_meta/docs.md * Remove conflict * Update WMI asciidoc according to original PR * Remove markdown files that belong to version 9.x --------- Co-authored-by: Mirko Bez <[email protected]> Co-authored-by: Mirko Bez <[email protected]> Co-authored-by: Visha Angelova <[email protected]>
1 parent cd4049e commit 567e4d5

File tree

2 files changed

+51
-220
lines changed

2 files changed

+51
-220
lines changed

docs/reference/metricbeat/metricbeat-metricset-windows-wmi.md

Lines changed: 0 additions & 210 deletions
This file was deleted.

metricbeat/module/windows/wmi/_meta/docs.asciidoc

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
The `wmi` metricset of the Windows module collects metrics via link:https://learn.microsoft.com/en-us/windows/win32/wmisdk/about-wmi[Windows Management Instrumentation (WMI)], a core management technology in the Windows Operating system.
1+
The `wmi` metricset of the Windows module collects metrics via link:https://learn.microsoft.com/en-us/windows/win32/wmisdk/about-wmi[Windows Management Instrumentation] (WMI), a core management technology in the Windows Operating system.
22

33
By leveraging WMI Query Language (WQL), this metricset allows you to extract detailed
44
system information and metrics to monitor the health and performance of Windows
55
Systems.
66

77
This metricset leverages the link:https://github.com/microsoft/wmi[Microsoft WMI] library, a
8-
convenient wrapper around the link:https://github.com/go-ole[Go-OLE] library. This allows invoking the
8+
convenient wrapper around the link:https://github.com/go-ole[Go-OLE] library, which allows to invoke the
99
link:https://learn.microsoft.com/en-us/windows/win32/wmisdk/scripting-api-for-wmi[Scripting API for WMI].
1010

1111
[float]
@@ -15,7 +15,7 @@ This metricset supports the execution of link:https://learn.microsoft.com/en-us/
1515

1616
Currently, the metricset supports queries with `SELECT`, `FROM` and `WHERE` clauses.
1717

18-
NOTE: When working with WMI queries, it is the user's responsibility to ensure that queries are safe, efficient, and do not cause unintended side effects. A notorious example of a problematic WMI class is Win32_Product. Read more in link:https://support.microsoft.com/kb/974524[Windows Documentation].
18+
NOTE: When working with WMI queries, it is the user's responsibility to ensure that queries are safe, efficient, and do not cause unintended side effects. A notorious example of a problematic WMI class is Win32_Product. Read more in link:https://learn.microsoft.com/en-us/troubleshoot/windows-server/admin-development/windows-installer-reconfigured-all-applications#more-information[Windows Documentation].
1919

2020
[float]
2121
[[wmi-arbitrator-and-query-execution]]
@@ -31,6 +31,32 @@ There is no way to directly stop a query once it has started. To prevent Metricb
3131

3232
NOTE: While Metricbeat stops waiting for the result, the underlying WMI query may continue running until the WMI Arbitrator decides to stop execution.
3333

34+
[float]
35+
[[wmi-type-support]]
36+
==== WMI type support
37+
38+
The `microsoft/wmi` library internally uses the WMI Scripting API. This API, as per the
39+
link:https://learn.microsoft.com/en-us/windows/win32/wmisdk/querying-wmi[official WMI Documentation],
40+
does not provide direct type conversion for `uint64`, `sint64`, and `datetime`
41+
link:https://learn.microsoft.com/en-us/windows/win32/wmisdk/common-information-model[Common Information Model] (CIM) types;
42+
instead, these values are returned as strings.
43+
44+
To ensure the correct data type is reported, Metricbeat dynamically fetches the
45+
CIM type definitions for the properties of the WMI instance classes returned by the query,
46+
and then performs the necessary data type conversions.
47+
48+
To optimize performance and avoid repeatedly fetching these schema definitions
49+
for every row and every request, an LRU cache is utilized. This cache stores
50+
the schema definition for each WMI class-property pair encountered. For queries involving
51+
superclasses, such as `CIM_LogicalDevice`, the cache will populate with individual entries
52+
for each specific derived class (leaf of the class hierarchy) whose instances are returned by the query (for example, `Win32_DiskDrive` or `Win32_NetworkAdapter`).
53+
54+
NOTE: The properties of type `CIM_Object` (embedded objects) are not yet supported and are ignored.
55+
56+
57+
NOTE: Properties of type `CIM_Reference` (references), which are used in link:https://learn.microsoft.com/en-us/windows/win32/wmisdk/declaring-an-association-class[WMI Association Classes], are currently returned as string values exactly as reported by the
58+
link:https://github.com/microsoft/wmi[Microsoft WMI] library.
59+
3460

3561
[float]
3662
=== Configuration
@@ -79,6 +105,14 @@ properties that have a `null` value in the output document. The default value is
79105
*`wmi.include_empty_string_properties`*:: A boolean option that causes the metricset to include
80106
the properties that are empty string. The default value is `false`.
81107

108+
*`wmi.max_rows_per_query`*:: Limits the number of rows returned by a single WMI query.
109+
The default value is `0`, which is a special value indicating that all fetched
110+
results should be returned without a row limit.
111+
112+
*`wmi.schema_cache_size`*:: The maximum number of WMI class-property pairs that can be cached per single query. Every query keeps its own separate cache.
113+
This cache helps improve performance when dealing with queries that involve inheritance hierarchies. Read more in <<wmi-type-support, WMI Type Support>>. For example, if a superclass is queried, the cache stores entries for each WMI concrete instance class (the leaves of the class hierarchy) and their associated properties. Therefore, querying a superclass that returns a result set containing instances of `10` different classes, each with `50` properties, will result in a cache size of `500` entries (`10×50`).
114+
The default value is `1000`.
115+
82116
*`wmi.queries`*:: The list of queries to execute. The list cannot be empty. See <<query-configuration, Query Configuration>> for the format of the queries.
83117

84118
[float]
@@ -123,23 +157,30 @@ Equivalent YAML Configuration:
123157
[float]
124158
=== Best Practices
125159

126-
- Test your queries in isolation using the `Get-CimInstance` PowerShell cmdlet or the WMI Explorer.
160+
- Test your queries in isolation using the link:https://learn.microsoft.com/en-us/powershell/module/cimcmdlets/get-ciminstance[`Get-CimInstance`] PowerShell cmdlet or link:https://github.com/vinaypamnani/wmie2[the WMI Explorer tool].
161+
162+
- Ensure that `wmi.warning_threshold` is less than or equal to the module's `period`.
163+
This configuration prevents Metricbeat from starting multiple concurrent executions of the same query.
127164

128-
- Ensure that `wmi.warning_threshold` is **less than or equal to** the module's `period`.
129-
This prevents starting intentionally multiple executions of the same query.
165+
- When possible, try querying concrete (leaf) classes or classes closer to the leaves of the WMI inheritance hierarchy. Querying abstract superclasses may require fetching and caching the schema definitions for numerous derived classes, which can lead to increased memory usage and potential performance penalties due to cache misses.
130166

131-
- Set up alerts in Metricbeat logs for timeouts and empty query results. If a query frequently times out or returns no data, investigate the cause to prevent missing critical information.
167+
- Set up Kibana Alerts for documents generated by this metricset with the `error.message` field.
132168

133-
- [Advanced] Collect WMI-Activity Operational Logs to correlate with Metricbeat WMI warnings.
169+
- Configure collection of WMI-Activity Operational Logs (found in Event Viewer under `Applications and Services Logs/Microsoft/Windows/WMI-Activity/Operational`). These logs can be invaluable for correlating issues with Metricbeat WMI warnings or documents containing `error.message`.
134170

135171

136172
[float]
137173
=== Compatibility
138174

139175
This module has been tested on the following platform:
140176

141-
- Operating System: Microsoft Windows Server 2019 Datacenter
142-
- Architecture: x64
177+
[options="header"]
178+
|===
179+
| Operating System | Architecture
180+
181+
| Microsoft Windows Server 2019 Datacenter | x64
182+
| Microsoft Windows 11 Pro | x64
183+
|===
143184

144185
Other Windows versions and architectures may also work but have not been explicitly tested.
145186

0 commit comments

Comments
 (0)