Skip to content

Commit 4fca557

Browse files
committed
HDD and SSD storage counters
1 parent 1309585 commit 4fca557

File tree

7 files changed

+86
-8
lines changed

7 files changed

+86
-8
lines changed

ydb/core/protos/counters_schemeshard.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ enum ESimpleCounters {
205205
COUNTER_IN_FLIGHT_OPS_TxCreateContinuousBackup = 162 [(CounterOpts) = {Name: "InFlightOps/CreateContinuousBackup"}];
206206
COUNTER_IN_FLIGHT_OPS_TxAlterContinuousBackup = 163 [(CounterOpts) = {Name: "InFlightOps/AlterContinuousBackup"}];
207207
COUNTER_IN_FLIGHT_OPS_TxDropContinuousBackup = 164 [(CounterOpts) = {Name: "InFlightOps/DropContinuousBackup"}];
208+
209+
COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_SSD = 165 [(CounterOpts) = {Name: "DiskSpaceTablesDataBytesOnSsd"}];
210+
COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_SSD = 166 [(CounterOpts) = {Name: "DiskSpaceTablesIndexBytesOnSsd"}];
211+
COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_SSD = 167 [(CounterOpts) = {Name: "DiskSpaceTablesTotalBytesOnSsd"}];
212+
COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_HDD = 168 [(CounterOpts) = {Name: "DiskSpaceTablesDataBytesOnHdd"}];
213+
COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_HDD = 169 [(CounterOpts) = {Name: "DiskSpaceTablesIndexBytesOnHdd"}];
214+
COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_HDD = 170 [(CounterOpts) = {Name: "DiskSpaceTablesTotalBytesOnHdd"}];
208215
}
209216

210217
enum ECumulativeCounters {

ydb/core/sys_view/service/ext_counters.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class TExtCountersUpdaterActor
2323
TCounterPtr MemoryUsedBytes;
2424
TCounterPtr MemoryLimitBytes;
2525
TCounterPtr StorageUsedBytes;
26+
TCounterPtr StorageUsedBytesOnSsd;
27+
TCounterPtr StorageUsedBytesOnHdd;
2628
TVector<TCounterPtr> CpuUsedCorePercents;
2729
TVector<TCounterPtr> CpuLimitCorePercents;
2830
THistogramPtr ExecuteLatencyMs;
@@ -54,6 +56,10 @@ class TExtCountersUpdaterActor
5456
"resources.memory.limit_bytes", false);
5557
StorageUsedBytes = ydbGroup->GetNamedCounter("name",
5658
"resources.storage.used_bytes", false);
59+
StorageUsedBytesOnSsd = ydbGroup->GetNamedCounter("name",
60+
"resources.storage.used_bytes.ssd", false);
61+
StorageUsedBytesOnHdd = ydbGroup->GetNamedCounter("name",
62+
"resources.storage.used_bytes.hdd", false);
5763

