forked from grafana/loki
/
metrics.go
38 lines (31 loc) · 996 Bytes
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cloudflare
import "github.com/prometheus/client_golang/prometheus"
// Metrics holds a set of cloudflare metrics.
type Metrics struct {
reg prometheus.Registerer
Entries prometheus.Counter
LastEnd prometheus.Gauge
}
// NewMetrics creates a new set of cloudflare metrics. If reg is non-nil, the
// metrics will be registered.
func NewMetrics(reg prometheus.Registerer) *Metrics {
var m Metrics
m.reg = reg
m.Entries = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "promtail",
Name: "cloudflare_target_entries_total",
Help: "Total number of successful entries sent via the cloudflare target",
})
m.LastEnd = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "promtail",
Name: "cloudflare_target_last_requested_end_timestamp",
Help: "The last cloudflare request end timestamp fetched. This allows to calculate how far the target is behind.",
})
if reg != nil {
reg.MustRegister(
m.Entries,
m.LastEnd,
)
}
return &m
}