2023-04-17 18:12:44 -05:00
|
|
|
package expr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
metricsSubSystem = "sse"
|
|
|
|
metricsNamespace = "grafana"
|
|
|
|
)
|
|
|
|
|
|
|
|
type metrics struct {
|
|
|
|
dsRequests *prometheus.CounterVec
|
|
|
|
|
|
|
|
// older metric
|
|
|
|
expressionsQuerySummary *prometheus.SummaryVec
|
|
|
|
}
|
|
|
|
|
|
|
|
func newMetrics(reg prometheus.Registerer) *metrics {
|
|
|
|
m := &metrics{
|
|
|
|
dsRequests: prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
|
|
Namespace: metricsNamespace,
|
|
|
|
Subsystem: metricsSubSystem,
|
|
|
|
Name: "ds_queries_total",
|
|
|
|
Help: "Number of datasource queries made via server side expression requests",
|
2023-07-26 09:51:02 -05:00
|
|
|
}, []string{"error", "dataplane", "datasource_type"}),
|
2023-04-17 18:12:44 -05:00
|
|
|
|
|
|
|
// older (No Namespace or Subsystem)
|
|
|
|
expressionsQuerySummary: prometheus.NewSummaryVec(
|
|
|
|
prometheus.SummaryOpts{
|
|
|
|
Name: "expressions_queries_duration_milliseconds",
|
|
|
|
Help: "Expressions query summary",
|
|
|
|
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
|
|
|
},
|
|
|
|
[]string{"status"},
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
if reg != nil {
|
|
|
|
reg.MustRegister(
|
|
|
|
m.dsRequests,
|
|
|
|
m.expressionsQuerySummary,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|