Metabase Metadata SQL

Hey everyone, I am trying to figure out if it is possible to query for all questions and dashboards that weren't visited in the past few months. Is it possible to do this in the application database?

That's already been answered earlier in this thread.

Got it, thank you!

Hi, I am new to application db. May I know, running_time in query_execution falls under what time format? seconds?

image

@amzar Look at the column descriptions, they are available for most tables and columns.
Specifically query_execution.running_time: The time, in milliseconds, this query took to complete.

1 Like

Thank you for sharing your queries! It was really helpful:)
Additionally I need to show dashboards which appear at the main page of our company metabase page. This dashboards are pinned in our collection Our analytics. Maybe you know where to find pinned dashboards in metabase logs?

Agreed super helpful

  • List of un archived dashboards with last accessed date on the public link
-- using view log table see when cards were last accessed and map the card ids to dashboard ids. 
-- (none of my cards are on more than one dash)
with joined as (
    select 
        view_log.model_id as Model_ID,
        date(max(view_log.timestamp)) as Last_Viewed,
        report_dashboardcard.dashboard_id as Dashboard_ID 
    from
        view_log 
        left join report_dashboardcard on view_log.model_id = report_dashboardcard.card_id 
    where 
        view_log.model = 'card'
        and view_log.user_id is null
    group by 
        Model_ID, 
        Dashboard_ID
),

-- get rid of dashboards that are archived
dashboards as (
    select 
        report_dashboard.id as Dashboard_ID,
        report_dashboard.name as Dashboard_Name
    from 
        report_dashboard
    where
        report_dashboard.archived = false
)

-- join two above tables to link dashboard name to dashboard id
select 
    dashboards.dashboard_name as Dashboard_Name,
    max(joined.last_viewed) as last_viewed 
from 
    joined 
    inner join dashboards on joined.dashboard_id = dashboards.dashboard_id
group by 
    Dashboard_Name
order by 
    last_viewed desc
1 Like

Hi, I'm struggling to find the Metabase application credentials. Could someone point me to the right direction? I have admin rights.

You need to migrate to Postgres or MySQL

Later update. Found it, thank you!

It is possible run these querys in Metabase Cloud?

@felipe.coxa No: https://www.metabase.com/cloud/docs/limitations#no-access-to-application-database

I already imagined that, more money to spend, thank you.

for those still looking, recently found this library by Roberto; contains a lot of useful queries on the internal application database for a typical BI-team

Has anyone the datamodel of Metabase? relation between tables?
I would like to get, not the most viewed dashboards but the more used TABLES...

check out Metabase Database Models · metabase/metabase Wiki · GitHub for an entity relationship diagram of the internal MB database

https://user-images.githubusercontent.com/25661381/205235833-c2ef54ce-1f2d-4a17-b4f2-b7dc9313b5b7.svg

3 Likes

lot of thanks!

Hi,
Was anyone able to get a number of visits to the Public-embedded dashboard and visits for each tab?

Hi Andrew,
I still don't get on how to query report_card from metabase db. I got this following error message
SELECT command denied to user 'metabase_system'@'10.1.60.151' for table 'report_card'

Could you please show me how to query the metabase db?

First add the database in Admin.
That error is user rights related. Is that the same account you use to start Metabase?