mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 00:02:19 +00:00
49ed757424
* feat: add prometheus metric queue_running_count Adds a new Prometheus metric queue_running_count that tracks the number of currently running jobs per tag, similar to the existing queue_count metric but filtered for running=true instead of running=false. Changes: - Added get_queue_running_counts() function in windmill-common/src/queue.rs - Added QUEUE_RUNNING_COUNT Prometheus metric in monitor.rs - Added /workers/queue_running_counts API endpoint - Updated OpenAPI specification - Added SQLx query cache entry Requested by @rubenfiszel 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * Remove database insertion for queue_running_count metrics Keep Prometheus metrics and API endpoint functionality while removing the database INSERT statements as requested. Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com> * sqlx * improve logic --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> Co-authored-by: Ruben Fiszel <rubenfiszel@users.noreply.github.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
30 lines
898 B
Rust
30 lines
898 B
Rust
use std::collections::HashMap;
|
|
|
|
use sqlx::{Pool, Postgres};
|
|
|
|
pub async fn get_queue_counts(db: &Pool<Postgres>) -> HashMap<String, u32> {
|
|
sqlx::query!(
|
|
"SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM v2_job_queue WHERE
|
|
scheduled_for <= now() - ('3 seconds')::interval AND running = false
|
|
GROUP BY tag",
|
|
)
|
|
.fetch_all(db)
|
|
.await
|
|
.ok()
|
|
.map(|v| v.into_iter().map(|x| (x.tag, x.count as u32)).collect())
|
|
.unwrap_or_else(|| HashMap::new())
|
|
}
|
|
|
|
pub async fn get_queue_running_counts(db: &Pool<Postgres>) -> HashMap<String, u32> {
|
|
sqlx::query!(
|
|
"SELECT tag AS \"tag!\", count(*) AS \"count!\" FROM v2_job_queue WHERE
|
|
running = true
|
|
GROUP BY tag",
|
|
)
|
|
.fetch_all(db)
|
|
.await
|
|
.ok()
|
|
.map(|v| v.into_iter().map(|x| (x.tag, x.count as u32)).collect())
|
|
.unwrap_or_else(|| HashMap::new())
|
|
}
|