Skip to content

[NBS] Open different YDB graphs depending on the channel kind #3540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 73 additions & 35 deletions cloud/blockstore/libs/diagnostics/hostname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,52 +115,90 @@ TString GetMonitoringNBSOverviewToTVUrl(const TDiagnosticsConfig& config)
<< data.MonitoringClusterName << "&p.host=" << GetShortHostName();
}

TString GetMonitoringYDBGroupUrl(
const TDiagnosticsConfig& config,
ui32 groupId,
const TString& storagePool,
const TString& dataKind)
TString
GetQueries(ui32 groupId, const TString& storagePool, const TString& dataKind)
{
constexpr TStringBuf GetFast =
R"(q.0.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="GetFast"})&q.0.name=A)";
constexpr TStringBuf PutUserData =
R"(q.1.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="PutUserData"})&q.1.name=B)";
constexpr TStringBuf PutTabletLog =
R"(q.2.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="PutTabletLog"})&q.2.name=C)";
constexpr TStringBuf GetAsync =
R"(q.2.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="GetAsync"})&q.2.name=C)";
constexpr TStringBuf PutAsyncBlob =
R"(q.3.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="PutAsyncBlob"})&q.3.name=D)";
constexpr TStringBuf QueryPattern =
R"(q.%u.s=histogram_percentile(100, {project="kikimr", cluster="*", storagePool="%s", group="%)" PRIu32
R"(", host="*", service="vdisks", subsystem="latency_histo", handleclass="%s"})&q.%u.name=%s)";

constexpr TStringBuf Url =
"%s/projects/%s/explorer/"
"queries?%sfrom=now-1d&to=now&refresh=60000";
constexpr std::array<TStringBuf, 2> DefaultHandleclasses(
{"GetFast", "PutUserData"});
constexpr std::array<TStringBuf, 3> LogHandleclasses(
{"GetFast", "PutUserData", "PutTabletLog"});
constexpr std::array<TStringBuf, 4> MergedAndMixedHandleclasses(
{"GetFast", "PutUserData", "GetAsync", "PutAsyncBlob"});

constexpr std::array<TStringBuf, 4> QueryNames({"A", "B", "C", "D"});

TStringBuilder queries;
queries << Sprintf(GetFast.data(), storagePool.c_str(), groupId).c_str()
<< "&"
<< Sprintf(PutUserData.data(), storagePool.c_str(), groupId).c_str()
<< "&";

if (dataKind == "Log") {
queries << Sprintf(PutTabletLog.data(), storagePool.c_str(), groupId)
.c_str()
<< "&";
for (ui32 queryIdx = 0; queryIdx < LogHandleclasses.size(); ++queryIdx)
{
queries << Sprintf(
QueryPattern.data(),
queryIdx,
storagePool.c_str(),
groupId,
LogHandleclasses.at(queryIdx).Data(),
queryIdx,
QueryNames.at(queryIdx).Data())
.c_str()
<< "&";
}

return queries.c_str();
}

if (dataKind == "Merged" || dataKind == "Mixed") {
queries
<< Sprintf(GetAsync.data(), storagePool.c_str(), groupId).c_str()
<< "&"
<< Sprintf(PutAsyncBlob.data(), storagePool.c_str(), groupId)
.c_str();
for (ui32 queryIdx = 0; queryIdx < MergedAndMixedHandleclasses.size();
++queryIdx)
{
queries << Sprintf(
QueryPattern.data(),
queryIdx,
storagePool.c_str(),
groupId,
MergedAndMixedHandleclasses.at(queryIdx).Data(),
queryIdx,
QueryNames.at(queryIdx).Data())
.c_str()
<< "&";
}

return queries.c_str();
}

for (ui32 queryIdx = 0; queryIdx < DefaultHandleclasses.size(); ++queryIdx)
{
queries << Sprintf(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может понятнее будет если строку формировать через << ? не смешивая old-school printf и потоки?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне кажется лучше как сейчас.
Если не использовать Sprintf, а выводить все через <<,
то придется шаблон QueryPattern разбивать на 5 частей, будет более громоздко.
И как будто особо понятнее не станет.

QueryPattern.data(),
queryIdx,
storagePool.c_str(),
groupId,
DefaultHandleclasses.at(queryIdx).Data(),
queryIdx,
QueryNames.at(queryIdx).Data())
.c_str()
<< "&";
}

return queries.c_str();
}

TString GetMonitoringYDBGroupUrl(
const TDiagnosticsConfig& config,
ui32 groupId,
const TString& storagePool,
const TString& dataKind)
{
constexpr TStringBuf Url =
"%s/projects/%s/explorer/"
"queries?%sfrom=now-1d&to=now&refresh=60000";

auto queries = GetQueries(groupId, storagePool, dataKind);

return Sprintf(
Url.data(),
config.GetMonitoringUrlData().MonitoringUrl.c_str(),
Expand Down
3 changes: 3 additions & 0 deletions cloud/blockstore/libs/diagnostics/hostname.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ TString GetMonitoringVolumeUrl(

TString GetMonitoringPartitionUrl(const TDiagnosticsConfig& config);

TString
GetQueries(ui32 groupId, const TString& storagePool, const TString& dataKind);

TString GetMonitoringYDBGroupUrl(
const TDiagnosticsConfig& config,
ui32 groupId,
Expand Down
Loading