-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
Bug Description
Container monitoring metrics return null even though data is being collected and stored correctly in the database. The issue is in the GetLastNContainerMetrics function in apps/monitoring/database/containers.go.
Root Cause
The function truncates the container name by removing the last segment after splitting by -:
parts := strings.Split(name, "-")
if len(parts) > 1 {
containerName = strings.Join(parts[:len(parts)-1], "-")
}However, the SaveContainerMetric function saves data with the full container name (e.g., automations-stack-xxqyba-n8n-1).
When querying, the function transforms:
- Input:
automations-stack-xxqyba-n8n-1 - Query searches for:
automations-stack-xxqyba-n8n
This results in no records being found because the data is stored with the full name.
Evidence
Direct database queries on the monitoring.db:
SELECT COUNT(*) FROM container_metrics WHERE container_name = 'automations-stack-xxqyba-n8n';→ 0 recordsSELECT COUNT(*) FROM container_metrics WHERE container_name = 'automations-stack-xxqyba-n8n-1';→ 3,524 records
Expected Behavior
The query function should search using the same name format that the save function uses, or both should use consistent name processing.
Suggested Fix
Either:
- Remove the name truncation logic from
GetLastNContainerMetricsandGetAllMetricsContainer - Or apply the same truncation logic in
SaveContainerMetricbefore saving
Environment
- Dokploy Cloud with remote node
- dokploy/monitoring:latest image
- Ubuntu 24.04.3 LTS
Metadata
Metadata
Assignees
Labels
No labels