| --- |
| id: offline-compute_PrestoSQL_prestosql_007 |
| name: APK Threat Scan Instance GPU Card-Hour 5-Minute Window Statistics |
| category: offline-compute/PrestoSQL |
| timeout_seconds: 900 |
| modality: pure-text |
| engine: prestosql |
| --- |
| ## Prompt |
| **Task Objective**: Compute the GPU card-hour consumption of APK scan instances, aggregated by 5-minute time windows, joining with Pod mapping and task instance GPU configuration information, and write the results to the output table. |
|
|
| **Input Tables**: |
| - `internal_platform_db.t_gpu_monitor_parsed_prestosql_007` (GPU monitoring data table) |
| - `container` STRING — container name |
| - `pod_name` STRING — Pod name |
| - `pkg_time` STRING — reporting time (epoch second string) |
| - `gpu_name` STRING — GPU model |
| - `metric` STRING — metric name |
| - `value` STRING — metric value |
| - `dt` STRING — partition field (format `'2026060800'`) |
|
|
| - `internal_platform_db.dwd_scan_instance_podname_prestosql_007` (Pod-to-scan-instance mapping table) |
| - `dt` STRING — partition field |
| - `instance_uuid` STRING — instance unique identifier |
| - `pod_name` STRING — Pod name |
| - `pod_phase` STRING — Pod phase |
| - `namespace` STRING — namespace |
|
|
| - `internal_platform_db.dwd_scan_task_instance_prestosql_007` (task instance GPU configuration table 1) |
| - `databus_imp_date` STRING — partition field |
| - `instance_uuid` STRING — instance unique identifier |
| - `host_gpu_num` DOUBLE — host GPU card count |
| - `host_num` DOUBLE — host count |
| - `last_modify` DOUBLE — last modification timestamp |
| - `gpu_name` STRING — GPU model |
|
|
| - `internal_platform_db.scan_task_instance_prestosql_007` (scan task instance GPU configuration table 2) |
| - `databus_imp_date` STRING — partition field |
| - `instance_uuid` STRING — instance unique identifier |
| - `host_gpu_num` DOUBLE — host GPU card count |
| - `host_num` DOUBLE — host count |
| - `last_modify` DOUBLE — last modification timestamp |
| - `gpu_name` STRING — GPU model |
| - `scan_type` STRING — scan type |
|
|
| **Computation Logic**: |
| 1. Filter specified metrics from the GPU monitoring data, and compute runtime per Pod in 5-minute time windows |
| 2. Join with the Pod-to-instance mapping to aggregate the GPU runtime and Pod count per instance per 5-minute window |
| 3. Retrieve the latest GPU configuration information for each task instance |
| 4. Compute the GPU card-hours (GPU-hour) per instance per 5-minute window |
| 5. The specific time window bucketing method, join conditions, aggregation logic, and GPU-hour computation formula must be determined based on the table structures and business semantics |
|
|
| **Output Requirements**: |
| - Target table: `internal_platform_db.t_scan_instance_gpu_time_stats_cand_prestosql_007` |
| - Output fields and order: `instance_uuid` STRING, `time_5min` BIGINT, `host_gpu_num` DOUBLE, `sum_run_time_m` DOUBLE, `gpu_hour` DOUBLE, `gpu_name` STRING, `pod_count` BIGINT, `host_num` DOUBLE |
| - If the target table does not exist, first create the table, then write the data |
| - Use Presto/Trino SQL syntax; do not use Hive/Spark SQL dialects |
|
|
| **Environment and Execution Notes**: |
| - Presto is running, connected via the Hive catalog |
| - Execute SQL: `presto-cli --catalog hive --schema internal_platform_db -f /tmp_workspace/result.sql` |
| - After writing `result.sql`, you must execute it yourself to verify that it runs successfully and produces correct data |
|
|