From 612833404b0028a8079cfe588c850d81ec72d3ac Mon Sep 17 00:00:00 2001 From: Omer Lachish Date: Wed, 23 Oct 2019 11:20:15 +0300 Subject: [PATCH] show current worker job (alongside with minor cosmetic column tweaks) (#4262) --- client/app/components/admin/RQStatus.jsx | 8 +++++--- redash/monitor.py | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/app/components/admin/RQStatus.jsx b/client/app/components/admin/RQStatus.jsx index fff2bc07..4e6636dc 100644 --- a/client/app/components/admin/RQStatus.jsx +++ b/client/app/components/admin/RQStatus.jsx @@ -24,9 +24,11 @@ const workersColumns = [Columns.custom( /> {value} ), { title: 'State', dataIndex: 'state' }, -)].concat(map(['Hostname', 'PID', 'Name', 'Queues', 'Successful Job Count', - 'Failed Job Count', 'Birth Date', 'Total Working Time'], -c => ({ title: c, dataIndex: c.toLowerCase().replace(/\s/g, '_') }))); +)].concat(map(['Hostname', 'PID', 'Name', 'Queues', 'Current Job', 'Successful Jobs', 'Failed Jobs'], + c => ({ title: c, dataIndex: c.toLowerCase().replace(/\s/g, '_') }))).concat([ + Columns.dateTime({ title: 'Birth Date', dataIndex: 'birth_date' }), + Columns.duration({ title: 'Total Working Time', dataIndex: 'total_working_time' }), +]); const queuesColumns = map( ['Name', 'Started', 'Queued'], diff --git a/redash/monitor.py b/redash/monitor.py index f0d8abfa..8e7329aa 100644 --- a/redash/monitor.py +++ b/redash/monitor.py @@ -159,6 +159,10 @@ def rq_queues(): } for q in Queue.all(connection=redis_connection)} +def describe_job(job): + return '{} ({})'.format(job.id, job.func_name.split(".").pop()) if job else None + + def rq_workers(): return [{ 'name': w.name, @@ -168,8 +172,9 @@ def rq_workers(): 'state': w.state, 'last_heartbeat': w.last_heartbeat, 'birth_date': w.birth_date, - 'successful_job_count': w.successful_job_count, - 'failed_job_count': w.failed_job_count, + 'current_job': describe_job(w.get_current_job()), + 'successful_jobs': w.successful_job_count, + 'failed_jobs': w.failed_job_count, 'total_working_time': w.total_working_time } for w in Worker.all(connection=redis_connection)]