Managing Custom Scheduled Queries


SummaryAn overview of the types of scheduled queries and how to work with custom scheduled queries using various API methods.

With Alooma there are two types of queries, both of which are scheduled: Consolidation (or default) and Custom scheduled queries. For more information about queries see Queries. Here, we'll focus on scheduled queries.

You could use a scheduled query to do something like take a snapshot of a table every night to create a log table.

Query functions

Just like with all other API work, it all begins with authenticating and getting an API instance. Once you have an API Instance, you can get a list of scheduled queries as well as create/schedule and delete them by using the methods below.

Get all scheduled queries

Use get_queries() to return a list of scheduled queries. You can also retrieve the list of any scheduled queries that did not run successfully on the last attempt.


# in error state
Create a scheduled query

Use schedule_query() to create a custom scheduled query specifying the event type, query, and either the frequency or the schedule, but not both. You can use a cron-like string for the value of run_at.Schedule Syntax

# Creating a Scheduled Query
# all queries must tie to an event type, even if they do not relate 
EVENT_TYPE = '<test_event>'
QUERY = """
SELECT * FROM my_table;
## These fields control query run times (only 1 can be used/specified)
# Frequency takes an integer value, re-run query X hours after last run
# run_at takes a Cron-like string (i.e. "0 * * * *")
api.schedule_query(EVENT_TYPE, QUERY, frequency=FREQUENCY, run_at=RUN_AT)


Snowflake users will need to replace single quotes (') in the query string with two dollar signs ($$) as explained in Dollar-quoted String Constants, here:

Remove a scheduled query

Remove a scheduled query by specifying the query ID from get_scheduled_queries().


Search results

    No results found