Skip to content

Commit 24a41e4

Browse files
authored
Cluster state info parameters (#29182)
1 parent 9d113df commit 24a41e4

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

ydb/core/grpc_services/rpc_cluster_state.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,27 +371,37 @@ class TClusterStateRPC : public TRpcRequestActor<TClusterStateRPC, TEvClusterSta
371371
}
372372
}
373373

374-
void ReplyAndPassAway() {
375-
CloseSession();
376-
TResponse response;
377-
Ydb::Operations::Operation& operation = *response.mutable_operation();
378-
operation.set_ready(true);
379-
operation.set_status(Ydb::StatusIds::SUCCESS);
374+
void AddBlock(Ydb::Monitoring::ClusterStateResult& result, const TString& name, const auto& obj) {
380375
google::protobuf::util::JsonPrintOptions jsonOpts;
381376
jsonOpts.add_whitespace = true;
382377
TString data;
383-
google::protobuf::util::MessageToJsonString(State, &data, jsonOpts);
384-
Ydb::Monitoring::ClusterStateResult result;
378+
google::protobuf::util::MessageToJsonString(obj, &data, jsonOpts);
385379
auto* block = result.Addblocks();
386-
block->Setname("cluster_state.json");
380+
block->Setname(name);
387381
block->Setcontent(data);
388382
block->Mutabletimestamp()->set_seconds(TInstant::Now().Seconds());
383+
}
389384

385+
void ReplyAndPassAway() {
386+
CloseSession();
387+
TResponse response;
388+
Ydb::Operations::Operation& operation = *response.mutable_operation();
389+
operation.set_ready(true);
390+
operation.set_status(Ydb::StatusIds::SUCCESS);
391+
392+
Ydb::Monitoring::ClusterStateResult result;
393+
AddBlock(result, "cluster_state.json", State);
394+
NKikimrClusterStateInfoProto::TClusterStateInfoParameters params;
395+
params.SetStartedAt(Started.ToStringUpToSeconds());
396+
params.SetDurationSeconds(Duration.Seconds());
397+
params.SetPeriodSeconds(Period.Seconds());
398+
AddBlock(result, "cluster_state_fetch_parameters.json", params);
390399
for (ui32 node : xrange(Counters.size())) {
391400
for (ui32 i : xrange(Counters[node].size())) {
392401
auto* counterBlock = result.Addblocks();
393402
TStringBuilder sb;
394-
sb << "node_" << node << "_counters_" << i << ".json";
403+
auto nodeId = Nodes[node].NodeId;
404+
sb << "node_" << nodeId << "_counters_" << i << ".json";
395405
counterBlock->Setname(sb);
396406
counterBlock->Setcontent(Counters[node][i].first);
397407
counterBlock->Mutabletimestamp()->set_seconds(Counters[node][i].second.Seconds());

ydb/core/protos/cluster_state_info.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ message TClusterStateQueryInfo {
2727
optional NKikimrKqp.TQueryResponse Response = 3;
2828
}
2929

30+
message TClusterStateInfoParameters {
31+
optional uint32 DurationSeconds = 1;
32+
optional uint32 PeriodSeconds = 2;
33+
optional string StartedAt = 3;
34+
}
35+
3036
message TClusterStateInfo {
3137
optional Ydb.Monitoring.SelfCheckResult SelfCheck = 1;
3238
repeated TNodeInfo NodeInfos = 2;

0 commit comments

Comments
 (0)