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

[META][metricbeat] - Consider using performance counters for windows system metricsets #41904

Open
VihasMakwana opened this issue Dec 5, 2024 · 2 comments
Assignees
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team windows

Comments

@VihasMakwana
Copy link
Contributor

While working on #40926, I observed that we can rely on performance counter for many of our system modules. This is a placeholder issue to identify all such modules that can use performance counters and work on a PoC, if we agree on the use case.

Why we should consider performance counters?

  • For windows, we rely on APIs such as NtQuerySystemInformation and it has a warning:

    NtQuerySystemInformation may be altered or unavailable in future versions of Windows. Applications should use the alternate functions listed in this topic

    • It might be worth it to consider alternatives
  • Currently, for modules such as system.process, there are multiple API calls involved:
    • We first call EnumProcesses to get a list of process ids.
    • Then we loop through all of them call OpenProcess (multiple times per pid).
    • We again have to call NtQuerySystemInformation to get memory/process information.
  • Using performance counter would simplify this by a lot.
  • While working on unprivileged mode for windows, we observed that system.diskio module wasn't working. There is no workaround for this and it is noted as a "limitation".
    • Performance counters can help resolve this issue. I did some quick unit testing and verified it.

cc: @cmacknz @flexitrev @pierrehilbert

@VihasMakwana VihasMakwana changed the title [META] - Consider using performance counters for windows modules [META][metricbeat] - Consider using performance counters for windows system metricsets Dec 5, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 5, 2024
@VihasMakwana VihasMakwana added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Dec 5, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Dec 5, 2024
@cmacknz
Copy link
Member

cmacknz commented Dec 5, 2024

+1 to a PoC. I do not know if there is any historical reason for why did not use performance counters by default. I would guess we ended up here by following the Unix pattern of making syscalls to get things when translating the metricsets to Windows.

@VihasMakwana VihasMakwana self-assigned this Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team windows
Projects
None yet
Development

No branches or pull requests

3 participants