aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhor911 <hor911@ydb.tech>2022-08-22 00:32:10 +0300
committerhor911 <hor911@ydb.tech>2022-08-22 00:32:10 +0300
commit8b5bbce3b135c225199b7234b07c0cb47f53dfa4 (patch)
tree7efb87e1f15bac0537131a7dd3f0ef2c5f14410d
parent1352dd15c8cc4ccfe52d150839d3130c56eb8ed5 (diff)
downloadydb-8b5bbce3b135c225199b7234b07c0cb47f53dfa4.tar.gz
Fetcher mon page
-rw-r--r--ydb/core/yq/libs/actors/pending_fetcher.cpp56
-rw-r--r--ydb/core/yq/libs/actors/run_actor.cpp8
2 files changed, 61 insertions, 3 deletions
diff --git a/ydb/core/yq/libs/actors/pending_fetcher.cpp b/ydb/core/yq/libs/actors/pending_fetcher.cpp
index acdb6edbfd0..81956d68717 100644
--- a/ydb/core/yq/libs/actors/pending_fetcher.cpp
+++ b/ydb/core/yq/libs/actors/pending_fetcher.cpp
@@ -9,6 +9,9 @@
#include <library/cpp/actors/core/hfunc.h>
#include <library/cpp/actors/core/actor_bootstrapped.h>
#include <library/cpp/protobuf/interop/cast.h>
+
+#include <ydb/core/base/appdata.h>
+#include <ydb/core/mon/mon.h>
#include <ydb/core/protos/services.pb.h>
#include <ydb/library/yql/ast/yql_expr.h>
@@ -166,6 +169,14 @@ public:
}
void Bootstrap() {
+
+ NActors::TMon* mon = NKikimr::AppData()->Mon;
+ if (mon) {
+ NMonitoring::TIndexMonPage* actorsMonPage = mon->RegisterIndexPage("fq", "Federated Query");
+ mon->RegisterActorPage(actorsMonPage, "fetcher", "Pending Fetcher", false,
+ TActivationContext::ActorSystem(), SelfId());
+ }
+
Become(&TPendingFetcher::StateFunc);
DatabaseResolver = Register(CreateDatabaseResolver(MakeYqlAnalyticsHttpProxyId(), CredentialsFactory));
Send(SelfId(), new NActors::TEvents::TEvWakeup());
@@ -223,6 +234,39 @@ private:
}
}
+ void Handle(NMon::TEvHttpInfo::TPtr& ev) {
+ const auto& params = ev->Get()->Request.GetParams();
+ if (params.Has("query")) {
+ TString queryId = params.Get("query");
+
+ auto it = CountersMap.find(queryId);
+ if (it != CountersMap.end()) {
+ auto runActorId = it->second.RunActorId;
+ if (RunActorMap.find(runActorId) != RunActorMap.end()) {
+ TActivationContext::Send(ev->Forward(runActorId));
+ return;
+ }
+ }
+ }
+
+ TStringStream html;
+ html << "<table class='table simple-table1 table-hover table-condensed'>";
+ html << "<thead><tr>";
+ html << "<th>Query ID</th>";
+ html << "<th>Query Name</th>";
+ html << "</tr></thead><tbody>";
+ for (const auto& pr : RunActorMap) {
+ const auto& runActorInfo = pr.second;
+ html << "<tr>";
+ html << "<td><a href='fetcher?query=" << runActorInfo.QueryId << "'>" << runActorInfo.QueryId << "</a></td>";
+ html << "<td>" << runActorInfo.QueryName << "</td>";
+ html << "</tr>";
+ }
+ html << "</tbody></table>";
+
+ Send(ev->Sender, new NMon::TEvHttpInfoRes(html.Str()));
+ }
+
void HandlePoisonTaken(NActors::TEvents::TEvPoisonTaken::TPtr& ev) {
auto runActorId = ev->Sender;
@@ -231,7 +275,7 @@ private:
LOG_W("Unknown RunActor " << runActorId << " destroyed");
return;
}
- auto queryId = itA->second;
+ auto queryId = itA->second.QueryId;
RunActorMap.erase(itA);
auto itC = CountersMap.find(queryId);
@@ -355,7 +399,7 @@ private:
auto runActorId = Register(CreateRunActor(SelfId(), queryCounters, std::move(params)));
- RunActorMap[runActorId] = queryId;
+ RunActorMap[runActorId] = TRunActorInfo { .QueryId = queryId, .QueryName = task.query_name() };
if (!task.automatic()) {
CountersMap[queryId] = { rootCountersParent, publicCountersParent, runActorId };
}
@@ -367,6 +411,7 @@ private:
hFunc(TEvInternalService::TEvGetTaskResponse, Handle)
hFunc(NActors::TEvents::TEvPoisonTaken, HandlePoisonTaken)
hFunc(TEvPrivate::TEvCleanupCounters, HandleCleanupCounters)
+ hFunc(NMon::TEvHttpInfo, Handle);
);
NYq::TYqSharedResources::TPtr YqSharedResources;
@@ -408,8 +453,13 @@ private:
TActorId RunActorId;
};
+ struct TRunActorInfo {
+ TString QueryId;
+ TString QueryName;
+ };
+
TMap<TString, TQueryCountersInfo> CountersMap;
- TMap<TActorId, TString> RunActorMap;
+ TMap<TActorId, TRunActorInfo> RunActorMap;
TString TenantName;
TActorId InternalServiceId;
};
diff --git a/ydb/core/yq/libs/actors/run_actor.cpp b/ydb/core/yq/libs/actors/run_actor.cpp
index 734211ef68d..0c629a0e516 100644
--- a/ydb/core/yq/libs/actors/run_actor.cpp
+++ b/ydb/core/yq/libs/actors/run_actor.cpp
@@ -352,6 +352,7 @@ private:
hFunc(TEvents::TEvRaiseTransientIssues, Handle);
hFunc(NFq::TEvInternalService::TEvCreateRateLimiterResourceResponse, Handle);
hFunc(TEvDqStats, Handle);
+ hFunc(NMon::TEvHttpInfo, Handle);
)
STRICT_STFUNC(FinishStateFunc,
@@ -1733,6 +1734,13 @@ private:
Fail("TRunActor::OnUndelivered");
}
+ void Handle(NMon::TEvHttpInfo::TPtr& ev) {
+ TStringStream html;
+ html << "<h2>RunActor</h2>";
+ html << "<p>QueryId: <b>" << Params.QueryId << "</b></p>";
+ Send(ev->Sender, new NMon::TEvHttpInfoRes(html.Str()));
+ }
+
TString FindTokenByName(const TString& tokenName) const {
for (auto& graphParams : DqGraphParams) {
const auto& secureParams = graphParams.GetSecureParams();