-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Celery/Queries Execution Status API #3057
Merged
Merged
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
bee2670
Remove QueryTaskTracker
arikfr 15d05c0
Remove scheudling of cleanup_tasks
arikfr c8270eb
Add Celery introspection tools
arikfr 517b437
First iteration of updating the admin API.
arikfr 6409d29
Show more details
arikfr 25a15f7
Add option to skip building npm in Dockerfile
arikfr ad00770
Show started_at
arikfr 522aebf
update the refresh schedule, as it's too fast
arikfr 5aa001e
Update Celery monitor to report on all active tasks.
arikfr e1e499e
Merge branch 'master' into celery-introspection
arikfr 81fda79
Merge branch 'master' into celery-introspection
arikfr 3710358
Update task parsing for new format
arikfr e467817
WIP: improved celery status screen
arikfr d129c24
Fix property name.
arikfr 6ca92e1
Update counters
arikfr bb55042
Merge branch 'master' into celery-introspection
arikfr 4147f0d
Merge branch 'celery-introspection' of github.com:getredash/redash in…
arikfr b558b3b
Update tab name
arikfr 3e1a302
Update counters names
arikfr 3c8b208
Move component to its own file and fix lint issues
arikfr dc684d7
Add migratin to remove Redis keys
arikfr 7efa30c
Improve columns layout
arikfr 5726b3d
Remove skip_npm_build arg as it's not used anymore.
arikfr 212dcbb
Convert query from SQL to Python
arikfr dfc5e26
Merge branch 'celery-introspection' of github.com:getredash/redash in…
arikfr 254106f
Simplify column definition.
arikfr b0f2248
Show alert on error.
arikfr 693451f
Merge branch 'master' into celery-introspection
arikfr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { $http } from '@/services/ng'; | ||
import Table from 'antd/lib/table'; | ||
import Col from 'antd/lib/col'; | ||
import Row from 'antd/lib/row'; | ||
import Card from 'antd/lib/card'; | ||
import Spin from 'antd/lib/spin'; | ||
import Badge from 'antd/lib/badge'; | ||
import Tabs from 'antd/lib/tabs'; | ||
import moment from 'moment'; | ||
import values from 'lodash/values'; | ||
import { Columns } from '@/components/items-list/components/ItemsTable'; | ||
|
||
function parseTasks(tasks) { | ||
const queues = {}; | ||
const queries = []; | ||
const otherTasks = []; | ||
|
||
const counters = { active: 0, reserved: 0, waiting: 0 }; | ||
|
||
tasks.forEach((task) => { | ||
queues[task.queue] = queues[task.queue] || { name: task.queue, active: 0, reserved: 0, waiting: 0 }; | ||
queues[task.queue][task.state] += 1; | ||
|
||
if (task.enqueue_time) { | ||
task.enqueue_time = moment(task.enqueue_time * 1000.0); | ||
} | ||
if (task.start_time) { | ||
task.start_time = moment(task.start_time * 1000.0); | ||
} | ||
|
||
counters[task.state] += 1; | ||
|
||
if (task.task_name === 'redash.tasks.execute_query') { | ||
queries.push(task); | ||
} else { | ||
otherTasks.push(task); | ||
} | ||
}); | ||
|
||
return { queues: values(queues), queries, otherTasks, counters }; | ||
} | ||
|
||
function QueuesTable({ loading, queues }) { | ||
const columns = [ | ||
{ | ||
title: 'Name', | ||
dataIndex: 'name', | ||
}, | ||
{ | ||
title: 'Active', | ||
dataIndex: 'active', | ||
}, | ||
{ | ||
title: 'Reserved', | ||
dataIndex: 'reserved', | ||
}, | ||
{ | ||
title: 'Waiting', | ||
dataIndex: 'waiting', | ||
}, | ||
]; | ||
return <Table columns={columns} rowKey="name" dataSource={queues} loading={loading} />; | ||
} | ||
|
||
QueuesTable.propTypes = { | ||
loading: PropTypes.bool.isRequired, | ||
queues: PropTypes.arrayOf(PropTypes.any).isRequired, | ||
}; | ||
|
||
function CounterCard({ title, value, loading }) { | ||
return ( | ||
<Spin spinning={loading}> | ||
<Card> | ||
{title} | ||
<div className="f-20">{value}</div> | ||
</Card> | ||
</Spin> | ||
); | ||
} | ||
|
||
CounterCard.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
loading: PropTypes.bool.isRequired, | ||
}; | ||
|
||
CounterCard.defaultProps = { | ||
value: '', | ||
}; | ||
|
||
export default class AdminCeleryStatus extends React.Component { | ||
state = { | ||
loading: true, | ||
counters: {}, | ||
queries: [], | ||
otherTasks: [], | ||
queues: [], | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.fetch(); | ||
} | ||
|
||
fetch() { | ||
// TODO: handle error | ||
arikfr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$http.get('/api/admin/queries/tasks').then(({ data }) => { | ||
const { queues, queries, otherTasks, counters } = parseTasks(data.tasks); | ||
this.setState({ loading: false, queries, otherTasks, queues, counters }); | ||
}); | ||
} | ||
|
||
render() { | ||
const commonColumns = [ | ||
{ | ||
title: 'Worker Name', | ||
dataIndex: 'worker', | ||
}, | ||
{ | ||
title: 'PID', | ||
dataIndex: 'worker_pid', | ||
}, | ||
{ | ||
title: 'Queue', | ||
dataIndex: 'queue', | ||
}, | ||
{ | ||
title: 'State', | ||
dataIndex: 'state', | ||
render: (value) => { | ||
if (value === 'active') { | ||
return ( | ||
<span> | ||
<Badge status="processing" /> Active | ||
</span> | ||
); | ||
} | ||
return ( | ||
<span> | ||
<Badge status="warning" /> {value} | ||
</span> | ||
); | ||
}, | ||
}, | ||
Columns.timeAgo({ title: 'Start Time', dataIndex: 'start_time' }), | ||
]; | ||
|
||
const queryColumns = commonColumns.concat([ | ||
Columns.timeAgo({ title: 'Enqueue Time', dataIndex: 'enqueue_time' }), | ||
{ | ||
title: 'Query ID', | ||
arikfr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dataIndex: 'query_id', | ||
}, | ||
{ | ||
title: 'Org ID', | ||
dataIndex: 'org_id', | ||
}, | ||
{ | ||
title: 'Data Source ID', | ||
dataIndex: 'data_source_id', | ||
}, | ||
{ | ||
title: 'User ID', | ||
dataIndex: 'user_id', | ||
}, | ||
{ | ||
title: 'Scheduled', | ||
dataIndex: 'scheduled', | ||
}, | ||
]); | ||
|
||
const otherTasksColumns = commonColumns.concat([ | ||
{ | ||
title: 'Task Name', | ||
dataIndex: 'task_name', | ||
}, | ||
]); | ||
|
||
return ( | ||
<div className="p-5"> | ||
<Row gutter={16}> | ||
<Col span={4}> | ||
<CounterCard title="Active Tasks" value={this.state.counters.active} loading={this.state.loading} /> | ||
</Col> | ||
<Col span={4}> | ||
<CounterCard title="Reserved Tasks" value={this.state.counters.reserved} loading={this.state.loading} /> | ||
</Col> | ||
<Col span={4}> | ||
<CounterCard title="Waiting Tasks" value={this.state.counters.waiting} loading={this.state.loading} /> | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Tabs defaultActiveKey="queues"> | ||
<Tabs.TabPane key="queues" tab="Queues"> | ||
<QueuesTable loading={this.state.loading} queues={this.state.queues} /> | ||
</Tabs.TabPane> | ||
<Tabs.TabPane key="queries" tab="Queries"> | ||
<Table | ||
rowKey="task_id" | ||
dataSource={this.state.queries} | ||
loading={this.state.loading} | ||
columns={queryColumns} | ||
/> | ||
</Tabs.TabPane> | ||
<Tabs.TabPane key="other" tab="Other Tasks"> | ||
<Table | ||
rowKey="task_id" | ||
dataSource={this.state.otherTasks} | ||
loading={this.state.loading} | ||
columns={otherTasksColumns} | ||
/> | ||
</Tabs.TabPane> | ||
</Tabs> | ||
</Row> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
254106f