Skip to content

Commit

Permalink
Add native histograms to latency/duration metrics
Browse files Browse the repository at this point in the history
Dogfood native histograms.
Allow dependent projects to migrate to native histograms.

I took the defaults from client_golang.

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
  • Loading branch information
krajorama committed Mar 1, 2024
1 parent d5f0a24 commit 6c53414
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
Expand Up @@ -86,6 +86,9 @@ var (
Name: "sent_batch_duration_seconds",
Help: "Duration of sample batch send calls to the remote storage.",
Buckets: prometheus.DefBuckets,
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
},
[]string{"remote"},
)
Expand Down
3 changes: 3 additions & 0 deletions storage/remote/client.go
Expand Up @@ -69,6 +69,9 @@ var (
Name: "read_request_duration_seconds",
Help: "Histogram of the latency for remote read requests.",
Buckets: append(prometheus.DefBuckets, 25, 60),
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
},
[]string{remoteName, endpoint},
)
Expand Down
3 changes: 3 additions & 0 deletions storage/remote/queue_manager.go
Expand Up @@ -220,6 +220,9 @@ func newQueueManagerMetrics(r prometheus.Registerer, rn, e string) *queueManager
Help: "Duration of send calls to the remote storage.",
Buckets: append(prometheus.DefBuckets, 25, 60, 120, 300),
ConstLabels: constLabels,
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
})
m.highestSentTimestamp = &maxTimestamp{
Gauge: prometheus.NewGauge(prometheus.GaugeOpts{
Expand Down
3 changes: 3 additions & 0 deletions tsdb/compact.go
Expand Up @@ -115,6 +115,9 @@ func newCompactorMetrics(r prometheus.Registerer) *CompactorMetrics {
Name: "prometheus_tsdb_compaction_duration_seconds",

Check failure on line 115 in tsdb/compact.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
Help: "Duration of compaction runs",
Buckets: prometheus.ExponentialBuckets(1, 2, 14),
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
})
m.ChunkSize = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "prometheus_tsdb_compaction_chunk_size_bytes",
Expand Down
3 changes: 3 additions & 0 deletions tsdb/db.go
Expand Up @@ -321,6 +321,9 @@ func newDBMetrics(db *DB, r prometheus.Registerer) *dbMetrics {
m.tombCleanTimer = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "prometheus_tsdb_tombstone_cleanup_seconds",

Check failure on line 322 in tsdb/db.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
Help: "The time taken to recompact blocks to remove tombstones.",
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
})
m.blocksBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "prometheus_tsdb_storage_blocks_bytes",
Expand Down
3 changes: 3 additions & 0 deletions tsdb/head.go
Expand Up @@ -480,6 +480,9 @@ func newHeadMetrics(h *Head, r prometheus.Registerer) *headMetrics {
60 * 60 * 6, // 6h
60 * 60 * 12, // 12h
},
NativeHistogramBucketFactor: 1.1,

Check failure on line 483 in tsdb/head.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
}),
mmapChunksTotal: prometheus.NewCounter(prometheus.CounterOpts{
Name: "prometheus_tsdb_mmap_chunks_total",
Expand Down
3 changes: 3 additions & 0 deletions web/web.go
Expand Up @@ -126,6 +126,9 @@ func newMetrics(r prometheus.Registerer) *metrics {
Name: "prometheus_http_request_duration_seconds",

Check failure on line 126 in web/web.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
Help: "Histogram of latencies for HTTP requests.",
Buckets: []float64{.1, .2, .4, 1, 3, 8, 20, 60, 120},
NativeHistogramBucketFactor: 1.1,
NativeHistogramMaxBucketNumber: 100,
NativeHistogramMinResetDuration: 1 * time.Hour,
},
[]string{"handler"},
),
Expand Down

0 comments on commit 6c53414

Please sign in to comment.