3636 MetricNodesCoresSummary ,
3737 MetricSummary ,
3838 ProfilingHostStatus ,
39+ ProfilingHostStatusRequest ,
3940 ProfilingRequest ,
4041 ProfilingResponse ,
4142 SampleCount ,
4243)
4344from backend .utils .filters_utils import get_rql_first_eq_key , get_rql_only_for_one_key
4445from backend .utils .request_utils import flamegraph_base_request_params , get_metrics_response , get_query_response
4546from botocore .exceptions import ClientError
46- from fastapi import APIRouter , Depends , HTTPException , Query , Request
47+ from fastapi import APIRouter , Depends , HTTPException , Query
4748from fastapi .responses import Response
4849from gprofiler_dev import S3ProfileDal
4950from gprofiler_dev .postgres .db_manager import DBManager
@@ -80,6 +81,13 @@ def get_time_interval_value(start_time: datetime, end_time: datetime, interval:
8081 return "24 hours"
8182
8283
84+ def profiling_host_status_params (
85+ service_name : Optional [str ] = Query (None , description = "Filter by service name" ),
86+ exact_match : bool = Query (False , description = "Use exact match for service name (default: false for partial matching)" ),
87+ ) -> ProfilingHostStatusRequest :
88+ return ProfilingHostStatusRequest (service_name = service_name , exact_match = exact_match )
89+
90+
8391@router .get ("/instance_type_count" , response_model = List [InstanceTypeCount ])
8492def get_instance_type_count (fg_params : FGParamsBaseModel = Depends (flamegraph_base_request_params )):
8593 response = get_query_response (fg_params , lookup_for = "instance_type_count" )
@@ -636,25 +644,22 @@ def report_command_completion(completion: CommandCompletionRequest):
636644
637645@router .get ("/profiling/host_status" , response_model = List [ProfilingHostStatus ])
638646def get_profiling_host_status (
639- service_name : Optional [str ] = Query (None , description = "Filter by service name" ),
640- exact_match : bool = Query (False , description = "Use exact match for service name (default: false for partial matching)" ),
641- request : Request = None
647+ profiling_params : ProfilingHostStatusRequest = Depends (profiling_host_status_params ),
642648):
643649 """
644650 Get profiling host status with optional service name filtering.
645651
646652 Args:
647- service_name: Optional service name to filter results (supports partial matching by default)
648- exact_match: If true, use exact matching; if false, use partial case-insensitive matching
653+ profiling_params: ProfilingHostStatusRequest object containing service name and exact match flag
649654
650655 Returns:
651- List of host statuses with dynamic profiling links
656+ List of host statuses
652657 """
653658 db_manager = DBManager ()
654659
655660 # Get hosts - filter by service_name if provided
656- if service_name :
657- hosts = db_manager .get_host_heartbeats_by_service (service_name , exact_match = exact_match )
661+ if profiling_params . service_name :
662+ hosts = db_manager .get_host_heartbeats_by_service (profiling_params . service_name , exact_match = profiling_params . exact_match )
658663 else :
659664 hosts = db_manager .get_all_host_heartbeats ()
660665
@@ -674,10 +679,6 @@ def get_profiling_host_status(
674679 profiling_status = "stopped"
675680 command_type = "N/A"
676681
677- # Generate dynamic profiling link with service filter
678- base_url = str (request .base_url ).rstrip ('/' ) if request else ""
679- profiling_link = f"{ base_url } /profiling?service={ host_service_name } &hostname={ hostname } "
680-
681682 results .append (
682683 ProfilingHostStatus (
683684 id = host .get ("id" , 0 ),
@@ -688,7 +689,6 @@ def get_profiling_host_status(
688689 command_type = command_type ,
689690 profiling_status = profiling_status ,
690691 heartbeat_timestamp = host .get ("heartbeat_timestamp" ),
691- profiling_link = profiling_link , # New field for contextual link
692692 )
693693 )
694694
0 commit comments