grafana/pkg/services/ngalert/metrics/remote_writer.go
William Wernert fcfa89f864
Alerting: Implement Prometheus remote write for recording rules (#89189)
* Fix timestamp recorded by rule

* Implement prometheus remote write

* Create http client instead of transport

* Address PR comments

* Remove status code label
2024-06-25 17:23:42 +03:00

31 lines
933 B
Go

package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type RemoteWriter struct {
WritesTotal *prometheus.CounterVec
WriteDuration *prometheus.HistogramVec
}
func NewRemoteWriterMetrics(r prometheus.Registerer) *RemoteWriter {
return &RemoteWriter{
WritesTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "remote_writer_writes_total",
Help: "The total number of remote writes attempted.",
}, []string{"org", "backend", "status_code"}),
WriteDuration: promauto.With(r).NewHistogramVec(
prometheus.HistogramOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "remote_writer_write_duration_seconds",
Help: "Histogram of remote write durations.",
Buckets: prometheus.DefBuckets,
}, []string{"org", "backend"}),
}
}