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.
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
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.