monitoring: update apm-server metrics collection to avoid conflicts#17512
Merged
isaacaflores2 merged 5 commits intoelastic:mainfrom Jul 8, 2025
Merged
Conversation
Contributor
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
Contributor
|
This pull request is now in conflicts. Could you fix it @isaacaflores2? 🙏 |
Contributor
|
Quickly tested this manually.
"sampling": {
"tail": {
"dynamic_service_groups": 1,
"events": {
"processed": 3,
"stored": 3
}
}
}
"sampling": {
"tail": {
"dynamic_service_groups": 1,
"events": {
"processed": 3,
"sampled": 3,
"stored": 3
},
"storage": {
"lsm_size": 5407,
"value_log_size": 0
}
}
}
apm-server:
host: "127.0.0.1:8200"
sampling.tail:
enabled: true
policies:
- sample_rate: 1.0
output.elasticsearch:
hosts: ["https://216c4d53f99e4e48a556e4cfe72cb680.us-central1.gcp.qa.cld.elstc.co:443"]
username: "elastic"
password: "<REDACTED>"
http:
enabled: true
host: localhost
port: 5066 |
rubvs
previously approved these changes
Jul 8, 2025
kruskall
reviewed
Jul 8, 2025
carsonip
previously approved these changes
Jul 8, 2025
Member
carsonip
left a comment
There was a problem hiding this comment.
lgtm, thanks for adding the test
carsonip
approved these changes
Jul 8, 2025
kruskall
approved these changes
Jul 8, 2025
Merged
1 task
Merged
1 task
Merged
1 task
isaacaflores2
added a commit
that referenced
this pull request
Jul 8, 2025
…17512) (#17527) * monitoring: update apm-server metrics collection to avoid conflicts * refactor beats monitoring since there are no more global registries * removed redundant temp slice from apm-server monitoring func (cherry picked from commit f1c279b) Co-authored-by: Isaac Flores <34590010+isaacaflores2@users.noreply.github.com>
isaacaflores2
added a commit
that referenced
this pull request
Jul 9, 2025
…ion to avoid conflicts (#17526) * monitoring: update apm-server metrics collection to avoid conflicts (#17512) * monitoring: update apm-server metrics collection to avoid conflicts * refactor beats monitoring since there are no more global registries * removed redundant temp slice from apm-server monitoring func (cherry picked from commit f1c279b) * fix merge conflict issues caused by global registries --------- Co-authored-by: Isaac Flores <34590010+isaacaflores2@users.noreply.github.com> Co-authored-by: Isaac Flores <isaac.flores@elastic.co>
simitt
reviewed
Jul 9, 2025
| // register all metrics once | ||
| // this prevents metrics with the same prefix in the name | ||
| // from different scoped meters from overwriting each other | ||
| reportOnKey(v, beatsMetrics) |
Member
mergify bot
added a commit
that referenced
this pull request
Jul 14, 2025
…tion to avoid conflicts (#17525) * monitoring: update apm-server metrics collection to avoid conflicts (#17512) * monitoring: update apm-server metrics collection to avoid conflicts * refactor beats monitoring since there are no more global registries * removed redundant temp slice from apm-server monitoring func (cherry picked from commit f1c279b) # Conflicts: # internal/beatcmd/beat_test.go * fix merge conflict in beat_test.go --------- Co-authored-by: Isaac Flores <34590010+isaacaflores2@users.noreply.github.com> Co-authored-by: Isaac Flores <isaac.flores@elastic.co> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation/summary
Currently
apm-server.sampling.tail.storage.lsm_sizeandapm-server.sampling.tail.dynamic_service_groupsare never reported together.Testing locally this is caused because both sets of metrics use the same namespace (metric name prefix)
apm-server.samplingbut they are created using different instances of a Meter.The related monitoring func calls
addAPMServerMetricsmultiple times for each scoped metric. Metric names with the same prefix in different scopes are somehow overwriting each other. This approach opts to collect all "apm-server" metrics and add them to the snapshot once. Another approach would be to update theelastic-agent-libto prevent metrics from overwriting each other.Checklist
For functional changes, consider:
How to test these changes
manual test
./sendotlp -insecure -endpoint=http://localhost:8200 -secret-token=<token>storageshould be visible along with other metrics underapm-server.sampling.tailRelated issues
Closes #17342
Alternate approach to #17427