Trying to use API – via Python SDK – to retrieve query information of elements in LookML Dashboards. I’ve noticed that the IDs of elements in UDDs are numeric strings but elements in LookML Dashboards are MD5 hash.
When I try to use the Get DashboardElement method to retrieve metadata for this element I get a 404 error.
When I look at list of elements from the Dashboard object returned from using Get Dashboard, I don’t see query object but only result_maker. And within the result_maker object there is no information regarding model, explore, fields, etc. These issues do not exist if I’m trying to retrieve elements from a UDD.
Is this a bug in API or is there a different method I need to be using when it comes to retrieving metadata of LookML Dashboard Tiles?
You usually have to use different methods to get information for LookML dashboards vs user-defined dashboards. User-defined dashboards have values for dashboard_element.query, which will give you the model and Explore, whereas for LookML dashboards you have to use elements.result_maker.
To show this in action, this is a script I use to pull information for all the dashboard tiles when I input a particular dashboard ID:
import os
import pandas as pd
from looker_sdk import init40
config_path = os.path.expanduser("~/python/looker.ini") # this should point to where you have saved your Looker API credentials
sdk = init40(config_file=config_path)
### --- FETCH DASHBOARD --- ###
dashboard_id_to_fetch = '1158' # Replace with your dashboard ID
# Fetch specified dashboard and store in a variable
print(f"➡️ Fetching dashboard {dashboard_id_to_fetch}...")
dashboard_full = sdk.dashboard(str(dashboard_id_to_fetch))
dashboard_elements = dashboard_full.dashboard_elements or []
# Create a list to store the dashboard elements data
dashboard_visualisations_data = []
# Loop through each dashboard tile, and append the details for each tile to the list
print("➡️ Fetching metadata and query details for each dashboard tile...")
for element in dashboard_elements:
if element.type != "vis":
continue # excludes non-query tiles
# Get the visualisation type (works for user-defined and LookML dashboards)
vis_type = None # assigns a default value in case the 'if' condition fails
if element.result_maker and element.result_maker.vis_config:
vis_type = element.result_maker.vis_config.get("type") # only grabs vis type if the tile has one (to avoid errors)
# Get dashboard-level filters, and return only the field names (works for user-defined and LookML dashboards)
dashboard_level_filters_full_string = element.result_maker.filterables
dashboard_level_filters = []
for filtered_field in dashboard_level_filters_full_string:
for listen_item in getattr(filtered_field, "listen", []):
field_name = getattr(listen_item, "field", None)
if field_name:
dashboard_level_filters.append(field_name)
# Get other visualisation details
if element.query: # gets info for user-defined dashboards
model_name = element.query.model
explore_name = element.query.view
filters = element.query.filters if element.query.filters else element.query.filter_expression
fields = element.query.fields
custom_fields = element.query.dynamic_fields
short_url = element.query.share_url
elif element.result_maker and element.result_maker.query: # gets info for LookML dashboards (element.query does not exist)
model_name = element.result_maker.query.model
explore_name = element.result_maker.query.view
fields = element.result_maker.query.fields
filters = element.result_maker.query.filters if element.result_maker.query.filters else element.result_maker.query.filter_expression
custom_fields = element.result_maker.query.dynamic_fields
short_url = element.result_maker.query.share_url
dashboard_visualisations_data.append({
"dashboard_id": dashboard_full.id,
"dashboard_title": dashboard_full.title,
"dashboard_level_filters": dashboard_level_filters,
"visualisation_id": element.id,
"visualisation_title": element.title,
"visualisation_type": vis_type,
"model": model_name,
"explore": explore_name,
"filters": filters,
"fields": fields,
"custom_fields": custom_fields,
"short_url": short_url
})
# Convert to a DataFrame for easy CSV export
df = pd.DataFrame(dashboard_visualisations_data)
# Output the DataFrame to a CSV file
print("💾 Exporting to CSV...")
output_path = "/Users/yourname/Python/outputs/get_tile_level_metadata_for_a_dashboard.csv" # Change this path as needed
df.to_csv(output_path, index=False)
print(f"✅ Results exported to: {output_path}")