5864
auto poolCount = Config.Pools.size();
5965
CpuUsedCorePercents.resize(poolCount);
@@ -110,6 +116,12 @@ class TExtCountersUpdaterActor
110116
if (StorageUsedBytes->Val() != 0) {
111117
metrics->AddMetric("resources.storage.used_bytes", StorageUsedBytes->Val());
112118
}
119+
if (StorageUsedBytesOnSsd->Val() != 0) {
120+
metrics->AddMetric("resources.storage.used_bytes.ssd", StorageUsedBytesOnSsd->Val());
121+
}
122+
if (StorageUsedBytesOnHdd->Val() != 0) {
123+
metrics->AddMetric("resources.storage.used_bytes.hdd", StorageUsedBytesOnHdd->Val());
124+
}
113125
if (!Config.Pools.empty()) {
114126
double cpuUsage = 0;
115127
for (size_t i = 0; i < Config.Pools.size(); ++i) {

ydb/core/tablet/tablet_counters_aggregator.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,12 @@ class TTabletMon {
770770
TCounterPtr ColumnShardBulkUpsertRows_;
771771
TCounterPtr ColumnShardBulkUpsertBytes_;
772772
TCounterPtr ResourcesStorageUsedBytes;
773+
TCounterPtr ResourcesStorageUsedBytesOnSsd;
774+
TCounterPtr ResourcesStorageUsedBytesOnHdd;
773775
TCounterPtr ResourcesStorageLimitBytes;
774776
TCounterPtr ResourcesStorageTableUsedBytes;
777+
TCounterPtr ResourcesStorageTableUsedBytesOnSsd;
778+
TCounterPtr ResourcesStorageTableUsedBytesOnHdd;
775779
TCounterPtr ResourcesStorageTopicUsedBytes;
776780
TCounterPtr ResourcesStreamUsedShards;
777781
TCounterPtr ResourcesStreamLimitShards;
@@ -806,6 +810,8 @@ class TTabletMon {
806810
TCounterPtr ColumnShardUpsertBytesWritten_;
807811

808812
TCounterPtr DiskSpaceTablesTotalBytes;
813+
TCounterPtr DiskSpaceTablesTotalBytesOnSsd;
814+
TCounterPtr DiskSpaceTablesTotalBytesOnHdd;
809815
TCounterPtr DiskSpaceTopicsTotalBytes;
810816
TCounterPtr DiskSpaceSoftQuotaBytes;
811817

@@ -860,10 +866,18 @@ class TTabletMon {
860866

861867
ResourcesStorageUsedBytes = ydbGroup->GetNamedCounter("name",
862868
"resources.storage.used_bytes", false);
869+
ResourcesStorageUsedBytesOnSsd = ydbGroup->GetNamedCounter("name",
870+
"resources.storage.used_bytes.ssd", false);
871+
ResourcesStorageUsedBytesOnHdd = ydbGroup->GetNamedCounter("name",
872+
"resources.storage.used_bytes.hdd", false);
863873
ResourcesStorageLimitBytes = ydbGroup->GetNamedCounter("name",
864874
"resources.storage.limit_bytes", false);
865875
ResourcesStorageTableUsedBytes = ydbGroup->GetNamedCounter("name",
866876
"resources.storage.table.used_bytes", false);
877+
ResourcesStorageTableUsedBytesOnSsd = ydbGroup->GetNamedCounter("name",
878+
"resources.storage.table.used_bytes.ssd", false);
879+
ResourcesStorageTableUsedBytesOnHdd = ydbGroup->GetNamedCounter("name",
880+
"resources.storage.table.used_bytes.hdd", false);
867881
ResourcesStorageTopicUsedBytes = ydbGroup->GetNamedCounter("name",
868882
"resources.storage.topic.used_bytes", false);
869883

@@ -930,6 +944,8 @@ class TTabletMon {
930944
auto appGroup = schemeshardGroup->GetSubgroup("category", "app");
931945

932946
DiskSpaceTablesTotalBytes = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTablesTotalBytes)");
947+
DiskSpaceTablesTotalBytesOnSsd = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTablesTotalBytesOnSsd)");
948+
DiskSpaceTablesTotalBytesOnHdd = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTablesTotalBytesOnHdd)");
933949
DiskSpaceTopicsTotalBytes = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceTopicsTotalBytes)");
934950
DiskSpaceSoftQuotaBytes = appGroup->GetCounter("SUM(SchemeShard/DiskSpaceSoftQuotaBytes)");
935951

@@ -973,12 +989,18 @@ class TTabletMon {
973989
if (DiskSpaceTablesTotalBytes) {
974990
ResourcesStorageLimitBytes->Set(DiskSpaceSoftQuotaBytes->Val());
975991
ResourcesStorageTableUsedBytes->Set(DiskSpaceTablesTotalBytes->Val());
992+
ResourcesStorageTableUsedBytesOnSsd->Set(DiskSpaceTablesTotalBytesOnSsd->Val());
993+
ResourcesStorageTableUsedBytesOnHdd->Set(DiskSpaceTablesTotalBytesOnHdd->Val());
976994
ResourcesStorageTopicUsedBytes->Set(DiskSpaceTopicsTotalBytes->Val());
977995

978996
if (AppData()->FeatureFlags.GetEnableTopicDiskSubDomainQuota()) {
979997
ResourcesStorageUsedBytes->Set(ResourcesStorageTableUsedBytes->Val() + ResourcesStorageTopicUsedBytes->Val());
998+
ResourcesStorageUsedBytesOnSsd->Set(ResourcesStorageTableUsedBytesOnSsd->Val());
999+
ResourcesStorageUsedBytesOnHdd->Set(ResourcesStorageTableUsedBytesOnHdd->Val());
9801000
} else {
9811001
ResourcesStorageUsedBytes->Set(ResourcesStorageTableUsedBytes->Val());
1002+
ResourcesStorageUsedBytesOnSsd->Set(ResourcesStorageTableUsedBytesOnSsd->Val());
1003+
ResourcesStorageUsedBytesOnHdd->Set(ResourcesStorageTableUsedBytesOnHdd->Val());
9821004
}
9831005

9841006
auto quota = StreamShardsQuota->Val();

ydb/core/tx/schemeshard/schemeshard_impl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7146,6 +7146,18 @@ void TSchemeShard::ChangeDiskSpaceTablesTotalBytes(i64 delta) {
71467146
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES].Add(delta);
71477147
}
71487148

7149+
void TSchemeShard::ChangeDiskSpaceTables(EUserFacingStorageType storageType, i64 dataDelta, i64 indexDelta) {
7150+
if (storageType == EUserFacingStorageType::Ssd) {
7151+
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_SSD].Add(dataDelta);
7152+
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_SSD].Add(indexDelta);
7153+
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_SSD].Add(dataDelta + indexDelta);
7154+
} else if (storageType == EUserFacingStorageType::Hdd) {
7155+
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_DATA_BYTES_ON_HDD].Add(dataDelta);
7156+
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_INDEX_BYTES_ON_HDD].Add(indexDelta);
7157+
TabletCounters->Simple()[COUNTER_DISK_SPACE_TABLES_TOTAL_BYTES_ON_HDD].Add(dataDelta + indexDelta);
7158+
}
7159+
}
7160+
71497161
void TSchemeShard::ChangeDiskSpaceTopicsTotalBytes(ui64 value) {
71507162
TabletCounters->Simple()[COUNTER_DISK_SPACE_TOPICS_TOTAL_BYTES].Set(value);
71517163
}

