-
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 a ring-buffer reporter to libbeat #28750
Add a ring-buffer reporter to libbeat #28750
Conversation
This pull request does not have a backport label. Could you fix it @michel-laterman? 🙏
NOTE: |
This pull request is now in conflicts. Could you fix it? 🙏
|
Add a ring buffer reporter that when enabled will store configured namespaces in a buffer to allow operators to view recent metrics history. Defaults are to gather the stats namespace every 10s for 10m. Must be explicitly enabled, along with monitoring, and the HTTP endpoint. The buffer endpoint is intended to be used for diagnostics reporting.
47c2b95
to
2a7f38e
Compare
Hi! We're labeling this issue as |
Hi! We're labeling this issue as |
This is interesting @michel-laterman let me know if it's ready to look at it. |
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 this looks really good.
It has great test coverage and it's easy to understand. I feel like I should have found something to comment on, but its really good, nothing I see!
Going to restart the tests, it been a few months the PR was created. /test |
/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.
Look good to me, adding only a small nit comment.
|
||
// ringBuffer is a buffer with a fixed number of items that can be tracked. | ||
// | ||
// we assume that the size of the buffer is greater than one. |
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.
// we assume that the size of the buffer is greater than one. | |
// We assume that the size of the buffer is greater than one. | |
`` |
func (r *reporter) Stop() { | ||
close(r.done) | ||
r.wg.Wait() | ||
// Clear entries? |
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.
Remove comment so there is no confusion on the godoc of the function, no need to clear the ring buffer there.
libbeat/api/server.go
Outdated
switch r.(type) { | ||
case error: | ||
err = r.(error) | ||
case string: | ||
err = fmt.Errorf(r.(string)) | ||
default: | ||
err = fmt.Errorf("handle attempted to panic with %v", r) | ||
} |
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.
switch r.(type) { | |
case error: | |
err = r.(error) | |
case string: | |
err = fmt.Errorf(r.(string)) | |
default: | |
err = fmt.Errorf("handle attempted to panic with %v", r) | |
} | |
switch r := r.(type) { | |
case error: | |
err = r | |
case string: | |
err = errors.New(r) | |
default: | |
err = fmt.Errorf("handle attempted to panic with %v", r) | |
} |
Needs "errors" added to imports.
libbeat/api/server_test.go
Outdated
require.NoError(t, err) | ||
defer r.Body.Close() | ||
|
||
body, err := ioutil.ReadAll(r.Body) |
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.
s/ioutil/io/
entries []interface{} | ||
i int | ||
full bool | ||
mu sync.Mutex |
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.
Conventionally mutexes are placed above the field they protect.
/test |
1 similar comment
/test |
…into feature/use-with-kind-k8s-env * 'feature/use-with-kind-k8s-env' of github.com:v1v/beats: (52 commits) ci: home is declared within withBeatsEnv ci: use withKindEnv step ci: use getBranchesFromAliases and support next-patch-8 (elastic#30400) Update fields.yml (elastic#29609) Heartbeat: fix browser metrics and trace mappings (elastic#30258) Apply light edits to 8.0 changelog (elastic#30351) packetbeat/beater: make sure Npcap installation runs before interfaces are needed (elastic#30396) Add a ring-buffer reporter to libbeat (elastic#28750) Osquerybeat: Add install verification for osquerybeat (elastic#30388) update windows matrix support (elastic#30373) Refactor of metricbeat process-gathering metrics and system/process (elastic#30076) adjust next changelog wording (elastic#30371) [Metricbeat] azure: move event report into loop validDim loop (elastic#29945) fix: report GitHub Check before the cache (elastic#30372) Add support for non-unique keys in Kafka output headers (elastic#30369) ci: 6 major branch reached EOL (elastic#30357) reduce Elastic Agent shut down time by stopping processes concurrently (elastic#29650) [Filebeat] Add message to register encode/decode debug logs (elastic#30271) [libbeat] kafka message header support (elastic#29940) Heartbeat: set duration to zero for syntax errors (elastic#30227) ...
What does this PR do?
Add a ring buffer reporter that when enabled will store configured
namespaces in a buffer to allow operators to view recent metrics
history. Defaults are to gather the stats namespace every 10s for 10m.
Must be explicitly enabled along with the HTTP endpoints.
The buffer endpoint is intended to be used for diagnostics reporting.
Why is it important?
We wish to gather recent metrics data with the
elastic-agent diagnostics
command.The buffer endpoint can be used to collect such data.
Also once this is implemented we may more easily disable the log metrics reporting functionality.
Checklist
I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
compile a beat, and run with the following options enabled in the config:
Related issues
Note that this functionality will not be backported, the number of cases metrics could help debug are minimal.