If you have many BigQuery users on your team, you can better control your team's usage and costs with the use of query policies.
Query policies specify a limit on data scanned or query cost for a given interval of time.
Policies allow you to effortlessly manage your team and can be customized according to your team's usage habits.
How to set up query policies
To create a query policy, access your policy hub by clicking on your Profile image in the left-hand resource panel. Then click on Settings and go to the Policies tab.
Finally, click the "+ Add Policy" button to open your policy creator.**
**In order to set up policies, make sure you have an Admin role on your superQuery team.
Easily create a policy by using a series of dropdown options. Let's go over each option below.
Does your policy apply on a per-user basis, or on the entire team? This is the question you're answering with the Limitation Level dropdown.
For example, if you have a Per-user query policy set up then if one user hits the limit — say $75 in 1 hour — the rest of the team will still be able to query.
An organization-level policy takes the combined usage of your superQuery team into account. Using the example above, if four users on your team queried $75 in less than an hour, then the policy will be triggered for the whole team.
The Actions dropdown is where you decide what happens when a policy gets triggered.
Choose whether to:
- Block the organization / user from querying until the policy timeframe is up, or
- Get notified when a policy is triggered.
If you select Notify, you will have the option of adding an additional email to be notified once a policy is triggered.
You may leave this field blank if you're the only person who needs to be notified.
Limit By & Set Limit
Decide whether to limit users by
- Terabytes scanned, or
- Query cost
After deciding that, enter a number that'll represent the limit that, if reached, will trigger your policy.
Units & Intervals
Finally, the last decision you need to make is on the policy's time period. Select the unit (hour, day, week, month), and then determine the interval.
This represents the period of time in which your limit will have to be reached to trigger the policy.
For example: If you set a limit of $75 for a 1-hour period, this means that if the limit is reached in less than an hour then the policy will trigger.
However, if you execute $73 worth of queries in 59 minutes, and then execute a $3 query two minutes later, the policy will NOT be triggered.
How query policies are enforced
When a policy is triggered, the triggering query will not execute successfully if the policy's Action is set to "Block".
Instead, the user will see a message in their results grid displaying the policy name and the length of time they'll be unable to query.
Accessing Policy Logs
View individual policy log
To inspect the logs of a policy, click on Log Info next to the policy you'd like to view.
Policy logs display information on when the selected policy was triggered, and which user triggered it.
View all policy logs
To view the combined logs of all your policies, go to your policy hub and click on the Audit button.
Logs are useful for understanding which users are consistently hitting your policy limit(s).
You can then use this information to address these users individually and explore tactics to help them better control their usage — or perhaps modify your policy.
Edit, Disable, And Delete Policies
To edit, temporarily disable, or delete a policy, click on the ⋮ next to a policy.
From there, select the action you'd like to take.
Disabled policies are denoted by a grey 🚫 symbol in the status bar.