Skip to content

port: fix(monitoring): dedupe container metrics by task suffix, not name prefix (upstream #4843) - #162

Merged
AminDhouib merged 1 commit into
canaryfrom
port/upr-4843
Jul 18, 2026
Merged

port: fix(monitoring): dedupe container metrics by task suffix, not name prefix (upstream #4843)#162
AminDhouib merged 1 commit into
canaryfrom
port/upr-4843

Conversation

@AminDhouib

Copy link
Copy Markdown
Member

Ports upstream Dokploy/dokploy#4843 by @sensorialsn 1:1 into the fork.

Problem

GetServiceName (apps/monitoring/containers/config.go) deduplicated docker stats output by stripping the last --separated segment of the container name. That conflated distinct compose services sharing a dash prefix — app-x-mysql and app-x-redis both mapped to app-x — so only the first sibling in each docker stats tick was stored, even though metrics are stored and queried by full container_name.

Fix

Dedupe on the swarm task suffix (myapp.1.abc → myapp) via strings.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.go was byte-identical to the upstream base at GetServiceName, so the patch applied cleanly. Adds a standalone config_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).

…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.
@AminDhouib
AminDhouib merged commit 622a747 into canary Jul 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants