@@ -35,6 +35,15 @@ namespace NYdb::NConsoleClient {
35
35
std::pair<TString, NYdb::NTopic::ECodec>(" zstd" , NYdb::NTopic::ECodec::ZSTD),
36
36
};
37
37
38
+ TVector<ui32> ExistingMetricsLevels = {2 , 3 };
39
+
40
+ THashMap<ui32, TString> MetricsLevelsDescriptions = {
41
+ {0 , " No metrics." },
42
+ {1 , " Database level metrics." },
43
+ {2 , " Database and topic level metrics." },
44
+ {3 , " Database, topic, and partition level metrics." },
45
+ };
46
+
38
47
THashMap<TString, NTopic::EMeteringMode> ExistingMeteringModes = {
39
48
std::pair<TString, NTopic::EMeteringMode>(" request-units" , NTopic::EMeteringMode::RequestUnits),
40
49
std::pair<TString, NTopic::EMeteringMode>(" reserved-capacity" , NTopic::EMeteringMode::ReservedCapacity),
@@ -159,6 +168,29 @@ namespace NYdb::NConsoleClient {
159
168
AllowedCodecs_ = supportedCodecs;
160
169
}
161
170
171
+ void TCommandWithMetricsLevel::AddMetricsLevels (TClientCommand::TConfig& config) {
172
+ TStringStream description;
173
+ description << " Available metrics levels: " ;
174
+ NColorizer::TColors colors = NColorizer::AutoColors (Cout);
175
+ for (const auto & level: ExistingMetricsLevels) {
176
+ auto findResult = MetricsLevelsDescriptions.find (level);
177
+ Y_ABORT_UNLESS (findResult != MetricsLevelsDescriptions.end (),
178
+ " Couldn't find description for %s metrics level" , (TStringBuilder () << level).c_str ());
179
+ description << " \n " << colors.BoldColor () << level << colors.OldColor ()
180
+ << " \n " << findResult->second ;
181
+ if (level == 2 /* database and topic level metrics */ ) {
182
+ description << colors.CyanColor () << " (default)" << colors.OldColor ();
183
+ }
184
+ }
185
+ config.Opts ->AddLongOption (" metrics-level" , description.Str ())
186
+ .Optional ()
187
+ .StoreResult (&MetricsLevel_);
188
+ }
189
+
190
+ TMaybe<NTopic::EMetricsLevel> TCommandWithMetricsLevel::GetMetricsLevel () const {
191
+ return MetricsLevel_;
192
+ }
193
+
162
194
void TCommandWithSupportedCodecs::ParseCodecs () {
163
195
TVector<NTopic::ECodec> parsedCodecs;
164
196
TVector<TString> split = SplitString (SupportedCodecsStr_, " ," );
@@ -323,6 +355,7 @@ namespace NYdb::NConsoleClient {
323
355
SetFreeArgTitle (0 , " <topic-path>" , " Topic path" );
324
356
AddAllowedCodecs (config, AllowedCodecs);
325
357
AddAllowedMeteringModes (config);
358
+ AddMetricsLevels (config);
326
359
327
360
config.Opts ->AddLongOption (" auto-partitioning-max-partitions-count" , " Maximum number of partitions for topic" )
328
361
.Optional ()
@@ -379,6 +412,10 @@ namespace NYdb::NConsoleClient {
379
412
settings.AddAttribute (" _partitions_per_tablet" , ToString (*PartitionsPerTablet_));
380
413
}
381
414
415
+ if (auto level = GetMetricsLevel (); level.Defined ()) {
416
+ settings.MetricsLevel (*level);
417
+ }
418
+
382
419
auto status = topicClient.CreateTopic (TopicName, settings).GetValueSync ();
383
420
NStatusHelpers::ThrowOnErrorOrPrintIssues (status);
384
421
return EXIT_SUCCESS;
@@ -406,6 +443,7 @@ namespace NYdb::NConsoleClient {
406
443
SetFreeArgTitle (0 , " <topic-path>" , " Topic path" );
407
444
AddAllowedCodecs (config, AllowedCodecs);
408
445
AddAllowedMeteringModes (config);
446
+ AddMetricsLevels (config);
409
447
410
448
config.Opts ->AddLongOption (" auto-partitioning-max-partitions-count" , " Maximum number of partitions for topic" )
411
449
.Optional ()
@@ -476,6 +514,10 @@ namespace NYdb::NConsoleClient {
476
514
settings.SetRetentionStorageMb (*RetentionStorageMb_);
477
515
}
478
516
517
+ if (MetricsLevel_.Defined ()) {
518
+ settings.SetMetricsLevel (*MetricsLevel_);
519
+ }
520
+
479
521
return settings;
480
522
}
481
523
0 commit comments