Query for checking dashboard usage

I would like to query the audit logs to obtain usage stats for all dashboards created by a particular user. In particular I would like to know which unique people, other than the creator, has viewed each dashboard created by this particular user, and how many times they have viewed it.

Any help would be appreciated !

1 Like

Hi @GBS
You should use the email support, when using Pro/Enterprise.
There's Audit functionality: https://www.metabase.com/docs/latest/enterprise-guide/audit.html
And if you need further specific analysis, then you can connect the application database as a source and make queries against it, see some tips here Metabase Metadata SQL

Hey GBS -

If you're connected to the Metabase database, you can get this from the view_log, report_dashboard, and core_user tables. See query below:

select
  count(*) as view_count,
  report_dashboard.id as dashboard_id,
  report_dashboard.name as dashboard_name,
  core_user.id,
  core_user.first_name,
  core_user.last_name,
  core_user.email
from
  view_log
join
  report_dashboard on view_log.model_id = report_dashboard.id
join
  core_user on view_log.user_id = core_user.id
where
  report_dashboard.creator_id = {{creator_user_id}}
  and view_log.user_id != {{creator_user_id}}
  and view_log.model = 'dashboard'
group by
  core_user.id,
  core_user.first_name,
  core_user.last_name,
  core_user.email,
  report_dashboard.id,
  report_dashboard.name

Hope this helps!

2 Likes

Hi @josiah44,
It's very interesting! Thank you so much for the query. But how we can connect to Metabase database ?
In "Browse Data", I only see Sample Database and another databases of my company.

SUPER late response. Apologies mluk.

First, you have to be using metabase's "On-Prem" (self-hosted) solution. You cannot do this with the cloud solution.

If you're self-hosting, you can point to the metabase database as a SOURCE to itself. We've lovingly named ours "Metabase-ception"). For reference, ours is a PostgreSQL database. I don't honestly know if Metabase has other options for the Database type for self-hosted dbs.