Area: Observability
Sub-Area: Usage Tracking
Issue
Usage statistics (query counts, user access patterns, popularity metrics) are not appearing for datasets in the DataHub UI. This typically occurs when usage extraction is not enabled in ingestion, insufficient query history is available, or DataHub Actions is not processing usage events.
You Might Be Asking:
- How do I see who's using my datasets?
- Why are usage stats empty?
- How does DataHub track usage?
Solution
- Enable usage extraction in ingestion:
Example for Snowflake. This can be adapted for other data sources/connectors.
source:
type: snowflake
config:
include_usage_stats: true
include_operational_stats: true
# Configure lookback window
start_time: "-30d" # Last 30 days of queries
end_time: "-1d" # Up to yesterday
# Usage extraction options
usage:
include_top_n_queries: true
top_n_queries: 10
- Verify usage data is being ingested:
# Check ingestion logs
datahub ingest -c recipe.yml 2>&1 | grep -i "usage"
# Query usage via GraphQL
query {
dataset(urn: "YOUR_URN") {
usageStats {
buckets {
bucket
duration
metrics {
uniqueUserCount
totalSqlQueries
}
}
}
}
}
- Emit custom usage events:
Example for Snowflake. This can be adapted for other data sources/connectors.
from datahub.emitter.mce_builder import make_dataset_urn
from datahub.metadata.schema_classes import (
DatasetUsageStatisticsClass,
DatasetUsageStatisticsFieldCountsClass
)
usage_stats = DatasetUsageStatisticsClass(
timestampMillis=int(time.time() * 1000),
eventGranularity=TimeWindowSizeClass(unit="DAY", multiple=1),
uniqueUserCount=50,
totalSqlQueries=1000,
topSqlQueries=["SELECT * FROM table LIMIT 10"],
fieldCounts=[
DatasetUsageStatisticsFieldCountsClass(
fieldPath="user_id",
count=500
)
]
)
emitter.emit_mcp(
entity_urn=make_dataset_urn("snowflake", "db.schema.table"),
aspect_name="datasetUsageStatistics",
aspect=usage_stats
)
- Configure usage aggregation:
# In DataHub Actions config
action:
type: "usage_aggregation"
config:
# Aggregate usage data hourly/daily
aggregation_interval: "DAILY"
# Retention period
retention_days: 90
- For BI tools, ensure usage extraction:
Examples for Looker and Tableau. This can be adapted for other BI tools.
# Looker usage
source:
type: looker
config:
extract_usage_history: true
lookback_days: 30
max_threads: 2
# Tableau usage
source:
type: tableau
config:
extract_usage_stats: true
stateful_ingestion:
enabled: true
Additional Notes
Usage statistics depend on query history availability in the source system. Snowflake and BigQuery provide rich query history, while other platforms may have limitations. Usage data aggregates over time windows (daily, weekly, monthly).
Related Documentation
Tags:
usage-statistics, observability, query-history, popularity, access-patterns, metrics, monitoring, user-activity