mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
3ee26df41e
Co-authored-by: Juan Cabanas <juan.cabanas@grafana.com> Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com> Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package clientmiddleware
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
const (
|
|
QueryPubdash = "pubdash"
|
|
QueryDashboard = "dashboard"
|
|
)
|
|
|
|
var QueryCachingRequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: metrics.ExporterName,
|
|
Subsystem: "caching",
|
|
Name: "query_caching_request_duration_seconds",
|
|
Help: "histogram of grafana query endpoint requests in seconds",
|
|
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
|
}, []string{"datasource_type", "cache", "query_type"})
|
|
|
|
var ShouldCacheQueryHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: metrics.ExporterName,
|
|
Subsystem: "caching",
|
|
Name: "should_cache_query_request_duration_seconds",
|
|
Help: "histogram of grafana query endpoint requests in seconds",
|
|
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
|
}, []string{"datasource_type", "cache", "shouldCache", "query_type"})
|
|
|
|
var ResourceCachingRequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: metrics.ExporterName,
|
|
Subsystem: "caching",
|
|
Name: "resource_caching_request_duration_seconds",
|
|
Help: "histogram of grafana resource endpoint requests in seconds",
|
|
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
|
|
}, []string{"plugin_id", "cache"})
|
|
|
|
func getQueryType(req *contextmodel.ReqContext) string {
|
|
if req.IsPublicDashboardView() {
|
|
return QueryPubdash
|
|
}
|
|
return QueryDashboard
|
|
}
|