From 60b764a63005822c1fc04f44667245812cec3601 Mon Sep 17 00:00:00 2001 From: zhengyu Date: Wed, 30 Oct 2024 12:18:35 +0800 Subject: [PATCH] [enhancement](cloud) expose file cache capacity for each disk (#42867) expose file cache capacity for better monitoring and easier to calculate file cache space usage using prometheus. Signed-off-by: freemandealer --- be/src/io/cache/block_file_cache.cpp | 3 +++ be/src/io/cache/block_file_cache.h | 1 + 2 files changed, 4 insertions(+) diff --git a/be/src/io/cache/block_file_cache.cpp b/be/src/io/cache/block_file_cache.cpp index cd502d16547f9b..814e84e8e21c70 100644 --- a/be/src/io/cache/block_file_cache.cpp +++ b/be/src/io/cache/block_file_cache.cpp @@ -54,6 +54,8 @@ BlockFileCache::BlockFileCache(const std::string& cache_base_path, _max_query_cache_size(cache_settings.max_query_cache_size) { _cur_cache_size_metrics = std::make_shared>(_cache_base_path.c_str(), "file_cache_cache_size", 0); + _cache_capacity_metrics = std::make_shared>( + _cache_base_path.c_str(), "file_cache_capacity", _capacity); _cur_ttl_cache_size_metrics = std::make_shared>( _cache_base_path.c_str(), "file_cache_ttl_cache_size", 0); _cur_normal_queue_element_count_metrics = std::make_shared>( @@ -1527,6 +1529,7 @@ std::string BlockFileCache::reset_capacity(size_t new_capacity) { } old_capacity = _capacity; _capacity = new_capacity; + _cache_capacity_metrics->set_value(_capacity); } auto use_time = duration_cast(steady_clock::time_point() - start_time); LOG(INFO) << "Finish tag deleted block. path=" << _cache_base_path diff --git a/be/src/io/cache/block_file_cache.h b/be/src/io/cache/block_file_cache.h index ac30e2411fa81b..2845994bd60d56 100644 --- a/be/src/io/cache/block_file_cache.h +++ b/be/src/io/cache/block_file_cache.h @@ -447,6 +447,7 @@ class BlockFileCache { LRUQueue _ttl_queue; // metrics + std::shared_ptr> _cache_capacity_metrics; std::shared_ptr> _cur_cache_size_metrics; std::shared_ptr> _cur_ttl_cache_size_metrics; std::shared_ptr> _cur_ttl_cache_lru_queue_cache_size_metrics;