fix(monitoring): dedupe container metrics by task suffix, not name prefix#4843
Open
sensorialsn wants to merge 1 commit into
Open
fix(monitoring): dedupe container metrics by task suffix, not name prefix#4843sensorialsn wants to merge 1 commit into
sensorialsn wants to merge 1 commit into
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. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AminDhouib
added a commit
to DevinoSolutions/dokploy-community
that referenced
this pull request
Jul 18, 2026
port: fix(monitoring): dedupe container metrics by task suffix, not name prefix (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.
Problem
In the monitoring service,
collectMetricsdeduplicates thedocker statsoutput byGetServiceName, which strips the last--separated segment of the container name:Any set of containers sharing a dash prefix therefore collapses to a single deduplication key. With explicit compose
container_names such as:all four map to the key
app-1425, so only the first container returned bydocker statsis stored on each tick — the metrics of every sibling container are silently dropped, and which container "wins" depends ondocker statsoutput order.This is inconsistent with the storage and query layers, which are already keyed by the full container name:
SaveContainerMetricstoresmetric.Name(full name) incontainer_metrics.container_name;GetLastNContainerMetricsfilters withWHERE container_name = ? OR container_name LIKE ?||'.%'.So the write-side dedup is the only place losing data.
Fix
Deduplicate by the swarm task prefix (the name up to the first
.) instead of the last dash segment:myapp.1.taskid/myapp.2.taskidstill collapse tomyapp— the original intent (one stored series per service and tick) is preserved, and reads keep matching through the existingLIKE name||'.%'clause;app-1425-mysql,project-web-1), which have no task suffix and are unique per container, keep distinct keys and are all stored.Added a table-driven unit test for
GetServiceNamecovering swarm replicas, explicit compose names, compose default naming, and the leading-slash case.How to reproduce
container_name: mystack-app,mystack-mysql,mystack-redis).GET /metrics/containers?appName=mystack-mysql&limit=50— empty (or nearly empty) results, whilemystack-app(or whichever containerdocker statslists first) has all the points.🤖 Generated with Claude Code