ydb/core/tx/schemeshard/schemeshard_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,7 @@ class TSchemeShard
13781378
void ChangeDiskSpaceTablesDataBytes(i64 delta) override;
13791379
void ChangeDiskSpaceTablesIndexBytes(i64 delta) override;
13801380
void ChangeDiskSpaceTablesTotalBytes(i64 delta) override;
1381+
void ChangeDiskSpaceTables(EUserFacingStorageType storageType, i64 dataDelta, i64 indexDelta) override;
13811382
void ChangeDiskSpaceTopicsTotalBytes(ui64 value) override;
13821383
void ChangeDiskSpaceQuotaExceeded(i64 delta) override;
13831384
void ChangeDiskSpaceHardQuotaBytes(i64 delta) override;

ydb/core/tx/schemeshard/schemeshard_info_types.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
namespace {
2222

23-
using TDiskSpaceQuotas = NKikimr::NSchemeShard::TSubDomainInfo::TDiskSpaceQuotas;
23+
using namespace NKikimr::NSchemeShard;
24+
using TDiskSpaceQuotas = TSubDomainInfo::TDiskSpaceQuotas;
2425
using TQuotasPair = TDiskSpaceQuotas::TQuotasPair;
25-
using TStoragePoolUsage = NKikimr::NSchemeShard::TSubDomainInfo::TDiskSpaceUsage::TStoragePoolUsage;
26+
using TStoragePoolUsage = TSubDomainInfo::TDiskSpaceUsage::TStoragePoolUsage;
2627

2728
enum class EDiskUsageStatus {
2829
AboveHardQuota,
@@ -50,6 +51,16 @@ EDiskUsageStatus CheckStoragePoolsQuotas(const THashMap<TString, TStoragePoolUsa
5051
: EDiskUsageStatus::BelowSoftQuota;
5152
}
5253

54+
EUserFacingStorageType GetUserFacingStorageType(const TString& poolKind) {
55+
if (poolKind.StartsWith("ssd")) {
56+
return EUserFacingStorageType::Ssd;
57+
}
58+
if (poolKind.StartsWith("hdd")) {
59+
return EUserFacingStorageType::Hdd;
60+
}
61+
return EUserFacingStorageType::Ignored;
62+
}
63+
5364
}
5465

5566
namespace NKikimr {
@@ -171,15 +182,21 @@ void TSubDomainInfo::AggrDiskSpaceUsage(IQuotaCounters* counters, const TPartiti
171182

172183
for (const auto& [poolKind, newStoragePoolStats] : newAggr.StoragePoolsStats) {
173184
const auto* oldStats = oldAggr.StoragePoolsStats.FindPtr(poolKind);
174-
auto& storagePoolUsage = DiskSpaceUsage.StoragePoolsUsage[poolKind];
175-
storagePoolUsage.DataSize += newStoragePoolStats.DataSize - (oldStats ? oldStats->DataSize : 0u);
176-
storagePoolUsage.IndexSize += newStoragePoolStats.IndexSize - (oldStats ? oldStats->IndexSize : 0u);
185+
const i64 dataSizeIncrement = newStoragePoolStats.DataSize - (oldStats ? oldStats->DataSize : 0u);
186+
const i64 indexSizeIncrement = newStoragePoolStats.IndexSize - (oldStats ? oldStats->IndexSize : 0u);
187+
auto& [dataSize, indexSize] = DiskSpaceUsage.StoragePoolsUsage[poolKind];
188+
dataSize += dataSizeIncrement;
189+
indexSize += indexSizeIncrement;
190+
counters->ChangeDiskSpaceTables(GetUserFacingStorageType(poolKind), dataSizeIncrement, indexSizeIncrement);
177191
}
178192
for (const auto& [poolKind, oldStoragePoolStats] : oldAggr.StoragePoolsStats) {
179193
if (const auto* newStats = newAggr.StoragePoolsStats.FindPtr(poolKind); !newStats) {
180-
auto& storagePoolUsage = DiskSpaceUsage.StoragePoolsUsage[poolKind];
181-
storagePoolUsage.DataSize -= oldStoragePoolStats.DataSize;
182-
storagePoolUsage.IndexSize -= oldStoragePoolStats.IndexSize;
194+
const i64 dataSizeDecrement = oldStoragePoolStats.DataSize;
195+
const i64 indexSizeDecrement = oldStoragePoolStats.IndexSize;
196+
auto& [dataSize, indexSize] = DiskSpaceUsage.StoragePoolsUsage[poolKind];
197+
dataSize -= dataSizeDecrement;
198+
indexSize -= indexSizeDecrement;
199+
counters->ChangeDiskSpaceTables(GetUserFacingStorageType(poolKind), -dataSizeDecrement, -indexSizeDecrement);
183200
}
184201
}
185202
}

ydb/core/tx/schemeshard/schemeshard_info_types.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,12 @@ struct TSchemeQuotas : public TVector<TSchemeQuota> {
12811281
mutable size_t LastKnownSize = 0;
12821282
};
12831283

1284+
enum class EUserFacingStorageType {
1285+
Ssd,
1286+
Hdd,
1287+
Ignored
1288+
};
1289+
12841290
struct IQuotaCounters {
12851291
virtual void ChangeStreamShardsCount(i64 delta) = 0;
12861292
virtual void ChangeStreamShardsQuota(i64 delta) = 0;
@@ -1289,6 +1295,7 @@ struct IQuotaCounters {
12891295
virtual void ChangeDiskSpaceTablesDataBytes(i64 delta) = 0;
12901296
virtual void ChangeDiskSpaceTablesIndexBytes(i64 delta) = 0;
12911297
virtual void ChangeDiskSpaceTablesTotalBytes(i64 delta) = 0;
1298+
virtual void ChangeDiskSpaceTables(EUserFacingStorageType storageType, i64 dataDelta, i64 indexDelta) = 0;
12921299
virtual void ChangeDiskSpaceTopicsTotalBytes(ui64 value) = 0;
12931300
virtual void ChangeDiskSpaceQuotaExceeded(i64 delta) = 0;
12941301
virtual void ChangeDiskSpaceHardQuotaBytes(i64 delta) = 0;

0 commit comments

Comments
 (0)