Skip to content

Commit

Permalink
Metrics: use Namespace everywhere when declaring metrics (#1320)
Browse files Browse the repository at this point in the history
Code linting to make things consistent.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
  • Loading branch information
roidelapluie authored and cyriltovena committed Nov 27, 2019
1 parent 30ec4eb commit eb7b495
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 32 deletions.
53 changes: 31 additions & 22 deletions pkg/ingester/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,56 @@ import (

var (
chunkUtilization = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "loki_ingester_chunk_utilization",
Help: "Distribution of stored chunk utilization (when stored).",
Buckets: prometheus.LinearBuckets(0, 0.2, 6),
Namespace: "loki",
Name: "ingester_chunk_utilization",
Help: "Distribution of stored chunk utilization (when stored).",
Buckets: prometheus.LinearBuckets(0, 0.2, 6),
})
memoryChunks = promauto.NewGauge(prometheus.GaugeOpts{
Name: "loki_ingester_memory_chunks",
Help: "The total number of chunks in memory.",
Namespace: "loki",
Name: "ingester_memory_chunks",
Help: "The total number of chunks in memory.",
})
chunkEntries = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "loki_ingester_chunk_entries",
Help: "Distribution of stored lines per chunk (when stored).",
Buckets: prometheus.ExponentialBuckets(200, 2, 9), // biggest bucket is 200*2^(9-1) = 51200
Namespace: "loki",
Name: "ingester_chunk_entries",
Help: "Distribution of stored lines per chunk (when stored).",
Buckets: prometheus.ExponentialBuckets(200, 2, 9), // biggest bucket is 200*2^(9-1) = 51200
})
chunkSize = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "loki_ingester_chunk_size_bytes",
Help: "Distribution of stored chunk sizes (when stored).",
Buckets: prometheus.ExponentialBuckets(10000, 2, 7), // biggest bucket is 10000*2^(7-1) = 640000 (~640KB)
Namespace: "loki",
Name: "ingester_chunk_size_bytes",
Help: "Distribution of stored chunk sizes (when stored).",
Buckets: prometheus.ExponentialBuckets(10000, 2, 7), // biggest bucket is 10000*2^(7-1) = 640000 (~640KB)
})
chunkCompressionRatio = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "loki_ingester_chunk_compression_ratio",
Help: "Compression ratio of chunks (when stored).",
Buckets: prometheus.LinearBuckets(.75, 2, 10),
Namespace: "loki",
Name: "ingester_chunk_compression_ratio",
Help: "Compression ratio of chunks (when stored).",
Buckets: prometheus.LinearBuckets(.75, 2, 10),
})
chunksPerTenant = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "loki_ingester_chunks_stored_total",
Help: "Total stored chunks per tenant.",
Namespace: "loki",
Name: "ingester_chunks_stored_total",
Help: "Total stored chunks per tenant.",
}, []string{"tenant"})
chunkSizePerTenant = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "loki_ingester_chunk_stored_bytes_total",
Help: "Total bytes stored in chunks per tenant.",
Namespace: "loki",
Name: "ingester_chunk_stored_bytes_total",
Help: "Total bytes stored in chunks per tenant.",
}, []string{"tenant"})
chunkAge = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "loki_ingester_chunk_age_seconds",
Help: "Distribution of chunk ages (when stored).",
Namespace: "loki",
Name: "ingester_chunk_age_seconds",
Help: "Distribution of chunk ages (when stored).",
// with default settings chunks should flush between 5 min and 12 hours
// so buckets at 1min, 5min, 10min, 30min, 1hr, 2hr, 4hr, 10hr, 12hr, 16hr
Buckets: []float64{60, 300, 600, 1800, 3600, 7200, 14400, 36000, 43200, 57600},
})
chunkEncodeTime = promauto.NewHistogram(prometheus.HistogramOpts{
Name: "loki_ingester_chunk_encode_time_seconds",
Help: "Distribution of chunk encode times.",
Namespace: "loki",
Name: "ingester_chunk_encode_time_seconds",
Help: "Distribution of chunk encode times.",
// 10ms to 10s.
Buckets: prometheus.ExponentialBuckets(0.01, 4, 6),
})
Expand Down
5 changes: 3 additions & 2 deletions pkg/ingester/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ var (

var (
memoryStreams = promauto.NewGauge(prometheus.GaugeOpts{
Name: "loki_ingester_memory_streams",
Help: "The total number of streams in memory.",
Namespace: "loki",
Name: "ingester_memory_streams",
Help: "The total number of streams in memory.",
})
streamsCreatedTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "loki",
Expand Down
10 changes: 6 additions & 4 deletions pkg/ingester/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (

var (
sentChunks = promauto.NewCounter(prometheus.CounterOpts{
Name: "loki_ingester_sent_chunks",
Help: "The total number of chunks sent by this ingester whilst leaving.",
Namespace: "loki",
Name: "ingester_sent_chunks",
Help: "The total number of chunks sent by this ingester whilst leaving.",
})
receivedChunks = promauto.NewCounter(prometheus.CounterOpts{
Name: "loki_ingester_received_chunks",
Help: "The total number of chunks received by this ingester whilst joining.",
Namespace: "loki",
Name: "ingester_received_chunks",
Help: "The total number of chunks received by this ingester whilst joining.",
})
)

Expand Down
10 changes: 6 additions & 4 deletions pkg/util/validation/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ const (
// DiscardedBytes is a metric of the total discarded bytes, by reason.
var DiscardedBytes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "loki_discarded_bytes_total",
Help: "The total number of bytes that were discarded.",
Namespace: "loki",
Name: "discarded_bytes_total",
Help: "The total number of bytes that were discarded.",
},
[]string{discardReasonLabel, "tenant"},
)

// DiscardedSamples is a metric of the number of discarded samples, by reason.
var DiscardedSamples = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "loki_discarded_samples_total",
Help: "The total number of samples that were discarded.",
Namespace: "loki",
Name: "discarded_samples_total",
Help: "The total number of samples that were discarded.",
},
[]string{discardReasonLabel, "tenant"},
)
Expand Down

0 comments on commit eb7b495

Please sign in to comment.