mirror of
https://github.com/minio/minio.git
synced 2025-02-04 10:26:01 -05:00
Add cache usage, total capacity to prometheus metrics (#11026)
This commit is contained in:
parent
934bed47fa
commit
f3beb1236a
@ -23,6 +23,10 @@ import (
|
|||||||
// CacheDiskStats represents cache disk statistics
|
// CacheDiskStats represents cache disk statistics
|
||||||
// such as current disk usage and available.
|
// such as current disk usage and available.
|
||||||
type CacheDiskStats struct {
|
type CacheDiskStats struct {
|
||||||
|
// used cache size
|
||||||
|
UsageSize uint64
|
||||||
|
// total cache disk capacity
|
||||||
|
TotalCapacity uint64
|
||||||
// indicates if usage is high or low, if high value is '1', if low its '0'
|
// indicates if usage is high or low, if high value is '1', if low its '0'
|
||||||
UsageState int32
|
UsageState int32
|
||||||
// indicates the current usage percentage of this cache disk
|
// indicates the current usage percentage of this cache disk
|
||||||
|
@ -781,6 +781,10 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec
|
|||||||
dcache := c.cache[i]
|
dcache := c.cache[i]
|
||||||
cacheDiskStats[i] = CacheDiskStats{}
|
cacheDiskStats[i] = CacheDiskStats{}
|
||||||
if dcache != nil {
|
if dcache != nil {
|
||||||
|
info, err := getDiskInfo(dcache.dir)
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
cacheDiskStats[i].UsageSize = info.Used
|
||||||
|
cacheDiskStats[i].TotalCapacity = info.Total
|
||||||
cacheDiskStats[i].Dir = dcache.stats.Dir
|
cacheDiskStats[i].Dir = dcache.stats.Dir
|
||||||
atomic.StoreInt32(&cacheDiskStats[i].UsageState, atomic.LoadInt32(&dcache.stats.UsageState))
|
atomic.StoreInt32(&cacheDiskStats[i].UsageState, atomic.LoadInt32(&dcache.stats.UsageState))
|
||||||
atomic.StoreUint64(&cacheDiskStats[i].UsagePercent, atomic.LoadUint64(&dcache.stats.UsagePercent))
|
atomic.StoreUint64(&cacheDiskStats[i].UsagePercent, atomic.LoadUint64(&dcache.stats.UsagePercent))
|
||||||
|
@ -280,6 +280,26 @@ func cacheMetricsPrometheus(ch chan<- prometheus.Metric) {
|
|||||||
float64(cdStats.UsageState),
|
float64(cdStats.UsageState),
|
||||||
cdStats.Dir,
|
cdStats.Dir,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName("cache", "usage", "size"),
|
||||||
|
"Indicates current cache usage in bytes",
|
||||||
|
[]string{"disk"}, nil),
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(cdStats.UsageSize),
|
||||||
|
cdStats.Dir,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName("cache", "total", "size"),
|
||||||
|
"Indicates total size of cache disk",
|
||||||
|
[]string{"disk"}, nil),
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(cdStats.TotalCapacity),
|
||||||
|
cdStats.Dir,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +198,8 @@ MinIO Gateway instances enabled with Disk-Caching expose caching related metrics
|
|||||||
| `cache_data_served` | Total number of bytes served from cache |
|
| `cache_data_served` | Total number of bytes served from cache |
|
||||||
|
|
||||||
#### Per disk cache metrics
|
#### Per disk cache metrics
|
||||||
|
| `cache_usage_size` | Total cache usage in bytes |
|
||||||
|
| `cache_total_capacity` | Total size of cache disk |
|
||||||
| `cache_usage_percent` | Total percentage cache usage |
|
| `cache_usage_percent` | Total percentage cache usage |
|
||||||
| `cache_usage_state` | Indicates cache usage is high or low, relative to current cache 'quota' settings |
|
| `cache_usage_state` | Indicates cache usage is high or low, relative to current cache 'quota' settings |
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user