[8.19](backport #44452) Provide a consistent non-global metrics API to beats and beat receivers
A refactor to allow beats and beat receivers to use consistent metrics registries without relying on the process-global default defined in elastic-agent-libs. When initialized under Beats, the locally passed registries reference the existing global ones, for compatibility while the remaining global references are removed. When initialized in a Beats receiver, new non-global registries are created, and the receiver will report only fields that have been migrated away from the global references.
This PR should cause no user-visible changes outside the beats receivers. Within the beats receivers, it migrates most Filebeat/Metricbeat metrics variables so they can be used within the receivers.
Checklist
- [x] My code follows the style guidelines of this project
- [x] 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~~
- [x] I have added tests that prove my fix is effective or that my feature works
- [ ] ~~I have added an entry in
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.~~
This is an automatic backport of pull request #44452 done by [Mergify](https://mergify.com).
Cherry-pick of 1b1a4c6f8879e8926d1590085364a9997b599a4c has failed:
On branch mergify/bp/8.19/pr-44452
Your branch is up to date with 'origin/8.19'.
You are currently cherry-picking commit 1b1a4c6f8.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --skip" to skip this patch)
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
Changes to be committed:
modified: filebeat/beater/filebeat.go
modified: filebeat/input/filestream/internal/input-logfile/metrics.go
modified: filebeat/input/filestream/metrics_integration_test.go
modified: filebeat/input/journald/environment_test.go
modified: filebeat/input/v2/compat/compat.go
modified: filebeat/input/v2/input-cursor/input.go
modified: filebeat/input/v2/input-cursor/manager_test.go
modified: heartbeat/monitors/mocks.go
modified: libbeat/api/routes.go
modified: libbeat/beat/beat.go
modified: libbeat/beat/info.go
new file: libbeat/beat/monitoring.go
modified: libbeat/cmd/instance/beat.go
modified: libbeat/monitoring/inputmon/httphandler.go
modified: libbeat/monitoring/inputmon/input.go
modified: libbeat/monitoring/inputmon/input_test.go
modified: libbeat/monitoring/report/elasticsearch/elasticsearch.go
modified: libbeat/monitoring/report/elasticsearch/elasticsearch_test.go
modified: libbeat/monitoring/report/report.go
modified: libbeat/outputs/elasticsearch/client_integration_test.go
modified: metricbeat/beater/metricbeat.go
modified: metricbeat/mb/module/configuration.go
modified: metricbeat/mb/module/example_test.go
modified: metricbeat/mb/module/factory.go
modified: metricbeat/mb/module/runner_test.go
modified: metricbeat/mb/module/wrapper.go
modified: metricbeat/mb/module/wrapper_internal_test.go
modified: metricbeat/mb/module/wrapper_test.go
modified: packetbeat/beater/packetbeat.go
modified: winlogbeat/beater/winlogbeat.go
modified: x-pack/filebeat/input/benchmark/input.go
modified: x-pack/heartbeat/scenarios/framework/framework.go
modified: x-pack/libbeat/cmd/instance/beat.go
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: filebeat/input/filestream/environment_test.go
both modified: filebeat/input/v2/compat/compat_test.go
both modified: x-pack/libbeat/cmd/instance/receiver.go
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally
Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform)
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)