Skip to content
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

247 add db size to status page #252

Merged
merged 3 commits into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/app/pages/admin/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function AdminStatusCtrl($scope, $http, $timeout, currentUser, Events) {
delete data.workers;
$scope.manager = data.manager;
delete data.manager;
$scope.database_metrics = data.database_metrics;
delete data.database_metrics;
$scope.status = data;
});

Expand Down
10 changes: 10 additions & 0 deletions client/app/pages/admin/status/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,15 @@
</li>
</ul>
</div>
<BR>
<div>
<ul class="list-group col-lg-4">
<li class="list-group-item active">Redash Database</li>
<li class="list-group-item" ng-repeat="(name, size) in database_metrics">
<span class="badge">{{size[1]}}</span>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<span> open and closed tags don't match. You may need an open span on the next line.

<span> {{size[0]}} </span>
</li>
</ul>
</div>
</div>
</div>
10 changes: 10 additions & 0 deletions redash/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ def get_status():
'size': redis_connection.llen(queue)
}

status['database_metrics'] = []
# have to include the fake FROM in the SQL to prevent an IndexError
queries = [
['Query Results Size', "pg_size_pretty(pg_total_relation_size('query_results')) as size from (select 1) as a"],
['Redash DB Size', "pg_size_pretty(pg_database_size('postgres')) as size from (select 1) as a"]
]
for query_name, query in queries:
result = models.db.session.query(query).first()
status['database_metrics'].append([query_name, result[0]])

return status