Skip to content

Commit 30f061e

Browse files
authored
Merge pull request #3947 from Dokploy/3896-application-monitor-problem
fix: enhance container metrics query to support wildcard matching for…
2 parents 8e9ab98 + c00aa6a commit 30f061e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

apps/monitoring/database/containers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ func (db *DB) GetLastNContainerMetrics(containerName string, limit int) ([]Conta
5454
WITH recent_metrics AS (
5555
SELECT metrics_json
5656
FROM container_metrics
57-
WHERE container_name = ?
57+
WHERE container_name = ? OR container_name LIKE ?
5858
ORDER BY timestamp DESC
5959
LIMIT ?
6060
)
6161
SELECT metrics_json FROM recent_metrics ORDER BY json_extract(metrics_json, '$.timestamp') ASC
6262
`
63-
rows, err := db.Query(query, containerName, limit)
63+
rows, err := db.Query(query, containerName, containerName+".%", limit)
6464
if err != nil {
6565
return nil, err
6666
}
@@ -90,12 +90,12 @@ func (db *DB) GetAllMetricsContainer(containerName string) ([]ContainerMetric, e
9090
WITH recent_metrics AS (
9191
SELECT metrics_json
9292
FROM container_metrics
93-
WHERE container_name = ?
93+
WHERE container_name = ? OR container_name LIKE ?
9494
ORDER BY timestamp DESC
9595
)
9696
SELECT metrics_json FROM recent_metrics ORDER BY json_extract(metrics_json, '$.timestamp') ASC
9797
`
98-
rows, err := db.Query(query, containerName)
98+
rows, err := db.Query(query, containerName, containerName+".%")
9999
if err != nil {
100100
return nil, err
101101
}

0 commit comments

Comments
 (0)