Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/loki/source/gelf/internal/target/metrics.go
4099 views
1
package target
2
3
// This code is copied from Promtail. The target package is used to
4
// configure and run the targets that can read gelf 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 gelf metrics.
10
type Metrics struct {
11
reg prometheus.Registerer
12
13
gelfEntries prometheus.Counter
14
gelfErrors prometheus.Counter
15
}
16
17
// NewMetrics creates a new set of gelf 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.gelfEntries = prometheus.NewCounter(prometheus.CounterOpts{
24
Namespace: "agent",
25
Name: "loki_source_gelf_target_entries_total",
26
Help: "Total number of successful entries sent to the gelf target",
27
})
28
m.gelfErrors = prometheus.NewCounter(prometheus.CounterOpts{
29
Namespace: "agent",
30
Name: "loki_source_gelf_target_parsing_errors_total",
31
Help: "Total number of parsing errors while receiving gelf messages",
32
})
33
34
if reg != nil {
35
reg.MustRegister(
36
m.gelfEntries,
37
m.gelfErrors,
38
)
39
}
40
41
return &m
42
}
43
44