Area: Observability
Sub-Area: Usage Tracking
Applies to: OSS + Cloud
Issue
Usage statistics (query counts and users) are not appearing for a dataset in the DataHub UI. The dataset's Queries and Stats tabs are greyed out or empty.
You Might Be Asking
- Why are usage stats empty?
- Why are the Queries and Stats tabs greyed out?
- How do I see who is using my datasets?
Cause
The Queries and Stats tabs turn on after an ingestion with usage extraction produced usage for that dataset. They stay greyed out when the dataset has no usage statistics, or when no usage-extracting ingestion has run.
Usage statistics are built inside the ingestion source. DataHub Actions does not produce them.
Common reasons usage is missing:
- The source does not support usage, or needs a separate usage recipe. Redshift is one example.
- For Snowflake, the role lacks access to the
SNOWFLAKEdatabase. Usage and lineage readSNOWFLAKE.ACCOUNT_USAGE(QUERY_HISTORY, ACCESS_HISTORY). Without the grant, usage, lineage and tags do not work, and permission errors appear in the ingestion logs. - The
start_timewindow does not cover the period you expect, or no queries ran in it. - Your user lacks the View Dataset Usage privilege.
Solution
-
Check that your source supports usage. Look at the source's capabilities table in the Dataset Usage and Query History guide. Some sources need a separate usage recipe.
-
For Snowflake, grant the ingestion role access to the account usage views:
grant imported privileges on database snowflake to role <role>;
Then check the ingestion logs for permission errors.
-
Check the recipe. In acryl-datahub 1.7.0.20, these Snowflake defaults already turn usage on:
include_usage_stats(true),include_operational_stats(true),include_top_n_queries(true) andtop_n_queries(10). You don't need to set them. Recipes reject unknown keys, so a key that the source doesn't define makes the recipe fail validation. See the Snowflake source for the keys it accepts. -
Check the time window.
start_timeaccepts an absolute UTC time or a relative value such as-30d, measured back fromend_time.end_timetakes only an absolute UTC datetime and defaults to now. It does not accept relative values, soend_time: "-1d"fails validation.bucket_durationdefaults toDAY. If you leavestart_timeunset, it defaults to the last full day. The Snowflake source page lists these settings.
source:
type: snowflake
config:
start_time: "-30d"
To use an absolute time, write it in UTC, for example '2021-07-20T00:00:00Z'. Run the ingestion again after any change.
-
Check the privileges. Viewing dataset usage needs the View Dataset Usage privilege. Seeing the SQL text of top queries also needs View Entity Queries or View All Queries.
-
Check the data through GraphQL. This query uses only fields that exist on
usageStats:
query {
dataset(urn: "YOUR_URN") {
usageStats(range: MONTH) {
buckets {
bucket
duration
}
aggregations {
uniqueUserCount
totalSqlQueries
}
}
}
}
Send it to /api/graphql. See the GraphQL API overview.
Additional Notes
Looker extract_usage_history ingests usage statistics for dashboards. Tableau extract_usage_stats (off by default, experimental) extracts usage statistics for dashboards and charts. Neither is a way to fill dataset usage. To change the Looker usage interval, set extract_usage_history_for_interval (default "30 days"). It is used only when extract_usage_history is true.