Skip to content

Commit

Permalink
adds redash db size metrics to status page (re getredash#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
alison985 authored and Allen Short committed Jan 8, 2018
1 parent 93d0593 commit 9b1b27b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
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>
<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 @@ -30,4 +30,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

0 comments on commit 9b1b27b

Please sign in to comment.