add metrics MergeTreeMetadataCacheSize

This commit is contained in:
taiyang-li 2022-01-10 12:20:39 +08:00
parent 5bff268f84
commit 3d409a4526
3 changed files with 19 additions and 0 deletions

View File

@ -12,6 +12,7 @@
#include <Storages/MarkCache.h> #include <Storages/MarkCache.h>
#include <Storages/StorageMergeTree.h> #include <Storages/StorageMergeTree.h>
#include <Storages/StorageReplicatedMergeTree.h> #include <Storages/StorageReplicatedMergeTree.h>
#include <Storages/MergeTree/MergeTreeMetadataCache.h>
#include <IO/UncompressedCache.h> #include <IO/UncompressedCache.h>
#include <IO/MMappedFileCache.h> #include <IO/MMappedFileCache.h>
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
@ -573,6 +574,15 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
} }
} }
#if USE_ROCKSDB
{
if (auto metadata_cache = getContext()->getMergeTreeMetadataCache())
{
new_values["MergeTreeMetadataCacheSize"] = metadata_cache->getEstimateNumKeys();
}
}
#endif
#if USE_EMBEDDED_COMPILER #if USE_EMBEDDED_COMPILER
{ {
if (auto * compiled_expression_cache = CompiledExpressionCacheFactory::instance().tryGetCache()) if (auto * compiled_expression_cache = CompiledExpressionCacheFactory::instance().tryGetCache())
@ -583,6 +593,7 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
} }
#endif #endif
new_values["Uptime"] = getContext()->getUptimeSeconds(); new_values["Uptime"] = getContext()->getUptimeSeconds();
/// Process process memory usage according to OS /// Process process memory usage according to OS

View File

@ -61,6 +61,13 @@ void MergeTreeMetadataCache::getByPrefix(const String & prefix, Strings & keys,
ProfileEvents::increment(ProfileEvents::MergeTreeMetadataCacheSeek); ProfileEvents::increment(ProfileEvents::MergeTreeMetadataCacheSeek);
} }
uint64_t MergeTreeMetadataCache::getEstimateNumKeys() const
{
uint64_t keys = 0;
rocksdb->GetAggregatedIntProperty("rocksdb.estimate-num-keys", &keys);
return keys;
}
void MergeTreeMetadataCache::shutdown() void MergeTreeMetadataCache::shutdown()
{ {
rocksdb->Close(); rocksdb->Close();

View File

@ -28,6 +28,7 @@ public:
Status del(const String & key); Status del(const String & key);
Status get(const String & key, String & value); Status get(const String & key, String & value);
void getByPrefix(const String & prefix, Strings & keys, Strings & values); void getByPrefix(const String & prefix, Strings & keys, Strings & values);
uint64_t getEstimateNumKeys() const;
void shutdown(); void shutdown();
private: private: