github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/clients/pkg/promtail/targets/gcplog/metrics.go (about)

     1  package gcplog
     2  
     3  import "github.com/prometheus/client_golang/prometheus"
     4  
     5  // Metrics stores gcplog entry metrics.
     6  type Metrics struct {
     7  	// reg is the Registerer used to create this set of metrics.
     8  	reg prometheus.Registerer
     9  
    10  	gcplogEntries                 *prometheus.CounterVec
    11  	gcplogErrors                  *prometheus.CounterVec
    12  	gcplogTargetLastSuccessScrape *prometheus.GaugeVec
    13  
    14  	gcpPushEntries *prometheus.CounterVec
    15  	gcpPushErrors  *prometheus.CounterVec
    16  }
    17  
    18  // NewMetrics creates a new set of metrics. Metrics will be registered to reg.
    19  func NewMetrics(reg prometheus.Registerer) *Metrics {
    20  	var m Metrics
    21  	m.reg = reg
    22  
    23  	// Pull subscription metrics
    24  	m.gcplogEntries = prometheus.NewCounterVec(prometheus.CounterOpts{
    25  		Namespace: "promtail",
    26  		Name:      "gcplog_target_entries_total",
    27  		Help:      "Help number of successful entries sent to the gcplog target",
    28  	}, []string{"project"})
    29  
    30  	m.gcplogErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
    31  		Namespace: "promtail",
    32  		Name:      "gcplog_target_parsing_errors_total",
    33  		Help:      "Total number of parsing errors while receiving gcplog messages",
    34  	}, []string{"project"})
    35  
    36  	m.gcplogTargetLastSuccessScrape = prometheus.NewGaugeVec(prometheus.GaugeOpts{
    37  		Namespace: "promtail",
    38  		Name:      "gcplog_target_last_success_scrape",
    39  		Help:      "Timestamp of the specific target's last successful poll",
    40  	}, []string{"project", "target"})
    41  
    42  	// Push subscription metrics
    43  	m.gcpPushEntries = prometheus.NewCounterVec(prometheus.CounterOpts{
    44  		Namespace: "promtail",
    45  		Name:      "gcp_push_target_entries_total",
    46  		Help:      "Number of successful entries received by the GCP Push target",
    47  	}, []string{})
    48  
    49  	m.gcpPushErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
    50  		Namespace: "promtail",
    51  		Name:      "gcp_push_target_parsing_errors_total",
    52  		Help:      "Number of parsing errors while receiving GCP Push messages",
    53  	}, []string{})
    54  
    55  	reg.MustRegister(
    56  		m.gcplogEntries,
    57  		m.gcplogErrors,
    58  		m.gcplogTargetLastSuccessScrape,
    59  		m.gcpPushEntries,
    60  		m.gcpPushErrors,
    61  	)
    62  	return &m
    63  }