-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 start of elastic-agent diagnostics command #28265
Conversation
Add initial command that will gather meta-data from running beats HTTP endpoints and elastic-agent version information.
This pull request does not have a backport label. Could you fix it @michel-laterman? 🙏
NOTE: |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
could you diff a change in output in desciption? it would make easier for people having strict requirements on format using this endpoint finding out what should be added |
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.
looks good, i havent tested it so far. i will today/tomorrow
@@ -20,6 +21,10 @@ type stater interface { | |||
State() map[string]state.State | |||
} | |||
|
|||
type specer interface { |
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.
probably you meant specser
. i dont know if it is a real world but it sounds funny :-)
no more naming comments from me
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 think specser
is a bit too strange, it does more to hide what the interface is doing than specer
/test |
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.
What is the format of the output? Can we make it human readable or at least add an option for it?
|
||
diag, err := getDiagnostics(innerCtx) | ||
if err == context.DeadlineExceeded { | ||
return errors.New("timed out after 30 seconds trying to connect to Elastic Agent daemon") |
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.
30s sounds like a long time for a timeout for a local diagnostic commands. I would expect the diagnostic command to be pretty quick or is there some "remote" dependency?
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.
copied timeout from the status command
@@ -53,6 +53,25 @@ type ApplicationStatus struct { | |||
Payload map[string]interface{} | |||
} | |||
|
|||
// BeatMeta is the running version and ID inforation for a running beat. | |||
type BeatMeta struct { |
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.
What about endpoint and other processes we run? If possible we should keep the naming not specific to Beats only.
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.
good point, Do we know the kind of meta-data endpoint or another process would return? Or should I change this to just be a generic map[string]interface{}
to capture everything?
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
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.
Overall looks really good. Just got one question.
// DialContext returns a function that can be used to dial a local unix-domain socket. | ||
func DialContext(socket string) func(context.Context, string, string) (net.Conn, error) { | ||
return func(_ context.Context, _, _ string) (net.Conn, error) { | ||
return net.Dial("unix", socket) |
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.
Is it not possible to get net.Dial
to take a context? Is there no net.DialContext
?
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.
good catch
This PR starts the elastic-agent diagnostics command. The beats info ("/") HTTP endpoint has been changed to add more data about the running beat including git commit and ephemeral ID. Currently the diagnostics command will gather beats metadata information from the endpoint and display them along with agent version information. (cherry picked from commit 887e40a)
This PR starts the elastic-agent diagnostics command. The beats info ("/") HTTP endpoint has been changed to add more data about the running beat including git commit and ephemeral ID. Currently the diagnostics command will gather beats metadata information from the endpoint and display them along with agent version information. (cherry picked from commit 887e40a) Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
This PR starts the elastic-agent diagnostics command. The beats info ("/") HTTP endpoint has been changed to add more data about the running beat including git commit and ephemeral ID. Currently the diagnostics command will gather beats metadata information from the endpoint and display them along with agent version information.
This PR starts the elastic-agent diagnostics command. The beats info ("/") HTTP endpoint has been changed to add more data about the running beat including git commit and ephemeral ID. Currently the diagnostics command will gather beats metadata information from the endpoint and display them along with agent version information. (cherry picked from commit 887e40a) # Conflicts: # libbeat/cmd/instance/beat.go # x-pack/elastic-agent/pkg/agent/cmd/diagnostics.go
This PR starts the elastic-agent diagnostics command. The beats info ("/") HTTP endpoint has been changed to add more data about the running beat including git commit and ephemeral ID. Currently the diagnostics command will gather beats metadata information from the endpoint and display them along with agent version information. (cherry picked from commit 887e40a) # Conflicts: # libbeat/cmd/instance/beat.go # x-pack/elastic-agent/pkg/agent/cmd/diagnostics.go
What does this PR do?
This PR starts the elastic-agent diagnostics command.
The beats info ("/") HTTP endpoint has been changed to add more data about the running beat including git commit and ephemeral ID.
Currently the diagnostics command will gather beats metadata information from the endpoint and display them along with agent version information.
Why is it important?
The diagnostics command is meant to be used to gather diagnostics information from a running elastic-agent (and beats) that can be used for debugging.
Checklist
I have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Run the agent normally then use:
elastic-agent diagnostics
Related issues
Logs