@@ -358,25 +358,51 @@ class TPendingFetcher : public NActors::TActorBootstrapped<TPendingFetcher> {
358358 const TString folderId = NYdb::NFq::TScope (task.scope ()).ParseFolder ();
359359 const TString cloudId = task.sensor_labels ().at (" cloud_id" );
360360 const TString queryId = task.query_id ().value ();
361+ const bool isStreaming = task.query_type () == FederatedQuery::QueryContent::STREAMING;
362+ TString queryIdLabel;
363+ // todo: sanitize query name
364+ TString queryNameLabel = task.query_name ();
365+ if (task.automatic ()) {
366+ queryIdLabel = isStreaming ? " streaming" : " analytics" ;
367+ } else if (isStreaming) {
368+ queryIdLabel = queryId;
369+ } else {
370+ queryIdLabel = " manual" ;
371+ }
361372
362373 ::NYql::NCommon::TServiceCounters queryCounters (ServiceCounters);
363374 auto publicCountersParent = ServiceCounters.PublicCounters ;
364375
365376 if (cloudId && folderId) {
366377 publicCountersParent = publicCountersParent->GetSubgroup (" cloud_id" , cloudId)->GetSubgroup (" folder_id" , folderId);
367378 }
368- queryCounters.PublicCounters = publicCountersParent->GetSubgroup (" query_id" ,
369- task.automatic () ? (task.query_name () ? task.query_name () : " automatic" ) : queryId);
379+
380+ ::NMonitoring::TDynamicCounterPtr queryPublicCounters = publicCountersParent;
381+ // use original query id here
382+ queryPublicCounters = queryPublicCounters->GetSubgroup (" query_id" , queryId);
383+
384+ if (queryNameLabel) {
385+ queryPublicCounters = queryPublicCounters->GetSubgroup (" query_name" , queryNameLabel);
386+ }
387+ queryCounters.PublicCounters = queryPublicCounters;
370388
371389 auto rootCountersParent = ServiceCounters.RootCounters ;
372390 std::set<std::pair<TString, TString>> sensorLabels (task.sensor_labels ().begin (), task.sensor_labels ().end ());
373391 for (const auto & [label, item]: sensorLabels) {
374392 rootCountersParent = rootCountersParent->GetSubgroup (label, item);
375393 }
376394
377- queryCounters.RootCounters = rootCountersParent->GetSubgroup (" query_id" ,
378- task.automatic () ? (folderId ? " automatic_" + folderId : " automatic" ) : queryId);
379- queryCounters.Counters = queryCounters.RootCounters ;
395+ ::NMonitoring::TDynamicCounterPtr queryRootCounters = rootCountersParent;
396+ if (queryIdLabel) {
397+ queryRootCounters = queryRootCounters->GetSubgroup (" query_id" , queryIdLabel);
398+ }
399+
400+ if (!task.automatic () && isStreaming && queryNameLabel) {
401+ queryRootCounters = queryRootCounters->GetSubgroup (" query_name" , queryNameLabel);
402+ }
403+
404+ queryCounters.RootCounters = queryRootCounters;
405+ queryCounters.Counters = queryRootCounters;
380406
381407 queryCounters.InitUptimeCounter ();
382408 const auto createdAt = TInstant::Now ();
0 commit comments