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

feat: add win_wmi input plugin #11250

Merged
merged 52 commits into from
Feb 22, 2023
Merged

feat: add win_wmi input plugin #11250

merged 52 commits into from
Feb 22, 2023

Conversation

julesroussel3
Copy link
Contributor

Required for all PRs:

resolves #1857

This PR creates a plugin to obtain metrics from Windows Management Instrumentation (WMI).

This plugin queries Windows Management Instrumentation (WMI) classes on Windows
operating systems. An administrator can query and filter for specific
properties in any WMI namespace and class. While some system information is
already exposed through regular plugins like [[inputs.cpu]] and [[inputs.mem]],
this plugin provides ultimate control and flexibility, allowing an
administrator to query classes not exposed through other plugins.

Full details of the plugin are available in the README.

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jun 2, 2022
@julesroussel3
Copy link
Contributor Author

Why do the linux-based tests complain with build constraints exclude all Go files in...? Is there a directive missing in some configuration file? (This plugin is Windows-only.)

@powersj
Copy link
Contributor

powersj commented Jun 3, 2022

Hi! Thanks for this PR!

Why do the linux-based tests complain with build constraints exclude all Go files in...? Is there a directive missing in some configuration file? (This plugin is Windows-only.)

The build constraint as-is will only build for Windows, yet the module is always imported with all.go.

To get around this we typically create a win_wmi_notwindows.go file that should look like this. This creates a no-op for the non-windows OSes. I believe adding that should get you going.

@julesroussel3
Copy link
Contributor Author

That worked! Thank you. All tests are passing now.

@reimda
Copy link
Contributor

reimda commented Jun 6, 2022

Hi @julesroussel3, thanks for looking into this.

Does your new plugin gather different data than telegraf's existing inputs/win_perf_counters? That plugin uses Windows's PDH API which seems to grab the same counters as WMI.

I ran into a few mentions that say PDH is a lower level API so it performs better than WMI:

@julesroussel3
Copy link
Contributor Author

Hi @reimda ! Thank you for the question. I’m happy to clarify.

Does your new plugin gather different data than telegraf's existing inputs/win_perf_counters?

It is true that some performance counters are exposed through WMI, and it is true that accessing performance counters directly with the win_perf_counters plugin is optimal. However, WMI provides access to lots of other information which is not available through performance counters.

Configuration and other metadata can be gathered using WMI. For example:

  • Using the Win32_ComputerSystem class, the TotalPhysicalMemory, NumberOfProcessors, and NumberOfLogicalProcessors properties can be gathered as metrics, and metadata such as Domain, Manufacturer, and Model can be included as tags. This provides the ability to create rich dashboards which provide administrators a single-pane-of-glass, showing not only resource utilization, but a complete hardware topology.
  • Similarly, Win32_PhysicalMemory can be used to inventory the physical memory devices in a computer and their respective sizes.
  • Similar to the previous example, properties from the Win32_OperatingSystem class can be used to tag metrics with the version and edition of Windows, allowing the creation of a dashboard which shows how many computers in the environment are running Windows 10 Enterprise versus Professional, Server Standard versus Server DataCenter edition, Server Core versus Server GUI, etc.
  • Using classes in the root\mscluster namespace, the name of the cluster to which a node is joined can be gathered, which allows a dashboard to summarize memory and CPU across multiple nodes in a cluster.
  • The MBAM_Volume class can be used to summarize the state of disk encryption in a Windows environment.
  • The Root\microsoft\sqlserver\ComputerManagement1* namespaces are useful for inventorying the editions and versions of SQL Server installed in a Windows environment.
  • The Speed property of MSFT_NetAdapter can be used to determine the negotiated speed and MTU of a network interface.

Furthermore, WMI provides ultimate control. Some of the basic input plug-ins (e.g. cpu, mem) provide abstraction layers to WMI-based data, but do not provide the ultimate flexibility and control that some administrators desire. This plug-in enables an administrator to granularly select each property of a class which they desire to include in their metrics. It's possible that most administrators will choose to use the stock plugins and win_perf_counters, but the lack of a flexible WMI plug-in was a major roadblock in the enterprise environment I support, which is how this plug-in came to be.

@cemremengu
Copy link
Contributor

