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

let the system/process metricset monitor a single PID #39620

Merged
merged 14 commits into from
May 23, 2024

Conversation

fearful-symmetry
Copy link
Contributor

Proposed commit message

required for elastic/elastic-agent#4083

This adds a process.pid config flag to system/process to let the metricset monitor a single PID.

This is needed for elastic/elastic-agent#4083, as we need to let metricbeat report metrics on a single process, which this metricset currently can't do.

Right now this has no documentation, as I'm not sure if we want to make this a public feature? It's a bit odd outside of our use case.

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.

@fearful-symmetry fearful-symmetry added the Team:Elastic-Agent Label for the Agent team label May 17, 2024
@fearful-symmetry fearful-symmetry self-assigned this May 17, 2024
@fearful-symmetry fearful-symmetry requested review from a team as code owners May 17, 2024 17:12
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels May 17, 2024
Copy link
Contributor

mergify bot commented May 17, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @fearful-symmetry? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@fearful-symmetry
Copy link
Contributor Author

Sigh, looks like I introduced a bug in elastic/elastic-agent-system-metrics#150, lemme deal with that...

Copy link
Contributor

mergify bot commented May 17, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b system-process-pid upstream/system-process-pid
git merge upstream/main
git push upstream system-process-pid

fearful-symmetry added a commit to elastic/elastic-agent-system-metrics that referenced this pull request May 17, 2024
## What does this PR do?

This fixes a small bug introduced in #150, where we weren't setting the
`ProcState` object while creating the root event.

This is needed for elastic/beats#39620

## Why is it important?

The previous PR adds fields that weren't in events before, this fixes
that.

## Checklist

- [x] My code follows the style guidelines of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added an entry in `CHANGELOG.md`
@ycombinator ycombinator added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label May 17, 2024
@elasticmachine
Copy link
Collaborator

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

@pierrehilbert pierrehilbert requested review from faec and removed request for AndersonQ May 21, 2024 07:50
Copy link
Contributor

@faec faec 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, one naming nit

@@ -32,6 +32,8 @@ type Config struct {
IncludeCPUTicks bool `config:"process.include_cpu_ticks"`
IncludePerCPU bool `config:"process.include_per_cpu"`
CPUTicks *bool `config:"cpu_ticks"` // Deprecated
// Pid, if set, will override the `processes` config, and only monitor a single process.
Pid int `config:"process.pid"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker, but what if the config field was just pid instead of process.pid? It seems a little confusing having two mutually exclusive top-level fields to specify the target, but one of them lives in a subobject for other behavior settings.

metricbeat/module/system/process/process.go Outdated Show resolved Hide resolved
@cmacknz
Copy link
Member

cmacknz commented May 21, 2024

Right now this has no documentation, as I'm not sure if we want to make this a public feature? It's a bit odd outside of our use case.

Leave it this way for now, if someone asks us specifically for this we can re-evaluate. We do not want to be limited in our ability to change or remove this in the future unnecessarily.

Copy link
Contributor

mergify bot commented May 21, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b system-process-pid upstream/system-process-pid
git merge upstream/main
git push upstream system-process-pid

@fearful-symmetry fearful-symmetry merged commit 43d5dd4 into elastic:main May 23, 2024
105 checks passed
pchila added a commit to pchila/beats that referenced this pull request May 24, 2024
pchila added a commit that referenced this pull request May 24, 2024
@pchila
Copy link
Member

pchila commented May 24, 2024

@fearful-symmetry I reverted this PR merge on main due to a linking problem, could you please have a look and check it again?

@ycombinator
Copy link
Contributor

@fearful-symmetry I reverted this PR merge on main due to a linking problem, could you please have a look and check it again?

@fearful-symmetry this might be helpful: #39714 (comment)

@fearful-symmetry
Copy link
Contributor Author

@ycombinator yup, looking at things now

@fearful-symmetry
Copy link
Contributor Author

a thought for later: why wasn't this caught in PR? Do we not have any tests that are building agentbeat?

fearful-symmetry added a commit to fearful-symmetry/beats that referenced this pull request May 24, 2024
fearful-symmetry added a commit that referenced this pull request May 31, 2024
…update to `go-systemd` (#39730)

* Reapply "let the system/process metricset monitor a single PID (#39620)" (#39714)

This reverts commit 05c5957.

* reapply single-pid changes, tinker with go-systemd dep

* fix deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants