mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 02:02:33 +08:00

* refactor grafana_index_server_index_size to calculate in a goroutine instead of at scrape time and remove grafana_index_server_indexed_docs metric * use wire to inject bleve index metrics * remove sprinkles metrics from bleve index metrics * log error when trying to calculate file index size and bump interval to 1m instead of 5s
58 lines
2.3 KiB
Go
58 lines
2.3 KiB
Go
package resource
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/dskit/instrument"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
type BleveIndexMetrics struct {
|
|
IndexLatency *prometheus.HistogramVec
|
|
IndexSize prometheus.Gauge
|
|
IndexedKinds *prometheus.GaugeVec
|
|
IndexCreationTime *prometheus.HistogramVec
|
|
IndexTenants *prometheus.CounterVec
|
|
}
|
|
|
|
var IndexCreationBuckets = []float64{1, 5, 10, 25, 50, 75, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}
|
|
|
|
func ProvideIndexMetrics(reg prometheus.Registerer) *BleveIndexMetrics {
|
|
return &BleveIndexMetrics{
|
|
IndexLatency: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: "index_server",
|
|
Name: "index_latency_seconds",
|
|
Help: "Time (in seconds) until index is updated with new event",
|
|
Buckets: instrument.DefBuckets,
|
|
NativeHistogramBucketFactor: 1.1, // enable native histograms
|
|
NativeHistogramMaxBucketNumber: 160,
|
|
NativeHistogramMinResetDuration: time.Hour,
|
|
}, []string{"resource"}),
|
|
IndexSize: promauto.With(reg).NewGauge(prometheus.GaugeOpts{
|
|
Namespace: "index_server",
|
|
Name: "index_size",
|
|
Help: "Size of the index in bytes - only for file-based indices",
|
|
}),
|
|
IndexedKinds: promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
|
|
Namespace: "index_server",
|
|
Name: "indexed_kinds",
|
|
Help: "Number of indexed documents by kind",
|
|
}, []string{"kind"}),
|
|
IndexCreationTime: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
|
|
Namespace: "index_server",
|
|
Name: "index_creation_time_seconds",
|
|
Help: "Time (in seconds) it takes until index is created",
|
|
Buckets: IndexCreationBuckets,
|
|
NativeHistogramBucketFactor: 1.1, // enable native histograms
|
|
NativeHistogramMaxBucketNumber: 160,
|
|
NativeHistogramMinResetDuration: time.Hour,
|
|
}, []string{}),
|
|
IndexTenants: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
|
|
Namespace: "index_server",
|
|
Name: "index_tenants",
|
|
Help: "Number of tenants in the index",
|
|
}, []string{"index_storage"}), // index_storage is either "file" or "memory"
|
|
}
|
|
}
|