prometheus: add node_id label to cache metrics

This commit is contained in:
ionutboangiu
2025-07-18 22:36:55 +03:00
committed by Dan Christian Bogos
parent 71a1242522
commit e8c770c415
10 changed files with 66 additions and 49 deletions

View File

@@ -396,6 +396,22 @@ func (chS *CacheS) V1GetCacheStats(ctx *context.Context, args *utils.AttrCacheID
return
}
type CacheStatsWithMetadata struct {
CacheStatistics map[string]*ltcache.CacheStats
Metadata map[string]any
}
func (chS *CacheS) V1GetStats(ctx *context.Context, args *utils.AttrCacheIDsWithAPIOpts,
rply *CacheStatsWithMetadata) error {
*rply = CacheStatsWithMetadata{
CacheStatistics: chS.tCache.GetCacheStats(args.CacheIDs),
Metadata: map[string]any{
utils.NodeID: chS.cfg.GeneralCfg().NodeID,
},
}
return nil
}
func (chS *CacheS) V1PrecacheStatus(_ *context.Context, args *utils.AttrCacheIDsWithAPIOpts, rply *map[string]string) (err error) {
if len(args.CacheIDs) == 0 {
args.CacheIDs = utils.CachePartitions.AsSlice()