Complete reference for defining your Data Catalog and Tracking Plan resources using YAML configuration files.
Available Plans
free
starter
growth
enterprise
10 minute read
This guide serves as a detailed reference for the CLI project YAML files that contain definitions of your Data Catalog and Tracking Plan resources.
Overview
In the context of the Rudder CLI (rudder-cli) tool, a project typically consists of a root directory that contains all the project files. Within this root directory, each YAML file can contain definitions for resources of a particular type, for example, events, properties, custom data types, and Tracking Plans.
The location and naming of these YAML files is flexible, as you can store the YAML files anywhere within the project’s root directory or subdirectories.
You can also group some resources of the same type in the same file, allowing structures that can best serve your project’s requirements. For example, you could have:
A events.yaml file in the project’s root directory that defines multiple events.
Another file subdirectory/user-events.yaml that defines addtional events.
The Rudder CLI tool processes all valid YAML files within the project structure to recognize the defined resources.
The following sections detail the specific YAML formats and parameter definitions for each resource type.
Events
You can define one or more events in the YAML file by setting kind to events.
The spec parameter of the YAML file has the following structure:
Additionally, track events (event_type: track) also support the following property:
Property
Type
Description
name Required
String
The track event name. In other words, this parameter corresponds to the event property of the corresponding RudderStack track event.
Example
version:rudder/v0.1kind:eventsmetadata:name:myeventgroupspec:events:- id:product_viewedname:"Product Viewed"event_type:trackdescription:"This event is triggered every time a user views a product."category:"#/categories/event-categories/browsing_category"# Reference to the Browsing category- id:added_to_cartname:"Added To Cart"event_type:trackdescription:"This event is triggered every time the user adds a product to their cart."- id:identifyevent_type:identifydescription:"An event that identifies the user."- id:pageevent_type:page
Event categories
You can define event categories in the YAML file by setting kind to categories.
The spec parameter of the YAML file has the following structure:
Additional validation rules for the property’s values.
Property config
Property
Type
Description
minLength
Integer
Minimum length of the property’s string value.
maxLength
Integer
Maximum length of the property’s string value.
pattern
String
Regular expression that the property’s string values need to match with.
enum
Array of strings
List of all valid values for the property.
Example
version:rudder/v0.1kind:propertiesmetadata:name:ecommerce_propertiesspec:properties:- id:product_idname:"product_id"type:stringdescription:"Unique identifier for the product."propConfig:minLength:3maxLength:64- id:product_namename:"product_name"type:stringdescription:"Name of the product."propConfig:minLength:2maxLength:255- id:product_pricename:"product_price"type:numberdescription:"Price of the product in the store's currency."- id:product_categoryname:"product_category"type:stringdescription:"Category the product belongs to."propConfig:enum:- "clothing"- "electronics"- "home_goods"- "beauty"- "accessories"maxLength:60- id:cart_itemsname:"cart_items"description:"Items present in the cart."type:arraypropConfig:minItems:1uniqueItems:false
Custom data types
You can define custom data types in the YAML file by setting kind to custom-types.
The spec parameter of the YAML file has the following structure:
An array of custom type objects grouped together in the same file.
Custom type definition
Property
Type
Description
id Required
String
Unique identifier for the custom type within the project. This parameter must be unique across all custom types in all the YAML files within the project.
Defines which nested properties should be included when this property is used in the Tracking Plan.
Example
version:rudder/v0.1kind:tpmetadata:name:ecommerce_tracking_planspec:id:ecommerce_tracking_plandisplay_name:"E-commerce Tracking Plan"description:"Tracking plan for an e-commerce application."rules:- type:event_ruleid:product_viewed_ruleevent:$ref:"#/events/myeventgroup/product_viewed"allow_unplanned:falseproperties:- $ref:"#/properties/ecommerce_properties/product_id"required:true- $ref:"#/properties/ecommerce_properties/product_name"required:true- $ref:"#/properties/ecommerce_properties/product_price"required:true- $ref:"#/properties/ecommerce_properties/product_category"required:false- type:event_ruleid:user_registered_ruleevent:$ref:"#/events/myeventgroup/user_registered"allow_unplanned:falseproperties:- $ref:"#/properties/ecommerce_properties/user_profile"# Object propertyrequired:trueproperties:- $ref:"#/properties/ecommerce_properties/personal_info"# Object propertyrequired:trueproperties:- $ref:"#/properties/ecommerce_properties/first_name"required:true- $ref:"#/properties/ecommerce_properties/last_name"required:true- $ref:"#/properties/ecommerce_properties/contact"# Object propertyrequired:trueproperties:# Deepest nesting level in this example- $ref:"#/properties/ecommerce_properties/email"required:true- $ref:"#/properties/ecommerce_properties/phone"required:false
Reference Catalog resources
Definitions in a YAML file can refer to definitions in other files by using the resource reference ($ref) strings — this is useful while defining resources like Tracking Plans which need to be associated with events and properties defined in other files.
Note that references must always start with a # character followed by the path using the / delimiter. The path can point to a unique resource within a project’s file and is expected to have the following components in order:
kind value of the target resource’s file, that is, events, properties, or tp.
metadata.name value of the target resource’s file.
id value of the target resource.
For example, you can refer an event inside a file with metadata.name set to examples and having id as example_id as follows:
- $ref:"#/events/examples/example_id"
Import metadata
When you import resources from a workspace using the import workspace command, the generated YAML files contain special import metadata that tells Rudder CLI how to link local resources to workspace resources.
Structure
The import metadata is located in the metadata.import section of the YAML file:
The metadata.import section contains the following properties:
Property
Type
Description
workspaces Required
Array
Array of workspace import configurations. Each workspace configuration contains the workspace ID and resource mappings.
Workspace configuration
Each workspace configuration in the workspaces array has the following structure:
Property
Type
Description
workspace_id Required
String
The ID of the workspace where resources were imported from.
resources Required
Array
Array of mappings between local resource IDs and their corresponding workspace IDs.
Resource mapping
Each resource mapping in the resources array has the following structure:
Property
Type
Description
local_id Required
String
The local resource ID used within your CLI project. This corresponds to the id field in the resource definition.
remote_id Required
String
The remote resource ID from the workspace where the resource was imported from.
The import metadata serves two key purposes:
Resource linking: Enables Rudder CLI to link local resource definitions to existing workspace resources when you run the apply command.
Workspace-aware operations: Tracks which workspace resources were imported from, allowing you to apply the same project to different workspaces. When you apply a project to a workspace different from the one specified in workspace_id, resources are treated as new resources to be created rather than imported.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.