Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Metabase Usage #5570

Closed
gilhs opened this issue Jul 25, 2017 · 13 comments
Closed

Tracking Metabase Usage #5570

gilhs opened this issue Jul 25, 2017 · 13 comments
Labels
Type:Question Please use the forum: https://discourse.metabase.com/

Comments

@gilhs
Copy link

gilhs commented Jul 25, 2017

As we've rolled out Metabase across our organization, we want to start tracking actual usage - who uses it, on what basis, what dashboards/cards are they using, etc.

I've found a (relatively) older PR (#2386) that discusses adding query metadata as a comment to the queries - this is definitely a good solution that we can take advantage of to answer our questions; however, I'm not seeing the metadata appended to our queries.

We're using Google BigQuery, and the GCP Stackdriver integration to log all queries run through BQ.
Is this not supported for BQ? Or am I missing a configuration to control this somewhere?

If not - what are possibilities do we have of tracking usage?

@robinfrick
Copy link

You can connect to Metabases own Database. Actually we have added it to Metabase itself with a read only user and made it only available to Admins (we don't have a read replica and don't want someone to accidentally run very expensive queries on it).

Here's a first inspiration for getting the 10 most active users for question creation and saving changes:

SELECT first_name || ' ' || last_name as name, 
        SUM(CASE WHEN topic = 'card-create' THEN 1 END) as "question created", 
        SUM(CASE WHEN topic = 'card-update' THEN 1 END) as "question updated"
FROM Activity INNER JOIN core_user on core_user.id = Activity.user_id
GROUP BY 1
ORDER BY 2 desc , 3 desc LIMIT 10

@gilhs
Copy link
Author

gilhs commented Jul 25, 2017

Thanks, I'll check it out!

@salsakran
Copy link
Contributor

@gilhs As @robinfrick mentioned, the application database is JustAnotherDatabase you can attach Metabase to and pull out whatever reports you need.

Depending on your scale of usage, we're also working on a dedicated "analytics on analytics" product on top of Metabase internally, and would love some feedback if you're open to a conversation.

@salsakran salsakran added the Type:Question Please use the forum: https://discourse.metabase.com/ label Jul 26, 2017
@gilhs
Copy link
Author

gilhs commented Jul 27, 2017

Always open to conversation :)

In terms of our needs - our scale is currently small, and it looks like the data that's currently being saved in the application DB is just right for what we're looking for. What kind of advanced analytics are you developing?

@vijayvenkatesh
Copy link

Hi @robinfrick @salsakran Got the local metabase connected and added to in metabase.
When I run the query above as myself (admin) I get
Running SQL queries against H2 databases using the default (admin) database user is forbidden.

@ans-4175
Copy link

@vijayvenkatesh I think you need to migrate metabase to another sql dbms and then connect metabase against your newly migrated db

@philippkeller
Copy link

After migrating from H2 to Postgres (which is best practice anyway for production use) I was able to query the meta data. I expanded the query from @robinfrick above to also show the number of queries done (we promote metabase as an ad-hoc tool so I don't expect many people are saving their questions) and limiting to the past 30 days:

SELECT *, (select count(*) from query_execution where executor_id=card.id and started_at > current_date - 30) as "queries executed" FROM 
(SELECT core_user.id as id, first_name || ' ' || last_name as name, 
        SUM(CASE WHEN topic = 'card-create' AND timestamp > current_date - 30 THEN 1 END) as "question created", 
        SUM(CASE WHEN topic = 'card-update' AND timestamp > current_date - 30 THEN 1 END) as "question updated"
FROM Activity INNER JOIN core_user on core_user.id = Activity.user_id
GROUP BY core_user.id) card
ORDER BY "queries executed" DESC

@ambarshante
Copy link

@robinfrick and @philippkeller thanks – this works great. Just one small issue – the credentials to the various databases connected to Metabase are exposed in the metabase_database table. Is there a way to not sync this table, or to store these in a hashed form?

@robinfrick
Copy link

@ambarshante if you set up a dedicated reader for your Metabase database queries through Metabase (as in not the DB user that metabase uses itself in the backend) then you can just revoke select permission for the table where the credentials are stored. Or probably better only selectively grant select for the tables you actually want to access for analytical purposes.

@flamber
Copy link
Contributor

flamber commented Nov 28, 2019

@vitorhirota
Copy link

vitorhirota commented Jan 10, 2020

We also use questions against metabase metadata db to list, for instance, most executed cards.

But I would like to know what are the most executed dashboards.

I saw there's a dashboard_id field in query_execution, but it is always empty.

Not sure if it's something I'm missing configuring, or it should be a separate issue.

@flamber
Copy link
Contributor

flamber commented Feb 7, 2020

@vitorhirota I think it might deserve it's own issue. Would you create one? If you use Public dashboards, then it includes the dashboard_id in query_execution, so perhaps it's just a missing parameter for regular dashboards.

@flamber
Copy link
Contributor

flamber commented Jul 1, 2021

Closing this, since the Enterprise Edition has Audit functionality: https://www.metabase.com/docs/latest/enterprise-guide/audit.html

@flamber flamber closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type:Question Please use the forum: https://discourse.metabase.com/
Projects
None yet
Development

No branches or pull requests

9 participants