Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/loki/source/journal/internal/target/metrics.go
4096 views
1
package target
2
3
// This code is copied from Promtail with minor edits. The target package is used to
4
// configure and run the targets that can read journal entries and forward them
5
// to other loki components.
6
7
import "github.com/prometheus/client_golang/prometheus"
8
9
// Metrics holds a set of journal target metrics.
10
type Metrics struct {
11
reg prometheus.Registerer
12
13
journalErrors *prometheus.CounterVec
14
journalLines prometheus.Counter
15
}
16
17
// NewMetrics creates a new set of journal target metrics. If reg is non-nil, the
18
// metrics will be registered.
19
func NewMetrics(reg prometheus.Registerer) *Metrics {
20
var m Metrics
21
m.reg = reg
22
23
m.journalErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
24
Name: "loki_source_journal_target_parsing_errors_total",
25
Help: "Total number of parsing errors while reading journal messages",
26
}, []string{"error"})
27
m.journalLines = prometheus.NewCounter(prometheus.CounterOpts{
28
Name: "loki_source_journal_target_lines_total",
29
Help: "Total number of successful journal lines read",
30
})
31
32
if reg != nil {
33
reg.MustRegister(
34
m.journalErrors,
35
m.journalLines,
36
)
37
}
38
39
return &m
40
}
41
42