-
Notifications
You must be signed in to change notification settings - Fork 155
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
Add CPU profile collection to diagnostics handler #4394
Add CPU profile collection to diagnostics handler #4394
Conversation
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
This pull request does not have a backport label. Could you fix it @michel-laterman? 🙏
NOTE: |
7c232ad
to
f251b0d
Compare
fleet-server changes are here: elastic/fleet-server#3333 in the future we can also specify a duration parameter as part of the action, but that will need support from the elastic-agent-client-libs repo in order for us to actually pass it (especially to |
} | ||
diags = append(diags, client.DiagnosticFileResult{ | ||
Name: "cpuprofile", | ||
Filename: "cpu.pprof", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied metadata from the control server: https://github.com/elastic/elastic-agent/blob/main/pkg/control/v2/server/server.go#L214-L221
We use cpu.pprof
, but all other traces use *.pprof.gz
.
Should we alter diagnostics.CreateCPUProfile
in order to compress the resulting trace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably correct to change the name to whatever comes back from a GET to http://localhost:6060/debug/pprof/profile?seconds=30
The parameters here could also be pulled out into a shared set of constants much like the profile duration.
changelog/fragments/1710153529-Add-CPU-profile-collection-to-diagnostics-action-handler.yaml
Outdated
Show resolved
Hide resolved
internal/pkg/agent/application/actions/handlers/handler_action_diagnostics.go
Show resolved
Hide resolved
internal/pkg/agent/application/actions/handlers/handler_action_diagnostics.go
Outdated
Show resolved
Hide resolved
} | ||
diags = append(diags, client.DiagnosticFileResult{ | ||
Name: "cpuprofile", | ||
Filename: "cpu.pprof", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably correct to change the name to whatever comes back from a GET to http://localhost:6060/debug/pprof/profile?seconds=30
The parameters here could also be pulled out into a shared set of constants much like the profile duration.
internal/pkg/agent/application/actions/handlers/handler_action_diagnostics.go
Show resolved
Hide resolved
|
If there is a Fleet API to let us request this we could write an E2E test for diagnostics requests in this repository. @michel-laterman is there an API for this? Is there a change on the Kibana side to follow? |
What does this PR do?
Add the optional CPU profile collection to the diagnostic action handler.
CPU profiles will be collected if the REQUEST_DIAGNOSTICS action has the
optional additional_metrics parameter list contains "CPU".
Why is it important?
Will make diagnostics requested through fleet feature-complete (compared to cli options)
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration files./changelog/fragments
using the changelog toolI have added an integration test or an E2E testTesting
Changes have been tested with an e2e workflow, see elastic/fleet-server#3333 (comment)
Related issues