Google Cloud Observability provides monitoring, logging, and diagnostic tools. These tools can help you monitor and analyze Cloud Tasks activity and growth, and understand the behavior, health, and performance of your applications.
By default, Cloud Tasks is configured to do the following:
- Send data and system audit logs to Cloud Logging. You can use the collected logs to debug, troubleshoot, and gain insights about your applications.
- Send system and resource metrics to Cloud Monitoring. You can use the collected metrics to monitor health and performance, identify trends and issues, and notify for changes in behavior.
Send audit logs to Cloud Logging
Cloud Tasks sends the following types of audit log data to Cloud Logging:
Data Access audit logs are disabled by default because these audit logs can be quite large.
For more information, see Cloud Tasks audit logging.
Use Cloud Logging with queues
You can use Cloud Logging with Cloud Tasks queues. The following operations are logged:
- Task operations:
CreateTask
DeleteTask
- Attempt operations:
AttemptDispatch
AttemptResponse
Enable logging
You can enabling logging using the Google Cloud console or the Google Cloud CLI.
Console
In the Google Cloud console, go to the Cloud Tasks > Queues page.
Click the name of the queue that you want to enable logging for.
On the Queue details page, click the Logs tab.
Click Enable logs and, to confirm, click Enable.
gcloud
To enable logging, you can use either the
gcloud tasks queues create
or the gcloud tasks queues update
command.
gcloud tasks queues create QUEUE_ID \ --log-sampling-ratio=LOG_SAMPLING_RATION
or
gcloud tasks queues update QUEUE_ID \ --log-sampling-ratio=LOG_SAMPLING_RATIO
Replace the following:
QUEUE_ID
: the ID of your queueLOG_SAMPLING_RATIO
: the fraction of the operations logged. Any value between1.0
and0.0
logs that fraction of operations. To log all operations, set it to1.0
. To log no operations, set it to0.0
(this is the default).
Disable logging
You can disable logging using the Google Cloud console or the Google Cloud CLI.
Console
In the Google Cloud console, go to the Cloud Tasks > Queues page.
Click the name of the queue that you want to disable logging for.
On the Queue details page, click the Logs tab.
Click the ellipsis icon > Disable logs. To confirm, click Disable.
gcloud
To disable logging, use the
gcloud tasks queues update
command and set the log-sampling-ratio
flag to 0.0
.
gcloud tasks queues update QUEUE_ID \ --log-sampling-ratio=0.0
Replace QUEUE_ID
with the ID of your queue.
Query and view logs
You can use following tools to view and analyze your logs:
- Logs Explorer is designed to to help you troubleshoot and analyze the performance of your services and applications. To learn how to view logs in the Logs Explorer, follow the instructions in View logs by using the Logs Explorer.
- Log Analytics is designed to run queries to analyze your logs, and then view or chart the results. To learn how to use Log Analytics, follow the instructions in Query and analyze logs with Log Analytics.
You can filter for Cloud Tasks logs in the Logs Explorer by
searching for cloudtasks
in the search field.
For more information about querying and analyzing logs, see Query and view logs overview.
Send metrics to Cloud Monitoring
Cloud Tasks sends metric data from monitored resources to Google Cloud Observability. A monitored resource in Monitoring represents a logical or physical entity, such as a virtual machine, a database, or an application. Monitored resources contain a unique set of metrics that can be explored, reported through a dashboard, or used to create alerts.
Cloud Tasks sends metric data from the following monitored resource to Google Cloud Observability:
Each resource also has a set of resource labels, which are key-value pairs that hold additional information about the resource. Resource labels are available for all metrics associated with the resource and are detailed in the following table.
Resource metrics and labels
The "metric type" strings in this table must be prefixed
with cloudtasks.googleapis.com/
. That prefix has been
omitted from the entries in the table.
When querying a label, use the metric.labels.
prefix; for
example, metric.labels.LABEL="VALUE"
.
Metric type Launch stage (Resource hierarchy levels) Display name |
|
---|---|
Kind, Type, Unit Monitored resources |
Description Labels |
api/request_count
GA
(project)
API requests |
|
DELTA , INT64 , 1
cloud_tasks_queue |
Count of Cloud Tasks API calls. Sampled every 60 seconds. After sampling, data is not visible for up to 240 seconds.
api_method :
The API method called (e.g. CreateTask).
response_code :
Canonical response code as string (e.g. 'ok').
|
queue/depth
GA
(project)
Queue depth |
|
GAUGE , INT64 , 1
cloud_tasks_queue |
The number of tasks in the queue. Sampled every 60 seconds. After sampling, data is not visible for up to 120 seconds. |
queue/task_attempt_count
GA
(project)
Task attempt count |
|
DELTA , INT64 , 1
cloud_tasks_queue |
Count of task attempts broken down by response code. Sampled every 60 seconds. After sampling, data is not visible for up to 180 seconds.
response_code :
Canonical response code as string (e.g. 'ok').
|
queue/task_attempt_delays
GA
(project)
Task attempt delays |
|
DELTA , DISTRIBUTION , ms
cloud_tasks_queue |
Delay between each scheduled attempt time and actual attempt time. Sampled every 60 seconds. After sampling, data is not visible for up to 120 seconds. |
Table generated at 2025-01-17 15:30:46 UTC.
To view all resource types, see Monitored resource types. To view all metric types, see Google Cloud metrics.
Read metric data
You can read metric data, also called time-series data, by using the
timeSeries.list
method in the Cloud Monitoring API. There are several ways to
call the method, including using a language-specific client library, or by
creating a chart with
Metrics Explorer. For an introduction to metrics
and time series, see
Metrics, time series, and resources. To learn how
to read your metric data, see
Retrieve time-series data.
Use Monitoring dashboards and alerts
You can use Monitoring dashboards and their associated charts to visualize the data for Cloud Tasks metrics.
To monitor these metrics in Monitoring, you can create custom dashboards. You can also add alerts based on these metrics.