@julesroussel3 AFAIK (but not sure) you can gather data remotely with WMI so if this plugin also provides that functionality, it will definitely have an edge over existing plugins.

@julesroussel3
Copy link
Contributor Author

@julesroussel3 AFAIK (but not sure) you can gather data remotely with WMI so if this plugin also provides that functionality, it will definitely have an edge over existing plugins.

@cemremengu That is a good idea for a feature enhancement and is certainly possible. Similar to #11090, for that to work, either the computer object or service account running telegraf would need to have administrative permissions on the remote machine. Unfortunately, when this plug-in was created, remote support wasn't in scope for my requirements.

Copy link
Contributor

@reimda reimda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick look at the code and had some thoughts/questions before getting into a close review.

plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/README.md Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/README.md Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/README.md Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/README.md Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/README.md Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
@sspaink sspaink added the waiting for response waiting for response from contributor label Sep 21, 2022
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Oct 5, 2022

Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Page. Thank you!

@telegraf-tiger telegraf-tiger bot closed this Oct 5, 2022
@rismoney
Copy link

any way to re-open and get this capability merged?

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Oct 15, 2022
@Hipska
Copy link
Contributor

Hipska commented Oct 16, 2022

@julesroussel3 feel free to implement the requested changes and reply to the questions, we will then reopen and review.

@Hipska Hipska reopened this Oct 16, 2022
@Hipska Hipska added area/windows Related to windows plugins (win_eventlog, win_perf_counters, win_services) plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins waiting for response waiting for response from contributor labels Oct 16, 2022
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
@telegraf-tiger
Copy link
Contributor

Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Page. Thank you!

@telegraf-tiger telegraf-tiger bot closed this Oct 30, 2022
@Hipska Hipska added help wanted Request for community participation, code, contribution and removed waiting for response waiting for response from contributor labels Oct 31, 2022
@rismoney
Copy link

rismoney commented Nov 1, 2022

inactivity? really?

@rismoney
Copy link

Can this get reopened/merged?

@powersj
Copy link
Contributor

powersj commented Dec 15, 2022

If @julesroussel3 has interest in continue working on it sure

@julesroussel3
Copy link
Contributor Author

I am actively working toward addressing review feedback.

@powersj
Copy link
Contributor

powersj commented Feb 6, 2023

I believe all of the recent comments have been addressed.

Thanks I will take a look tomorrow

The readme linter is complaining, but only about plugin READMEs unrelated to the PR. How do I address that?

A rebase on master should have a change that only tests the READMEs that are touched. Otherwise, we can ignore.

@powersj powersj assigned srebhan and unassigned powersj Feb 7, 2023
@powersj
Copy link
Contributor

powersj commented Feb 7, 2023

Thanks for seeing this through. I'll let Sven take one final look at this.

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the nice plugin @julesroussel3! I do have some smaller comments though. Can you please take a look!?

plugins/inputs/win_wmi/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
julesroussel3 and others added 6 commits February 7, 2023 16:16
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
plugins/inputs/win_wmi/win_wmi.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
@srebhan
Copy link
Contributor

srebhan commented Feb 16, 2023

@julesroussel3 any updates here? I really would love to see this PR merged...

@julesroussel3
Copy link
Contributor Author

Hi folks! I made another pass at review comments. Let me know if this is satisfactory for merge.

Copy link
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, just a minor improvement.

plugins/inputs/win_wmi/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julesroussel3 I think we are almost there. I have three minor comments for the test and I agree with @Hipska about the example. Can you please fix those so we get that nice plugin in?

plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
plugins/inputs/win_wmi/win_wmi_test.go Outdated Show resolved Hide resolved
@julesroussel3
Copy link
Contributor Author

I've addressed the latest feedback. Let me know what's next.

@telegraf-tiger
Copy link
Contributor

Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for your great work and for keeping this going @julesroussel3!

@powersj as we have quite some changes, please take another look and merge if you are fine with the changes.

@srebhan srebhan assigned powersj and unassigned srebhan Feb 22, 2023
@powersj powersj merged commit 100a27e into influxdata:master Feb 22, 2023
@srebhan srebhan added this to the v1.26.0 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/windows Related to windows plugins (win_eventlog, win_perf_counters, win_services) feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to query WMI on Windows.
8 participants