mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 18:01:40 -06:00
Public Dashboards: count public dashboards view requests (#52419)
This commit is contained in:
parent
0300b1c674
commit
e0a58300ac
@ -113,7 +113,7 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
}
|
||||
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagPublicDashboards) {
|
||||
r.Get("/public-dashboards/:accessToken", publicdashboardsapi.SetPublicDashboardFlag(), hs.Index)
|
||||
r.Get("/public-dashboards/:accessToken", publicdashboardsapi.SetPublicDashboardFlag(), publicdashboardsapi.CountPublicDashboardRequest(), hs.Index)
|
||||
}
|
||||
|
||||
r.Get("/explore", authorize(func(c *models.ReqContext) {
|
||||
|
@ -101,6 +101,9 @@ var (
|
||||
|
||||
// MAccessEvaluationCount is a metric gauge for total number of evaluation requests
|
||||
MAccessEvaluationCount prometheus.Counter
|
||||
|
||||
// MPublicDashboardRequestCount is a metric counter for public dashboards requests
|
||||
MPublicDashboardRequestCount prometheus.Counter
|
||||
)
|
||||
|
||||
// Timers
|
||||
@ -410,6 +413,12 @@ func init() {
|
||||
Namespace: ExporterName,
|
||||
})
|
||||
|
||||
MPublicDashboardRequestCount = metricutil.NewCounterStartingAtZero(prometheus.CounterOpts{
|
||||
Name: "public_dashboard_request_count",
|
||||
Help: "counter for public dashboards requests",
|
||||
Namespace: ExporterName,
|
||||
})
|
||||
|
||||
MStatTotalDashboards = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "stat_totals_dashboard",
|
||||
Help: "total amount of dashboards",
|
||||
@ -654,5 +663,6 @@ func initMetricVars() {
|
||||
StatsTotalLibraryVariables,
|
||||
StatsTotalDataKeys,
|
||||
MStatTotalPublicDashboards,
|
||||
MPublicDashboardRequestCount,
|
||||
)
|
||||
}
|
||||
|
@ -1,9 +1,18 @@
|
||||
package api
|
||||
|
||||
import "github.com/grafana/grafana/pkg/models"
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
|
||||
func SetPublicDashboardFlag() func(c *models.ReqContext) {
|
||||
return func(c *models.ReqContext) {
|
||||
c.IsPublicDashboardView = true
|
||||
}
|
||||
}
|
||||
|
||||
func CountPublicDashboardRequest() func(c *models.ReqContext) {
|
||||
return func(c *models.ReqContext) {
|
||||
metrics.MPublicDashboardRequestCount.Inc()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user