Преглед на файлове

Added grafana_admins count

utkarshcmu преди 10 години
родител
ревизия
2190392e05
променени са 4 файла, в които са добавени 25 реда и са изтрити 12 реда
  1. 2 1
      docs/sources/reference/http_api.md
  2. 9 8
      pkg/models/stats.go
  3. 5 1
      pkg/services/sqlstore/stats.go
  4. 9 2
      public/app/features/admin/partials/stats.html

+ 2 - 1
docs/sources/reference/http_api.md

@@ -1446,7 +1446,8 @@ Keys:
       "db_tag_count":6,
       "data_source_count":1,
       "playlist_count":1,
-      "starred_db_count":2
+      "starred_db_count":2,
+      "grafana_admin_count":2
     }
 
 ### Global Users

+ 9 - 8
pkg/models/stats.go

@@ -20,14 +20,15 @@ type GetDataSourceStatsQuery struct {
 }
 
 type AdminStats struct {
-	UserCount       int `json:"user_count"`
-	OrgCount        int `json:"org_count"`
-	DashboardCount  int `json:"dashboard_count"`
-	DbSnapshotCount int `json:"db_snapshot_count"`
-	DbTagCount      int `json:"db_tag_count"`
-	DataSourceCount int `json:"data_source_count"`
-	PlaylistCount   int `json:"playlist_count"`
-	StarredDbCount  int `json:"starred_db_count"`
+	UserCount         int `json:"user_count"`
+	OrgCount          int `json:"org_count"`
+	DashboardCount    int `json:"dashboard_count"`
+	DbSnapshotCount   int `json:"db_snapshot_count"`
+	DbTagCount        int `json:"db_tag_count"`
+	DataSourceCount   int `json:"data_source_count"`
+	PlaylistCount     int `json:"playlist_count"`
+	StarredDbCount    int `json:"starred_db_count"`
+	GrafanaAdminCount int `json:"grafana_admin_count"`
 }
 
 type GetAdminStatsQuery struct {

+ 5 - 1
pkg/services/sqlstore/stats.go

@@ -81,7 +81,11 @@ func GetAdminStats(query *m.GetAdminStatsQuery) error {
       (
         SELECT COUNT (DISTINCT ` + dialect.Quote("dashboard_id") + ` )
         FROM ` + dialect.Quote("star") + `
-      ) AS starred_db_count
+      ) AS starred_db_count,
+      (
+        SELECT SUM ( ` + dialect.Quote("is_admin") + ` )
+        FROM ` + dialect.Quote("user") + `
+      ) AS grafana_admin_count
       `
 
 	var stats m.AdminStats

+ 9 - 2
public/app/features/admin/partials/stats.html

@@ -1,10 +1,13 @@
-<topnav icon="fa fa-fw fa-bar-chart" title="Grafana stats">
+<topnav icon="fa fa-fw fa-bar-chart" title="Grafana stats"  subnav="true">
+  <ul class="nav">
+    <li class="active"><a href="admin/stats">Overview</a></li>
+  </ul>
 </topnav>
 
 <div class="page-container">
 	<div class="page-wide">
 		<h1>
-			Stats
+			Overview
 		</h1>
 
     <table class="filter-table form-inline">
@@ -23,6 +26,10 @@
           <td>Total users</td>
           <td>{{stats.user_count}}</td>
         </tr>
+        <tr>
+          <td>Total grafana admins</td>
+          <td>{{stats.grafana_admin_count}}</td>
+        </tr>
         <tr>
           <td>Total organizations</td>
           <td>{{stats.org_count}}</td>