Hi all,
Running an excessive amount queries simultaneously may lead to degraded Looker instance performance, especially queries run by an API user to send out bulk schedules or queries requiring post-processing features (such as merged results, custom fields, and table calculations). In these situations, the fastest way to bring an instance back to a normal stage is to kill all running queries to help with restoring CPU and memory.
I am sharing an example script to kill running queries using Looker Python SDK (either all running queries, or selective queries with two optional arguments: 'user_id' and 'source')
Link to Google Colab to run as an one-off task.
import looker_sdk
sdk = looker_sdk.init40()
def kill_queries(user_id=None, source=None):
"""Kill running queries in an instance.
Args:
user_id(int): id of the user whose queries are to be killed
source(str): common values are 'merge_query', 'explore', 'dashboard', 'look', 'regenerator'
"""
queries = sdk.all_running_queries()
if len(queries) == 0:
print('Currently, there is no running query in the instance')
else:
for i in range(0, len(queries)):
if queries['source'] == source or queries['user']['id'] == user_id:
sdk.kill_query(queries['query_task_id'])
print('Killed query task id' + queries['query_task_id'])
else:
print('Currently, there are no running queries that meet the conditions')
kill_queries(user_id=1, source='merge_query')
hi Lan, I have been trying to download dashboards in pdf format but no luck using looker_sdk.. by any chance do you have anything handy ?
Hi Naren, have you tried testing with this example script from Looker Python SDK example repo?