Area: Governance Sub-Area: Tags
Applies to: OSS + Cloud
Issue
You want to learn how to create tags, apply them to datasets and columns, use them in search and policies, and manage them with code or automation.
You Might Be Asking
- How do I create a tag and apply it to a dataset or a column?
- Can a policy hide assets that carry a sensitive tag?
- How do I manage tags programmatically?
- Does tag propagation copy existing tags?
Cause
This is a video walkthrough. Some statements in the narration were general and need these corrections:
- A policy that targets a tag does not restrict access by itself. DataHub policies only grant privileges. They never deny.
- The video says the "REST API" manages tags. Use the GraphQL mutations or the Python SDK listed below.
Solution
Create a tag
- Open the Tags page. On DataHub Cloud, go to Govern > Tags. On OSS the page is titled Manage Tags.
- Click Create Tag.
- In the Create New Tag modal, enter a tag name (for example,
PII Data) and a description. The name is required. - Save the tag.
To change a tag's color, you need the Edit Tag Color privilege. In GraphQL, use setTagColor.
A tag URN has the form urn:li:tag:<name>.
Apply a tag to a dataset or a column
Use the Add Tags button, then pick your tag in the Add Tags modal. You can tag a dataset or a column (dataset field).
Search by tag
In search, the Tags filter on datasets also matches datasets where the tag is only on a column. Glossary Terms filters work the same way.
Use tags in policies
A Metadata policy can target assets by tag. Resource conditions combine with AND. For example, "resource type dataset AND tagged myTag" means datasets that carry myTag.
Policies only grant privileges. To keep tagged assets from users:
- Remove the grants that give those users access, including the default policies that give everyone view access.
- Turn on view-based access control.
-
OSS: set
VIEW_AUTHORIZATION_ENABLED=trueon GMS (defaultfalse). It gates entity pages. It does not filter search at query time. - Cloud: use Search Access Controls. It filters search results at query time and uses the View Entity privilege. Your DataHub Cloud administrator enables it.
-
OSS: set
Privileges for tags include Edit Tags, Edit Dataset Column Tags, Create Tags, Manage Tags and Edit Tag Color.
Manage tags with code
-
GraphQL: the mutations are
createTag,updateTag,deleteTag,setTagColor,addTag,addTags,batchAddTagsandremoveTag. To tag a column withaddTags, setsubResourceTypetoDATASET_FIELDandsubResourceto the column. -
Python SDK: use
DatasetPatchBuilder(urn).for_field(field_path). It returns a helper withadd_tagandremove_tagfor column tags. A patch makes a targeted change instead of rewriting the whole aspect, which a full aspect write would do. See the patch guide. -
Ingestion: use the
simple_add_dataset_tagstransformer. Puttransformersat the top level of the recipe, next tosourceandsink. Setsemantics: PATCHto keep tags already in DataHub. The default,OVERWRITE, replaces them, so tags added in the UI are lost.
transformers:
- type: simple_add_dataset_tags
config:
semantics: PATCH
tag_urns:
- "urn:li:tag:AutoGenerated"
To apply tags by pattern, use pattern_add_dataset_tags with tag_pattern: {rules: {...}}.
Tag propagation
Tag propagation has no setting on the tag itself. updateTag takes only urn, name, description and ownership.
DataHub Cloud
- You set up tag propagation as an automation under Govern > Automations.
- It copies dataset-level tags only. It skips column tags and tags on anything that is not a dataset.
- It sends tags to downstream datasets and to sibling assets. Options include
include_downstreamsandinclude_siblings(both defaulttrue) andtag_prefixes(default is all tags). - It reacts to tag add and remove events made after the automation is running. Removing a tag also propagates.
- It does not copy tags that already exist. The Initialize action processes no assets for the standard Tag Propagation automation. To propagate an existing tag, remove it and add it again after the automation is running.
- On deployments where Lineage Propagation is enabled, new automations are created as Lineage Propagation. Existing Tag Propagation automations can still be run and edited. If you need column-level or upstream tag propagation, or you don't see the option, contact DataHub Support.
OSS
- OSS has no Automations page. Run the
tag_propagationaction fromacryl-datahub-actions. - Its config has
enabled(defaulttrue) andtag_prefixes(default is all tags). - It reacts to tag add and remove events and propagates to downstream entities.
To see whether a tag was propagated, read attribution.source on the tag association. Do not use associatedUrn. It only references the tagged URN.