Group AI errors by owner service
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
CREATE INDEX IF NOT EXISTS ai_jobs_owner_error_stats_idx
|
||||||
|
ON ai_jobs (owner_service, task_type, model_profile, error_code, updated_at DESC)
|
||||||
|
WHERE status = 'failed';
|
||||||
@@ -111,6 +111,7 @@ type QueueStat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ErrorStat struct {
|
type ErrorStat struct {
|
||||||
|
OwnerService string `json:"owner_service,omitempty"`
|
||||||
TaskType string `json:"task_type"`
|
TaskType string `json:"task_type"`
|
||||||
ModelProfile string `json:"model_profile"`
|
ModelProfile string `json:"model_profile"`
|
||||||
ErrorCode string `json:"error_code"`
|
ErrorCode string `json:"error_code"`
|
||||||
|
|||||||
@@ -599,13 +599,13 @@ ORDER BY owner_service, task_type, model_profile, status
|
|||||||
}
|
}
|
||||||
|
|
||||||
errorRows, err := s.pool.Query(ctx, `
|
errorRows, err := s.pool.Query(ctx, `
|
||||||
SELECT task_type, model_profile, COALESCE(NULLIF(error_code, ''), 'unknown') AS error_code,
|
SELECT owner_service, task_type, model_profile, COALESCE(NULLIF(error_code, ''), 'unknown') AS error_code,
|
||||||
count(*) AS total,
|
count(*) AS total,
|
||||||
count(*) FILTER (WHERE updated_at > NOW() - INTERVAL '24 hours') AS last_24h
|
count(*) FILTER (WHERE updated_at > NOW() - INTERVAL '24 hours') AS last_24h
|
||||||
FROM ai_jobs
|
FROM ai_jobs
|
||||||
WHERE status = 'failed'
|
WHERE status = 'failed'
|
||||||
GROUP BY task_type, model_profile, COALESCE(NULLIF(error_code, ''), 'unknown')
|
GROUP BY owner_service, task_type, model_profile, COALESCE(NULLIF(error_code, ''), 'unknown')
|
||||||
ORDER BY last_24h DESC, total DESC
|
ORDER BY owner_service, last_24h DESC, total DESC
|
||||||
`)
|
`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -613,7 +613,7 @@ ORDER BY last_24h DESC, total DESC
|
|||||||
defer errorRows.Close()
|
defer errorRows.Close()
|
||||||
for errorRows.Next() {
|
for errorRows.Next() {
|
||||||
var stat model.ErrorStat
|
var stat model.ErrorStat
|
||||||
if err := errorRows.Scan(&stat.TaskType, &stat.ModelProfile, &stat.ErrorCode, &stat.Total, &stat.Last24h); err != nil {
|
if err := errorRows.Scan(&stat.OwnerService, &stat.TaskType, &stat.ModelProfile, &stat.ErrorCode, &stat.Total, &stat.Last24h); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
out.Errors = append(out.Errors, stat)
|
out.Errors = append(out.Errors, stat)
|
||||||
|
|||||||
1
migrations/006_ai_jobs_owner_error_stats.down.sql
Normal file
1
migrations/006_ai_jobs_owner_error_stats.down.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DROP INDEX IF EXISTS ai_jobs_owner_error_stats_idx;
|
||||||
3
migrations/006_ai_jobs_owner_error_stats.up.sql
Normal file
3
migrations/006_ai_jobs_owner_error_stats.up.sql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CREATE INDEX IF NOT EXISTS ai_jobs_owner_error_stats_idx
|
||||||
|
ON ai_jobs (owner_service, task_type, model_profile, error_code, updated_at DESC)
|
||||||
|
WHERE status = 'failed';
|
||||||
Reference in New Issue
Block a user