fix: enhance container metrics query to support wildcard matching for container names

This commit is contained in:
Mauricio Siu
2026-03-08 16:16:45 -06:00
parent 8e9ab98a7a
commit c00aa6acbf
+4 -4
View File
@@ -54,13 +54,13 @@ func (db *DB) GetLastNContainerMetrics(containerName string, limit int) ([]Conta
WITH recent_metrics AS (
SELECT metrics_json
FROM container_metrics
WHERE container_name = ?
WHERE container_name = ? OR container_name LIKE ?
ORDER BY timestamp DESC
LIMIT ?
)
SELECT metrics_json FROM recent_metrics ORDER BY json_extract(metrics_json, '$.timestamp') ASC
`
rows, err := db.Query(query, containerName, limit)
rows, err := db.Query(query, containerName, containerName+".%", limit)
if err != nil {
return nil, err
}
@@ -90,12 +90,12 @@ func (db *DB) GetAllMetricsContainer(containerName string) ([]ContainerMetric, e
WITH recent_metrics AS (
SELECT metrics_json
FROM container_metrics
WHERE container_name = ?
WHERE container_name = ? OR container_name LIKE ?
ORDER BY timestamp DESC
)
SELECT metrics_json FROM recent_metrics ORDER BY json_extract(metrics_json, '$.timestamp') ASC
`
rows, err := db.Query(query, containerName)
rows, err := db.Query(query, containerName, containerName+".%")
if err != nil {
return nil, err
}