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
26852ca7
Unverified
Commit
26852ca7
authored
Jul 03, 2020
by
Carl Bergquist
Committed by
GitHub
Jul 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instrument dashboard versions and annotation count (#26044)
parent
081f954a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
0 deletions
+32
-0
pkg/infra/metrics/metrics.go
+20
-0
pkg/infra/usagestats/usage_stats.go
+4
-0
pkg/infra/usagestats/usage_stats_test.go
+4
-0
pkg/models/stats.go
+2
-0
pkg/services/sqlstore/stats.go
+2
-0
No files found.
pkg/infra/metrics/metrics.go
View file @
26852ca7
...
...
@@ -159,6 +159,12 @@ var (
// StatsTotalDataSources is a metric total number of defined datasources, labeled by pluginId
StatsTotalDataSources
*
prometheus
.
GaugeVec
// StatsTotalAnnotations is a metric of total number of annotations stored in Grafana.
StatsTotalAnnotations
prometheus
.
Gauge
// StatsTotalDashboardVersions is a metric of total number of dashboard versions stored in Grafana.
StatsTotalDashboardVersions
prometheus
.
Gauge
// grafanaBuildVersion is a metric with a constant '1' value labeled by version, revision, branch, and goversion from which Grafana was built
grafanaBuildVersion
*
prometheus
.
GaugeVec
...
...
@@ -483,6 +489,18 @@ func init() {
Help
:
"A metric with a constant '1' value labeled by pluginId, pluginType and version from which Grafana plugin was built"
,
Namespace
:
ExporterName
,
},
[]
string
{
"plugin_id"
,
"plugin_type"
,
"version"
})
StatsTotalDashboardVersions
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_totals_dashboard_versions"
,
Help
:
"total amount of dashboard versions in the database"
,
Namespace
:
ExporterName
,
})
StatsTotalAnnotations
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"stat_totals_annotations"
,
Help
:
"total amount of annotations in the database"
,
Namespace
:
ExporterName
,
})
}
// SetBuildInformation sets the build information for this binary
...
...
@@ -550,6 +568,8 @@ func initMetricVars() {
StatsTotalDataSources
,
grafanaBuildVersion
,
grafanaPluginBuildInfoDesc
,
StatsTotalDashboardVersions
,
StatsTotalAnnotations
,
)
}
...
...
pkg/infra/usagestats/usage_stats.go
View file @
26852ca7
...
...
@@ -61,6 +61,8 @@ func (uss *UsageStatsService) sendUsageStats(oauthProviders map[string]bool) {
metrics
[
"stats.snapshots.count"
]
=
statsQuery
.
Result
.
Snapshots
metrics
[
"stats.teams.count"
]
=
statsQuery
.
Result
.
Teams
metrics
[
"stats.total_auth_token.count"
]
=
statsQuery
.
Result
.
AuthTokens
metrics
[
"stats.dashboard_versions.count"
]
=
statsQuery
.
Result
.
DashboardVersions
metrics
[
"stats.annotations.count"
]
=
statsQuery
.
Result
.
Annotations
metrics
[
"stats.valid_license.count"
]
=
getValidLicenseCount
(
uss
.
License
.
HasValidLicense
())
metrics
[
"stats.edition.oss.count"
]
=
getOssEditionCount
()
metrics
[
"stats.edition.enterprise.count"
]
=
getEnterpriseEditionCount
()
...
...
@@ -212,6 +214,8 @@ func (uss *UsageStatsService) updateTotalStats() {
metrics
.
StatsTotalActiveEditors
.
Set
(
float64
(
statsQuery
.
Result
.
ActiveEditors
))
metrics
.
StatsTotalAdmins
.
Set
(
float64
(
statsQuery
.
Result
.
Admins
))
metrics
.
StatsTotalActiveAdmins
.
Set
(
float64
(
statsQuery
.
Result
.
ActiveAdmins
))
metrics
.
StatsTotalDashboardVersions
.
Set
(
float64
(
statsQuery
.
Result
.
DashboardVersions
))
metrics
.
StatsTotalAnnotations
.
Set
(
float64
(
statsQuery
.
Result
.
Annotations
))
dsStats
:=
models
.
GetDataSourceStatsQuery
{}
if
err
:=
uss
.
Bus
.
Dispatch
(
&
dsStats
);
err
!=
nil
{
...
...
pkg/infra/usagestats/usage_stats_test.go
View file @
26852ca7
...
...
@@ -50,6 +50,8 @@ func TestMetrics(t *testing.T) {
Snapshots
:
13
,
Teams
:
14
,
AuthTokens
:
15
,
DashboardVersions
:
16
,
Annotations
:
17
,
}
getSystemStatsQuery
=
query
return
nil
...
...
@@ -238,6 +240,8 @@ func TestMetrics(t *testing.T) {
So
(
metrics
.
Get
(
"stats.teams.count"
)
.
MustInt
(),
ShouldEqual
,
getSystemStatsQuery
.
Result
.
Teams
)
So
(
metrics
.
Get
(
"stats.total_auth_token.count"
)
.
MustInt64
(),
ShouldEqual
,
15
)
So
(
metrics
.
Get
(
"stats.avg_auth_token_per_user.count"
)
.
MustInt64
(),
ShouldEqual
,
5
)
So
(
metrics
.
Get
(
"stats.dashboard_versions.count"
)
.
MustInt64
(),
ShouldEqual
,
16
)
So
(
metrics
.
Get
(
"stats.annotations.count"
)
.
MustInt64
(),
ShouldEqual
,
17
)
So
(
metrics
.
Get
(
"stats.ds."
+
models
.
DS_ES
+
".count"
)
.
MustInt
(),
ShouldEqual
,
9
)
So
(
metrics
.
Get
(
"stats.ds."
+
models
.
DS_PROMETHEUS
+
".count"
)
.
MustInt
(),
ShouldEqual
,
10
)
...
...
pkg/models/stats.go
View file @
26852ca7
...
...
@@ -16,6 +16,8 @@ type SystemStats struct {
Folders
int64
ProvisionedDashboards
int64
AuthTokens
int64
DashboardVersions
int64
Annotations
int64
Admins
int
Editors
int
...
...
pkg/services/sqlstore/stats.go
View file @
26852ca7
...
...
@@ -75,6 +75,8 @@ func GetSystemStats(query *models.GetSystemStatsQuery) error {
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"dashboard_provisioning"
)
+
`) AS provisioned_dashboards,`
)
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"dashboard_snapshot"
)
+
`) AS snapshots,`
)
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"dashboard_version"
)
+
`) AS dashboard_versions,`
)
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"annotation"
)
+
`) AS annotations,`
)
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"team"
)
+
`) AS teams,`
)
sb
.
Write
(
`(SELECT COUNT(id) FROM `
+
dialect
.
Quote
(
"user_auth_token"
)
+
`) AS auth_tokens,`
)
...
...
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