Path: blob/main/component/loki/source/gelf/internal/target/metrics.go
4099 views
package target12// This code is copied from Promtail. The target package is used to3// configure and run the targets that can read gelf entries and forward them4// to other loki components.56import "github.com/prometheus/client_golang/prometheus"78// Metrics holds a set of gelf metrics.9type Metrics struct {10reg prometheus.Registerer1112gelfEntries prometheus.Counter13gelfErrors prometheus.Counter14}1516// NewMetrics creates a new set of gelf metrics. If reg is non-nil, the17// metrics will be registered.18func NewMetrics(reg prometheus.Registerer) *Metrics {19var m Metrics20m.reg = reg2122m.gelfEntries = prometheus.NewCounter(prometheus.CounterOpts{23Namespace: "agent",24Name: "loki_source_gelf_target_entries_total",25Help: "Total number of successful entries sent to the gelf target",26})27m.gelfErrors = prometheus.NewCounter(prometheus.CounterOpts{28Namespace: "agent",29Name: "loki_source_gelf_target_parsing_errors_total",30Help: "Total number of parsing errors while receiving gelf messages",31})3233if reg != nil {34reg.MustRegister(35m.gelfEntries,36m.gelfErrors,37)38}3940return &m41}424344