port: fix(monitoring): dedupe container metrics by task suffix, not name prefix (upstream #4843) - #162
Merged
Merged
Conversation
…efix collectMetrics dropped every sibling of the first container sharing a dash prefix (app-x-mysql, app-x-redis... all mapped to "app-x"), while storage and queries are keyed by full container_name. Dedupe on the swarm task suffix instead: replicas of a service still collapse to one stored series per tick, distinct compose containers all get stored. Ported from upstream Dokploy#4843.
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.
Ports upstream Dokploy/dokploy#4843 by @sensorialsn 1:1 into the fork.
Problem
GetServiceName(apps/monitoring/containers/config.go) deduplicateddocker statsoutput by stripping the last--separated segment of the container name. That conflated distinct compose services sharing a dash prefix —app-x-mysqlandapp-x-redisboth mapped toapp-x— so only the first sibling in eachdocker statstick was stored, even though metrics are stored and queried by fullcontainer_name.Fix
Dedupe on the swarm task suffix (
myapp.1.abc → myapp) viastrings.Index(name, ".")instead. Swarm replicas of one service still collapse to a single stored series per tick, while distinct compose containers (which have no.-task suffix) each keep their full name and get stored.Adaptations
None — the fork's
config.gowas byte-identical to the upstream base atGetServiceName, so the patch applied cleanly. Adds a standaloneconfig_test.go(TestGetServiceName, 7 cases).Verification
Go is not installed in the porting environment, so the test was not executed locally; the change is a self-contained logic swap plus a table-driven unit test. CI (Go build/test) is the ground truth.
Credit: @sensorialsn (upstream Dokploy#4843).