Area: Product
Sub-Area: Audit
Applies to: OSS + Cloud
Issue
You need to see who changed metadata and when, review how an entity changed over time, or audit metadata changes for compliance.
You Might Be Asking
- How do I see metadata change history?
- Who changed the dataset description?
- Can I get a previous version of an aspect from GraphQL?
- Can I restore previous metadata versions?
Cause
There is no GraphQL query that returns aspect history. The GraphQL aspects field returns only the current value of an aspect. It takes input: AspectParams, which has only autoRenderOnly: Boolean and aspectNames: [String!]. It returns [RawAspect!], and RawAspect has only aspectName, payload (a JSON string) and renderSpec. It has no version, created, actor or history fields. Queries that pass aspectName or maxCount, or that ask for version or created { time actor }, fail.
DataHub also doesn't keep every version forever. By default, version retention keeps the 20 latest versions of each aspect, so older versions are deleted. See Version retention.
Solution
Use one of these tools, depending on the question.
-
See what changed on an entity: the Timeline CLI. Run:
datahub timeline --urn <urn> -c <category> [-c ...] [--start <ms|Ndaysago>] [--end <ms|Ndaysago>] [--raw] [--verbose]The CLI accepts these categories:
tag,glossary_term,technical_schema,documentation,ownership,domain,structured_property,application,asset_membershipandversioning. The CLI also acceptsowneras an alias forownership. For example, use-c documentationfor description changes. See Timeline API.If you call the Timeline API directly, use the category
OWNERSHIP, notOWNER. Pass the time range asstartTimeandendTimein epoch milliseconds. The server ignoresstartandend, even though the public docs examples show them. -
See who made a change: the Audit Events Search API. This API is a POST at
/audit/search. Query parameters includestartTime(epoch ms, defaults to one day ago),endTime(epoch ms, defaults to now) andsize(default 10). Each event carriestimestamp,actorUrn,sourceIPandeventSource(RESTLI,OPENAPI,GRAPHQLorSSO_SCIM). When more results are available, the response returnsnextScrollId. Thetotalcount is calculated up to 10,000. See Audit Events Search API. -
React to changes as they happen.
- On self-hosted DataHub, change logs go to Kafka. Versioned aspects go to
MetadataChangeLog_Versioned_v1(default retention 7 days). Timeseries aspects go toMetadataChangeLog_Timeseries_v1(default retention 90 days). The topicMetadataChangeLog_v1doesn't exist. See MCP and MCL events. - On DataHub Cloud, you can't access Kafka. Use the Entity Events API for real-time change events.
- On self-hosted DataHub, change logs go to Kafka. Versioned aspects go to
-
Keep long-term history. Because retention deletes old versions, export audit data to an external system if you need it for compliance. Audit events from the search API and the Timeline output are the sources to export.
Restoring a previous version
DataHub has no GraphQL call that returns an old version, so you can't build a restore from GraphQL.
- Run the Timeline CLI for the entity and category to see what changed and when.
- Re-apply the earlier value yourself with the Python emitter. Prefer a targeted patch of the one field you need to change over writing the whole aspect again.
DatahubRestEmitter.emit_mcp(mcp, async_flag=None, emit_mode=None, wait_timeout=timedelta(seconds=3600)) takes a single MetadataChangeProposal or MetadataChangeProposalWrapper. It doesn't accept entity_urn, aspect_name or aspect keyword arguments. Calling it that way raises TypeError.
Version retention may already have deleted the version you want. Check the Timeline output before you plan a restore.
Changing retention on Cloud
On DataHub Cloud, you can't set GMS environment variables or change retention yourself. To change retention, contact DataHub Support.