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