Viewing tasks and task graphs in Snowsight¶
Tasks let you schedule the execution of SQL code. A task is associated with a specific database and schema. You can use Snowsight to view and manage your tasks and task graphs. Using Snowsight, you can also view the execution history for tasks and tasks graphs and retry failed tasks.
View and manage individual tasks¶
To view and manage a task in Snowsight, do the following:
Sign in to Snowsight.
Select Data » Databases.
For a specific database and schema, select Tasks and select the task you want to manage.
When viewing the task in Snowsight, you can do the following:
In the Details section, review the task ID, warehouse used by the task, schedule, state, parameters, and any conditions.
Review the SQL statement used to create the task and any task graph configurations in the Task Definition section.
Manage privileges on the task. See Manage object privileges with Snowsight.
Select the … actions button to edit the task, clone the task, drop the task, or transfer ownership of the task to another role.
When you edit a task in Snowsight, the task is automatically suspended and resumed when you finish editing the task. For more information about suspending and resuming tasks, see Versioning of task runs.
View and manage task graphs¶
Review a task graph to see a root task, its dependent tasks, and finalizer task in the format of a task graph. For more information about task graphs, see Manage task dependencies with task graphs. When you review a task graph, you can do the following in Snowsight:
View task information.
Examine the task graph.
Select a task on the graph to view additional details, such as predecessor tasks, the warehouse used to run the task, and the role that owns the task.
You can also edit the root task to change parameters for the task graph. When you edit a task in Snowsight, the task is automatically suspended and resumed when you finish editing the task. For more information about suspending and resuming tasks, see Versioning of task runs.
![Example task graph shown in Snowsight, with annotations showing the navigation to view the task graph as described in the following procedure.](../_images/ui-snowsight-task-graph.png)
To view a task graph for a specific database schema, do the following:
Sign in to Snowsight.
In the navigation menu, select Data » Databases.
Use the object explorer to locate the database and schema that contain the tasks that you want to view.
For the selected schema, select Tasks.
Select a specific task.
The task details appear, with additional Graph, and Run History tabs.
Select the Graph tab to view the task graph.
The task graph appears, displaying a hierarchy of tasks.
Select a task to view details in the context of the graph.
Note
Task history data is only available if the task has been executed in the last 7 days.
Viewing task history¶
Using Snowsight, you can review the execution history for tasks in different ways:
View the execution history of all tasks run in your account, for example to identify critical tasks that failed to run, long-running tasks, or tasks increasing costs.
View the execution history for a specific task, to gather more information about the task.
View the execution history for a task graph, for observability and monitoring purposes and to help identify problems with a specific task graph.
You can also review task history in SQL by using a table function TASK_HISTORY or a view TASK_HISTORY view.
Required privileges for viewing task history¶
To view task history in Snowsight, you need the same privileges required to run the TASK_HISTORY function.
You must use one of the following roles:
The ACCOUNTADMIN role.
A role with the OWNERSHIP privilege on the task.
A role with the global MONITOR EXECUTION privilege and the USAGE privilege on the database and schema that store the task.
The role that you use must be able to query the Account Usage TASK_HISTORY view. You can grant the USAGE_VIEWER database role in the shared SNOWFLAKE database to the role that you use.
For example, to view the history for a specific task mytask
, the custom role myrole
needs:
The OWNERSHIP privilege on the task.
The USAGE_VIEWER database role in the shared SNOWFLAKE database.
To grant those privileges, run the following SQL commands:
GRANT OWNERSHIP ON TASK mytask TO ROLE myrole;
GRANT DATABASE ROLE USAGE_VIEWER TO ROLE myrole;
For details, see:
Review the run history for a task¶
Task run history includes details about each execution of a given task. You can view the scheduled time, the actual start time, duration of a task and other information.
![Snowsight task history page with annotations for each section.](../_images/ui-snowsight-task-run-history.png)
For each instance, you can view the following:
Scheduled start time: When is the task next scheduled to run.
Status: Status of the most recent run.
Duration: Amount of time, in seconds, for the most recent run.
Query: View the task query profile or task statements in a worksheet.
To view the run history:
Sign in to Snowsight.
Select Data » Databases.
In the right pane, using the object explorer, navigate to a database and schema.
For the selected schema, select and expand Tasks.
Select a task. Task information is displayed, including Task Details, Graph, and Run History sub-tabs.
Select the Run History tab.
Note
Task history data is only available if the task has been executed in the last 7 days.
Review account-level task history¶
Review the account-level history for task runs to identify failing tasks, long-running tasks, and other monitoring and debugging cases for an entire account, rather than for one specific task.
To view account-level history for tasks, do the following:
Sign in to Snowsight.
In the navigation menu, select Monitoring » Task History.
To view individual task runs, select View » Task Runs from the filters.
After you select the history of task runs, you can filter the page to display relevant information.
Select the Date Range filter to show task history from the last day through the last 12 months, or a custom range.
Select the Task status filter to display task history for one or more status, such as Succeeded, Failed, Cancelled, or Skipped.
Filter on the name of the task to see patterns in status or duration over time for specific tasks.
Filter on the name of the database or schema that contain the tasks.
For example, to identify long-running tasks, select the Status filter to show only successful tasks, and sort the Duration field in descending order. For advanced debugging, you can open the filtered and sorted table in worksheets using the Open in worksheets button. You could then modify the SQL statement with LIMIT / FETCH and GROUP BY arguments to identify the databases and schemas with the top 25 most long-running tasks.
You can also select a specific task to drill down for more details.
Review account-level task graph history¶
Review the account-level history for task graphs to identify critical failing tasks preventing a graph from completing, long-running tasks, inefficient or frequently failing task graphs, and other monitoring and debugging cases for an entire account.
To view account-level history for tasks graphs, do the following:
Note
You must use a role that has the OBJECT_VIEWER database role. The task graph history page uses the COMPLETE_TASK_GRAPHS view. For more information, see ACCOUNT_USAGE schema SNOWFLAKE database roles. Your role must also have the OWNERSHIP privilege on the task.
Sign in to Snowsight.
In the navigation menu, select Monitoring » Task History.
By default, the page displays all task graph runs from the last day as a histogram and a table.
After you select the history of task graph runs, you can filter the page to display relevant information.
Select the Date Range filter to show task history for a longer time range, up to the last 12 months.
Select the Graph status filter to display the run history for one or more task graph statuses, such as Succeeded, Failed, Cancelled, or Skipped. If one task in the graph failed, the entire graph is shown as Failed.
Filter on the name of the database, and optionally a schema, that contain the root tasks for the task graphs.
After selecting the database and optional schema, filter on the name of the root task name to see patterns in status or duration over time for specific task types. You might see root tasks that your active role does not have privileges to view.
For example, to identify task graphs with failing tasks, select the Graph status filter to show only failed tasks. You can hover over a failed task for more details about the failure. For advanced debugging, open the filtered and sorted table in worksheets using the Open in worksheets button. You could then modify the SQL statement with LIMIT / FETCH and GROUP BY arguments to identify, for example, the databases and schemas with the top 25 failing tasks.
Debug a task graph run¶
When viewing the account-level task graph history, select a specific task graph run to see more details. If you have access to view the history of the tasks in the graph, the task graph run displays, otherwise you see an error.
![Snowsight task graph showing one root task with 3 dependent tasks, and 4 dependent tasks of those predecessors. The Task titled ROOT_TASK succeeded while showing a slightly longer duration than other tasks, along with INSERT_1 task. Two dependent tasks of INSERT_2 ran but failed, and the third dependent task succeeded. The highlighted task failed.](../_images/snowsight-task-graph-run.png)
For example, you can select a specific failed task graph run to view the full graph and identify tasks that did not run as a result of specific failed tasks, suspended tasks, or identify a long-running task that is delaying a dependent task run in the graph.
For a specific task in the task graph, you can gather additional details about the task by hovering over various aspects of the task:
Warehouse metadata identifies which warehouse is used to run the task, including the status and size, which can help identify tasks running slowly due to warehouse size or which are contributing to warehouse usage.
Stream condition metadata displays the table stream details and whether the conditions were set to true or false for the task.
Select Go to Task Page to view additional details about the task.
Each task displays a status, such as Succeeded, Failed, Skipped, Suspended, Cancelled, or Did not run, along with a corresponding color. You can hover over the status of failed, skipped, suspended, and cancelled tasks for more information.
In addition to the task graph, you can review a table describing which tasks ran, the start time of each task, the duration of each task run, the status of each task, and a timeline representing the sequence of task runs. With the timeline, you can quickly determine why a task graph run was slow, and which long-running task might have delayed the start of a dependent task.
For each task in the table, you can select the … more menu to open the query ID for the task in a worksheet, or open the query profile.
Retry failed tasks¶
In Snowsight, you can see previous task run attempts and manually retry failed and canceled task graphs. You must have the OPERATE privilege on the task to retry failed and canceled tasks. To view previous task run attempts, you also need the same privileges as viewing task history.
Take the following steps to retry failed and canceled tasks.
Follow the steps to open the account-level task graph history.
On the account-level task graph history page, select a specific task graph run to see more details.
On the specific task graph run details page, select Retry to manually retry all failed task graph runs.
The retry starts only failed and canceled tasks in a graph and does not rerun tasks that have already succeeded.
Select the refresh button to refresh the page. The failed attempts show up in the account-level task graph run details. Account-level task run history and task graph run history show the status of the most recent attempt with a 45-minute latency.
The failed attempts also show up in the object-level task history. Follow the steps to view the run history of a task. The latest attempt for a run is shown. All attempts to run the task have the same run ID.
Any previous failed or canceled attempts are shown next to the run status. You can select the task to see the scheduled timestamp, status, and error messages for each attempt.
Note
The Retry button is disabled if any of the following is true:
No tasks in the graph failed or were canceled.
A retry is already in progress.
The selected run is not the most recent run.
The task graph has been modified after the run.
The run is longer than 14 days.