diff --git a/pkg/infra/metrics/service.go b/pkg/infra/metrics/service.go index dd8d57aec5c..3038cf656f7 100644 --- a/pkg/infra/metrics/service.go +++ b/pkg/infra/metrics/service.go @@ -25,12 +25,13 @@ func (lw *logWrapper) Println(v ...any) { lw.logger.Info("graphite metric bridge", v...) } -func ProvideService(cfg *setting.Cfg, reg prometheus.Registerer) (*InternalMetricsService, error) { +func ProvideService(cfg *setting.Cfg, reg prometheus.Registerer, gatherer prometheus.Gatherer) (*InternalMetricsService, error) { initMetricVars(reg) initFrontendMetrics(reg) s := &InternalMetricsService{ - Cfg: cfg, + Cfg: cfg, + gatherer: gatherer, } return s, s.readSettings() } @@ -40,6 +41,7 @@ type InternalMetricsService struct { intervalSeconds int64 graphiteCfg *graphitebridge.Config + gatherer prometheus.Gatherer } func (im *InternalMetricsService) Run(ctx context.Context) error { diff --git a/pkg/infra/metrics/settings.go b/pkg/infra/metrics/settings.go index 54715db249e..587956158f2 100644 --- a/pkg/infra/metrics/settings.go +++ b/pkg/infra/metrics/settings.go @@ -5,8 +5,6 @@ import ( "strings" "time" - "github.com/prometheus/client_golang/prometheus" - "github.com/grafana/grafana/pkg/infra/metrics/graphitebridge" ) @@ -40,7 +38,7 @@ func (im *InternalMetricsService) parseGraphiteSettings() error { URL: address, Prefix: graphiteSection.Key("prefix").MustString("prod.grafana.%(instance_name)s"), CountersAsDelta: true, - Gatherer: prometheus.DefaultGatherer, + Gatherer: im.gatherer, Interval: time.Duration(im.intervalSeconds) * time.Second, Timeout: 10 * time.Second, Logger: &logWrapper{logger: metricsLogger},