Stay organized with collections Save and categorize content based on your preferences.
Set up alerts with scheduled queriesThis document describes how to set up an alert using a BigQuery scheduled query. This approach supports custom use cases defined by query logic.
Before you beginBefore you use Cloud Monitoring, ensure that you have the following:
One way to ensure that you have both is to complete the Quickstart using the Google Cloud console.
Create a SQL queryCreate and run a SQL query in BigQuery that generates the output for your alert. The query captures the logic that you want to monitor. For more information, see Run a query.
Set up a scheduled queryYou can schedule queries to run on a recurring basis, from every 15 minutes to every several months. You can write any query over your log buckets. For more information, see Scheduling queries.
Understand the row count metricScheduled queries automatically create a metric in Cloud Monitoring. This metric records the number of rows that the SQL query returned during its last evaluation. You can create an alert policy that monitors this row count metric in Monitoring.
The following metric is a gauge that contains the most recent row count of a scheduled query:
bigquerydatatransfer.googleapis.com/transfer_config/last_execution_job_rows
All scheduled queries write their row count to this metric, using different labels. You need the config_id
label when you define an alert policy. To find the config_id
label, follow these steps:
In Google Cloud console, go to the Scheduled queries page:
Click the scheduled query for which you want to create an alert.
Go to the Details tab.
Check the last string in Resource name, as shown in the following screenshot:
If a problem occurs with the scheduled query, an error message appears in the Run history tab of your scheduled query.
Monitor scheduled queriesMonitor scheduled queries to ensure successful executions:
completion_state
field of the bigquerydatatransfer.googleapis.com/transfer_config/completed_runs
metric.Use a metric-threshold alert to detect when the number of rows returned by the scheduled query differs from a threshold.
To set up an alert on the number of rows a scheduled query returns, follow these steps:
In the Google Cloud console, go to the notifications Alerting page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
Click Create policy.
Select the row count metric for the scheduled query. In the Select a metric menu, click BigQuery DTS Config > Transfer_config > Last executed job row count.
In Add filters, click Add a filter.
In the Filter menu, select config_id.
In the Value menu, select the config_id
of the scheduled query for which you want to create an alert:
If you don't set a filter, your alert tests the output of every scheduled query. To find the config_id
of your scheduled query, see Understand the row count metric.
Keep the default Transform data settings and click Next.
For Condition types, select Threshold.
Select the condition that you want. For example, to trigger when the query returns any rows, set the following condition:
0
.Keep the default Advanced Options and click Next.
Optional: To configure notifications for your alert, click the Use notification channel toggle, and then set channels and subject line for your notifications. You can also set notifications for incident closure.
If you don't want notifications, deselect the Use notification channel toggle.
Optional: If you have many alert policies, you can annotate labels on them to indicate that they are derived from scheduled queries.
Optional: In the Documentation field, you can add links that help to interpret the alert. For example, you can add a link to the Logs Explorer page with a similar query, so that you can explore the data that raised the alert. You can also link to the specific schedule query's details page.
In Name the alert policy, enter a name for your alert.
Click Create Policy.
Alert policies for scheduled queries are subject to the following limitations:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4