github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/storage/stores/indexshipper/compactor/metrics.go (about)

     1  package compactor
     2  
     3  import (
     4  	"github.com/prometheus/client_golang/prometheus"
     5  	"github.com/prometheus/client_golang/prometheus/promauto"
     6  )
     7  
     8  const (
     9  	statusFailure = "failure"
    10  	statusSuccess = "success"
    11  )
    12  
    13  type metrics struct {
    14  	compactTablesOperationTotal           *prometheus.CounterVec
    15  	compactTablesOperationDurationSeconds prometheus.Gauge
    16  	compactTablesOperationLastSuccess     prometheus.Gauge
    17  	applyRetentionLastSuccess             prometheus.Gauge
    18  	compactorRunning                      prometheus.Gauge
    19  }
    20  
    21  func newMetrics(r prometheus.Registerer) *metrics {
    22  	m := metrics{
    23  		compactTablesOperationTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
    24  			Namespace: "loki_boltdb_shipper",
    25  			Name:      "compact_tables_operation_total",
    26  			Help:      "Total number of tables compaction done by status",
    27  		}, []string{"status"}),
    28  		compactTablesOperationDurationSeconds: promauto.With(r).NewGauge(prometheus.GaugeOpts{
    29  			Namespace: "loki_boltdb_shipper",
    30  			Name:      "compact_tables_operation_duration_seconds",
    31  			Help:      "Time (in seconds) spent in compacting all the tables",
    32  		}),
    33  		compactTablesOperationLastSuccess: promauto.With(r).NewGauge(prometheus.GaugeOpts{
    34  			Namespace: "loki_boltdb_shipper",
    35  			Name:      "compact_tables_operation_last_successful_run_timestamp_seconds",
    36  			Help:      "Unix timestamp of the last successful compaction run",
    37  		}),
    38  		applyRetentionLastSuccess: promauto.With(r).NewGauge(prometheus.GaugeOpts{
    39  			Namespace: "loki_boltdb_shipper",
    40  			Name:      "apply_retention_last_successful_run_timestamp_seconds",
    41  			Help:      "Unix timestamp of the last successful retention run",
    42  		}),
    43  		compactorRunning: promauto.With(r).NewGauge(prometheus.GaugeOpts{
    44  			Namespace: "loki_boltdb_shipper",
    45  			Name:      "compactor_running",
    46  			Help:      "Value will be 1 if compactor is currently running on this instance",
    47  		}),
    48  	}
    49  
    50  	return &m
    51  }