Area: Best Practices
Sub-Area: Self-Hosted Infrastructure, Storage, Observability, and Query Logging
Applies to: OSS
Issue
When you self-host DataHub, you run your own search cluster (Elasticsearch or OpenSearch) and your own relational database. DataHub Cloud runs these for you. A self-hosted deployment does not. If you don't set up disk headroom, node metrics and slow query logging, a full disk or an expensive query shows up only as failed writes or slow pages, with no clear cause.
Current DataHub releases support Elasticsearch 8.x and OpenSearch 2.x or 3.x as the search backend. The settings below apply to both engines.
You Might Be Asking
- How much free disk space should I keep on my Elasticsearch or OpenSearch cluster for DataHub?
- What happens when disk usage crosses the watermark thresholds?
- Which index names does DataHub use, so I can turn on slow logs for them?
- How do I turn on slow query logging in PostgreSQL (including Aurora PostgreSQL) for DataHub?
- How do I see node-level health metrics for my search cluster?
Solution
1. Keep disk headroom for reindexing
Elasticsearch and OpenSearch protect themselves with disk watermarks. With the default settings:
- At 85% used (low watermark), the cluster stops allocating new shards to that node.
- At 90% used (high watermark), the cluster moves shards away from that node.
- At 95% used (flood stage), the cluster sets
index.blocks.read_only_allow_deleteon every index that has a shard on that node. DataHub writes to those indices fail.
DataHub needs extra room during upgrades. On every upgrade, the Helm chart runs a system-update job, and that job reindexes search indices when needed (System update and upgrades). For each index it reindexes, DataHub creates a new index named <index>_<timestamp> and copies every document into it. Then it points the alias at the new index and deletes the old one. Until the copy finishes, the cluster holds two copies of that index.
Keep disk usage below the low watermark. On top of that, keep free space at least the size of your largest DataHub index, replicas included. Check usage and index sizes with:
# Watermark settings in effect
GET /_cluster/settings?include_defaults=true&filter_path=*.cluster.routing.allocation.disk
# Disk use per node
GET /_cat/allocation?v&h=node,disk.used,disk.avail,disk.percent,shards
# Largest indices first
GET /_cat/indices?v&s=store.size:desc&h=index,pri,rep,docs.count,store.size
When usage gets close to the low watermark, add disk or nodes. Changing the watermarks only moves the point where writes fail.
2. Watch node-level health metrics
Track heap use, CPU, load and disk per node. Point your monitoring tool at these APIs:
# Cluster health
GET /_cat/health?v
# Per-node summary
GET /_cat/nodes?v&h=name,heap.percent,ram.percent,cpu,load_1m,disk.used_percent
# Full node statistics
GET /_nodes/stats
Common ways to collect them:
- Prometheus and Grafana: run an Elasticsearch exporter, which reads the node stats API and exposes Prometheus metrics.
- Elasticsearch: Elastic Stack Monitoring in Kibana.
- OpenSearch: the Performance Analyzer plugin. On Amazon OpenSearch Service, use the CloudWatch metrics for the domain.
If these calls work in a lower environment but fail in production, compare the credentials, roles and network rules (security groups, VPC policies) between the two environments.
For metrics from DataHub itself (GMS requests and JVM), see Monitoring DataHub.
3. Turn on slow logs for DataHub indices
Slow logs record searches and indexing operations that take longer than a threshold. DataHub uses these index names:
- One search index per entity type, named
<entity>index_v2, for exampledatasetindex_v2,chartindex_v2anddashboardindex_v2. -
graph_service_v1for relationships. -
system_metadata_service_v1for aspect run metadata.
If you set INDEX_PREFIX, every name starts with <prefix>_, for example myprefix_datasetindex_v2 (Environment variables). List the indices first:
GET /_cat/indices/*index_v2*,*graph_service_v1*,*system_metadata_service_v1*?v
Then set the thresholds on them. These are starting values:
PUT /*index_v2*,*graph_service_v1*,*system_metadata_service_v1*/_settings
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
"index.search.slowlog.threshold.query.debug": "2s",
"index.search.slowlog.threshold.query.trace": "500ms",
"index.search.slowlog.threshold.fetch.warn": "1s",
"index.search.slowlog.threshold.fetch.info": "800ms",
"index.indexing.slowlog.threshold.index.warn": "10s",
"index.indexing.slowlog.threshold.index.info": "5s",
"index.indexing.slowlog.threshold.index.debug": "2s",
"index.indexing.slowlog.threshold.index.trace": "500ms"
}
Don't add index.indexing.slowlog.level or index.search.slowlog.level. Elasticsearch 8 removed them and rejects the whole request.
These settings live on the current index, not on the alias. When an upgrade reindexes an index, DataHub builds the new index with its own settings and deletes the old one, so your slow log thresholds are gone for that index. Run the PUT again after each upgrade.
Slow log entries go to the slow log files in each node's log directory. On a managed service, turn on slow log publishing in the service's log settings. Lower the thresholds once you know your baseline.
4. Turn on PostgreSQL slow query logging
On RDS and Aurora PostgreSQL, set these in a custom DB parameter group. On self-managed PostgreSQL, set them in postgresql.conf.
-
log_min_duration_statement = 1000logs every statement that runs longer than 1000 ms. Lower it to 500 once you know your baseline. -
log_statement = ddllogs every schema change. -
shared_preload_librariesmust includepg_stat_statements. A change to this parameter takes effect only after a database restart. -
pg_stat_statements.track = alltracks statements inside functions too.
Check whether the library is already loaded:
SHOW shared_preload_libraries;
After it is loaded, create the extension in the DataHub database. The pg_stat_statements view does not exist until you do:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
Then list the most expensive statements. This query uses the PostgreSQL 13 and later column names. On PostgreSQL 12 and earlier, the columns are total_time and mean_time.
SELECT
query,
calls,
total_exec_time,
mean_exec_time,
stddev_exec_time,
rows
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 20;
DataHub stores metadata in the metadata_aspect_v2 table, so most of its statements hit that table.
On RDS and Aurora PostgreSQL, the console shows the logs under the instance's Logs & events tab. With the AWS CLI, list the log files first, then download one by the name the first command returns:
aws rds describe-db-log-files \
--db-instance-identifier <instance-id>
aws rds download-db-log-file-portion \
--db-instance-identifier <instance-id> \
--log-file-name <LogFileName from the previous output> \
--output text
Roll out in stages
- Apply the logging and metric settings in your lowest environment first.
- Check that logs appear, metrics are visible, and logging overhead doesn't slow anything down.
- Tune the thresholds from what you see there.
- Promote the settings to staging, then production, with change approval at each step.
Additional Notes
None of these settings change DataHub's own configuration. They are search cluster and database settings. Plan a maintenance window before you add pg_stat_statements to shared_preload_libraries in production, because the database restarts.