Path: blob/main/component/loki/source/cloudflare/internal/cloudflaretarget/metrics.go
4097 views
package cloudflaretarget12// This code is copied from Promtail. The cloudflaretarget package is used to3// configure and run a target that can read from the Cloudflare Logpull API and4// forward entries to other loki components.56import "github.com/prometheus/client_golang/prometheus"78// Metrics holds a set of cloudflare metrics.9type Metrics struct {10reg prometheus.Registerer1112Entries prometheus.Counter13LastEnd prometheus.Gauge14}1516// NewMetrics creates a new set of cloudflare metrics. If reg is non-nil, the17// metrics will be registered.18func NewMetrics(reg prometheus.Registerer) *Metrics {19var m Metrics20m.reg = reg2122m.Entries = prometheus.NewCounter(prometheus.CounterOpts{23Name: "loki_source_cloudflare_target_entries_total",24Help: "Total number of successful entries sent via the cloudflare target.",25})26m.LastEnd = prometheus.NewGauge(prometheus.GaugeOpts{27Name: "loki_source_cloudflare_target_last_requested_end_timestamp",28Help: "The last cloudflare request end timestamp fetched. This allows to calculate how far the target is behind.",29})3031if reg != nil {32reg.MustRegister(33m.Entries,34m.LastEnd,35)36}3738return &m39}404142