This topic describes how to monitor Hologres Serverless Computing to ensure your service remains stable and efficient.
View monitoring metrics
Log in to the Hologres console to view metrics related to Serverless Computing for your instance. For more information, see CloudMonitor.
View task status
View SQL tasks running on serverless resources.
SELECT *, (running_info::json) ->> 'computing_resource' AS computing_resource, (running_info::json) ->> 'current_stage' AS current_stage FROM hg_stat_activity WHERE (running_info::json) ->> 'computing_resource' = 'Serverless' AND (running_info::json) -> 'current_stage'->>'stage_name' = 'EXECUTE'View SQL tasks queueing for serverless resources.
SELECT *, (running_info::json) ->> 'computing_resource' AS computing_resource, (running_info::json) ->> 'current_stage' AS current_stage FROM hg_stat_activity WHERE (running_info::json) ->> 'computing_resource' = 'Serverless' AND (running_info::json) -> 'current_stage'->>'stage_name' = 'QUEUE'View the status of a specific SQL task running on serverless resources.
SELECT *, (running_info::json) ->> 'computing_resource' AS computing_resource, (running_info::json) ->> 'current_stage' AS current_stage FROM hg_stat_activity WHERE query_id = '<query_id>';
Query historical tasks
Data in the hologres.hg_query_log and hologres.hg_serverless_computing_query_log views is retained for one month.
Starting from Hologres V2.1.18, you can use the hologres.hg_serverless_computing_query_log view to query historical tasks that ran on serverless resources.
Compared to slow query logs, this view adds the following fields:
queue_time_ms: The duration (in milliseconds) that the SQL query spends in the queue waiting for serverless resources.serverless_allocated_cores: The number of CUs allocated to the query.serverless_allocated_workers: The number of workers allocated to the query.serverless_resource_used_time_ms: The duration (in milliseconds) that the query used serverless resources.
The
extended_infofield provides additional information:serverless_computing_source: Indicates the origin of the query when running on serverless resources. Valid values:user_submit: Query explicitly submitted by the user for serverless execution.query_queue: Query originated from a query queue configured for serverless execution. See Use Serverless Computing resources to execute queries in a query queue.big_query_isolation_service: Query utilized serverless resources via Adaptive Serverless Computing. See Adaptive Serverless Computing.query_queue_rerun: A large query automatically re-executed on serverless resources. See Large query management.
query_id_of_triggered_rerun: Present only whenserverless_computing_sourceisquery_queue_rerun. It shows the original ID of the re-executed query.
Before Hologres V2.2.7, the hologres.hg_serverless_computing_query_log view showed only successful queries with an execution duration greater than 100 ms and all failed queries. Starting from Hologres V2.2.7, the view shows all queries running on Serverless Computing.
SELECT
*
FROM
hologres.hg_serverless_computing_query_log;Certain tasks, such as COPY, CTAS, and INSERT OVERWRITE, generate multiple records in slow query logs. These records include the original SQL task and the subsequent INSERT statements created during its execution. These INSERT statements are the ones that actually consume serverless resources. Link the INSERT records to the original task using the trans_id from the original task's record. The following example shows how to establish this link.
SELECT
query_id,
query,
extended_info
FROM
hologres.hg_query_log
WHERE
extended_info ->> 'source_trx' = '<transaction_id>' -- Obtain the transaction_id from the trans_id field of the record for tasks like COPY, CTAS, or RESHARDING.
-- extended_info ->> 'src_query_id' = 'query_id' -- Stored procedures are not transactions, so you need to link them using the query_id field.
-- query like '%<transaction_id>%' -- RESHARDING tasks cannot be linked using the extended_info field. You must link them using the query field.
ORDER BY
query_start
;View resource usage
View the total serverless resources used by active SQL tasks.
SELECT
datname::text as db_name,
(running_info::json) -> 'current_stage' ->> 'stage_name' AS current_stage,
SUM(((running_info::json) -> 'current_stage' ->> 'serverless_allocated_cores')::int) AS total_computing_resource,
count(1) as query_qty
FROM
hg_stat_activity
WHERE (running_info::json) ->> 'computing_resource' = 'Serverless'
GROUP BY
1,
2;The result set includes the following columns:
db_name: The database name.current_stage: The execution stage of a task, such asEXECUTE(running) orQUEUE(queued).total_computing_resource: The total serverless resources used by the database and in the execution stage.query_qty: The number of SQL queries.