Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
95c8766f
Unverified
Commit
95c8766f
authored
Feb 18, 2021
by
Carl Bergquist
Committed by
GitHub
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Usagestats: Exclude folders from total dashboard count (#31320)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
parent
0e63dfaf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
pkg/infra/metrics/metrics.go
+10
-0
pkg/infra/usagestats/usage_stats.go
+1
-0
pkg/services/sqlstore/stats.go
+2
-2
No files found.
pkg/infra/metrics/metrics.go
View file @
95c8766f
...
...
@@ -126,6 +126,9 @@ var (
// MStatTotalDashboards is a metric total amount of dashboards
MStatTotalDashboards
prometheus
.
Gauge
// MStatTotalDashboards is a metric total amount of dashboards
MStatTotalFolders
prometheus
.
Gauge
// MStatTotalUsers is a metric total amount of users
MStatTotalUsers
prometheus
.
Gauge
...
...
@@ -412,6 +415,12 @@ func init() {
Namespace
:
ExporterName
,
})
MStatTotalFolders
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_totals_folder"
,
Help
:
"total amount of folders"
,
Namespace
:
ExporterName
,
})
MStatTotalUsers
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_total_users"
,
Help
:
"total amount of users"
,
...
...
@@ -575,6 +584,7 @@ func initMetricVars() {
MRenderingQueue
,
MAlertingActiveAlerts
,
MStatTotalDashboards
,
MStatTotalFolders
,
MStatTotalUsers
,
MStatActiveUsers
,
MStatTotalOrgs
,
...
...
pkg/infra/usagestats/usage_stats.go
View file @
95c8766f
...
...
@@ -265,6 +265,7 @@ func (uss *UsageStatsService) updateTotalStats() {
}
metrics
.
MStatTotalDashboards
.
Set
(
float64
(
statsQuery
.
Result
.
Dashboards
))
metrics
.
MStatTotalFolders
.
Set
(
float64
(
statsQuery
.
Result
.
Folders
))
metrics
.
MStatTotalUsers
.
Set
(
float64
(
statsQuery
.
Result
.
Users
))
metrics
.
MStatActiveUsers
.
Set
(
float64
(
statsQuery
.
Result
.
ActiveUsers
))
metrics
.
MStatTotalPlaylists
.
Set
(
float64
(
statsQuery
.
Result
.
Playlists
))
...
...
pkg/services/sqlstore/stats.go
View file @
95c8766f
...
...
@@ -46,7 +46,6 @@ func GetSystemStats(query *models.GetSystemStatsQuery) error {
sb
.
Write
(
"SELECT "
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"user"
)
+
`) AS users,`
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"org"
)
+
`) AS orgs,`
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"dashboard"
)
+
`) AS dashboards,`
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"data_source"
)
+
`) AS datasources,`
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"star"
)
+
`) AS stars,`
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"playlist"
)
+
`) AS playlists,`
)
...
...
@@ -55,6 +54,7 @@ func GetSystemStats(query *models.GetSystemStatsQuery) error {
activeUserDeadlineDate
:=
time
.
Now
()
.
Add
(
-
activeUserTimeLimit
)
sb
.
Write
(
`(SELECT COUNT(*) FROM `
+
dialect
.
Quote
(
"user"
)
+
` WHERE last_seen_at > ?) AS active_users,`
,
activeUserDeadlineDate
)
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"dashboard"
)
+
` WHERE is_folder = ?) AS dashboards,`
,
dialect
.
BooleanStr
(
false
))
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"dashboard"
)
+
` WHERE is_folder = ?) AS folders,`
,
dialect
.
BooleanStr
(
true
))
sb
.
Write
(
`(
...
...
@@ -119,7 +119,7 @@ func GetAdminStats(query *models.GetAdminStatsQuery) error {
) AS orgs,
(
SELECT COUNT(*)
FROM `
+
dialect
.
Quote
(
"dashboard"
)
+
`
FROM `
+
dialect
.
Quote
(
"dashboard"
)
+
`
WHERE is_folder=`
+
dialect
.
BooleanStr
(
false
)
+
`
) AS dashboards,
(
SELECT COUNT(*)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment