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

     1  package retention
     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  	statusNotFound = "notfound"
    12  
    13  	tableActionModified = "modified"
    14  	tableActionDeleted  = "deleted"
    15  	tableActionNone     = "none"
    16  )
    17  
    18  type sweeperMetrics struct {
    19  	deleteChunkDurationSeconds *prometheus.HistogramVec
    20  	markerFileCurrentTime      prometheus.Gauge
    21  	markerFilesCurrent         prometheus.Gauge
    22  	markerFilesDeletedTotal    prometheus.Counter
    23  }
    24  
    25  func newSweeperMetrics(r prometheus.Registerer) *sweeperMetrics {
    26  	return &sweeperMetrics{
    27  		deleteChunkDurationSeconds: promauto.With(r).NewHistogramVec(prometheus.HistogramOpts{
    28  			Namespace: "loki_boltdb_shipper",
    29  			Name:      "retention_sweeper_chunk_deleted_duration_seconds",
    30  			Help:      "Time (in seconds) spent in deleting chunk",
    31  			Buckets:   prometheus.ExponentialBuckets(0.1, 2, 8),
    32  		}, []string{"status"}),
    33  		markerFilesCurrent: promauto.With(r).NewGauge(prometheus.GaugeOpts{
    34  			Namespace: "loki_boltdb_shipper",
    35  			Name:      "retention_sweeper_marker_files_current",
    36  			Help:      "The current total of marker files valid for deletion.",
    37  		}),
    38  		markerFileCurrentTime: promauto.With(r).NewGauge(prometheus.GaugeOpts{
    39  			Namespace: "loki_boltdb_shipper",
    40  			Name:      "retention_sweeper_marker_file_processing_current_time",
    41  			Help:      "The current time of creation of the marker file being processed.",
    42  		}),
    43  		markerFilesDeletedTotal: promauto.With(r).NewCounter(prometheus.CounterOpts{
    44  			Namespace: "loki_boltdb_shipper",
    45  			Name:      "retention_sweeper_marker_files_deleted_total",
    46  			Help:      "The total of marker files deleted after being fully processed.",
    47  		}),
    48  	}
    49  }
    50  
    51  type markerMetrics struct {
    52  	tableProcessedTotal           *prometheus.CounterVec
    53  	tableMarksCreatedTotal        *prometheus.CounterVec
    54  	tableProcessedDurationSeconds *prometheus.HistogramVec
    55  }
    56  
    57  func newMarkerMetrics(r prometheus.Registerer) *markerMetrics {
    58  	return &markerMetrics{
    59  		tableProcessedTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
    60  			Namespace: "loki_boltdb_shipper",
    61  			Name:      "retention_marker_table_processed_total",
    62  			Help:      "Total amount of table processed for each user per action. Empty string for user_id is for common index",
    63  		}, []string{"table", "user_id", "action"}),
    64  		tableMarksCreatedTotal: promauto.With(r).NewCounterVec(prometheus.CounterOpts{
    65  			Namespace: "loki_boltdb_shipper",
    66  			Name:      "retention_marker_count_total",
    67  			Help:      "Total count of markers created per table.",
    68  		}, []string{"table"}),
    69  		tableProcessedDurationSeconds: promauto.With(r).NewHistogramVec(prometheus.HistogramOpts{
    70  			Namespace: "loki_boltdb_shipper",
    71  			Name:      "retention_marker_table_processed_duration_seconds",
    72  			Help:      "Time (in seconds) spent in marking table for chunks to delete",
    73  			Buckets:   []float64{1, 2.5, 5, 10, 20, 40, 90, 360, 600, 1800},
    74  		}, []string{"table", "status"}),
    75  	}
    76  }