Data lineage in Knowledge Catalog (formerly Dataplex Universal Catalog) lets you
import OpenLineage events to track and visualize data movement from external
systems. You can unify custom pipeline lineage alongside built-in lineage from
Google Cloud services in a single lineage graph.

## Overview

[OpenLineage](https://openlineage.io/) is an open platform for collecting and
analyzing data lineage information. Using an open standard for lineage data,
OpenLineage captures lineage events from data pipeline components which use an
OpenLineage API to report on runs, jobs, and datasets.

Knowledge Catalog acts as an OpenLineage consumer through the
Data Lineage API. You can import OpenLineage events from external systems
and custom pipelines to display in the Knowledge Catalog web interface
alongside built-in lineage information from Google Cloud services, such
as BigQuery, Dataform, Managed Service for Apache Airflow,
Cloud Data Fusion, and Managed Service for Apache Spark.

To import OpenLineage events that use the
[OpenLineage specification](https://github.com/OpenLineage/OpenLineage/blob/main/spec/OpenLineage.json),
use the
[`ProcessOpenLineageRunEvent`](https://docs.cloud.google.com/knowledge-catalog/docs/reference/data-lineage/rest/v1/projects.locations/processOpenLineageRunEvent.md.txt)
REST API method, and map OpenLineage facets to Data Lineage API attributes.

## OpenLineage integration limitations

- **Supported versions:** The Data Lineage API supports OpenLineage major versions 1 and 2.

- **API actions:** The Data Lineage API endpoint
  [`ProcessOpenLineageRunEvent`](https://docs.cloud.google.com/knowledge-catalog/docs/reference/data-lineage/rest/v1/projects.locations/processOpenLineageRunEvent.md.txt)
  only acts as a **consumer** of OpenLineage messages, not a **producer** . The
  API lets you send lineage information generated by any OpenLineage-compliant
  tool or system into Knowledge Catalog. Some Google Cloud services, such as
  [Managed Service for Apache Spark](https://docs.cloud.google.com/dataproc/docs/guides/spark-lineage),
  [Managed Airflow](https://docs.cloud.google.com/composer/docs/composer-3/lineage-integration.md.txt),
  and [Dataform](https://docs.cloud.google.com/dataform/docs/use-dataplex.md.txt#data-lineage), include
  built-in OpenLineage **producers** that can send events to this endpoint,
  automating lineage capture from those services.

- **Unsupported features:** The Data Lineage API doesn't support the following:

  - Any subsequent OpenLineage release with message format changes
  - `DatasetEvent`
  - `JobEvent`
- **Message size:** Maximum size of a single message is 5 MB.

- **Name length:** Length of each [Fully Qualified Name](https://docs.cloud.google.com/knowledge-catalog/docs/fully-qualified-names.md.txt)
  in inputs and outputs is limited to 4,000 characters.

- **Column-level lineage:** The `ProcessOpenLineageRunEvent` endpoint
  materializes table-level lineage edges only for custom OpenLineage events.
  Column-level lineage graphs are generated only for BigQuery
  SQL transformations and Managed Service for Apache Spark jobs. Custom
  column-level facets are not rendered in the console.

- **Link limits:** [Links](https://docs.cloud.google.com/knowledge-catalog/docs/reference/data-lineage/rest/v1/projects.locations.processes.runs.lineageEvents.md.txt#EventLink)
  are grouped by events, with a maximum of 100 links per event. The maximum
  aggregate number of table-level links is 1,000. For supported automated
  engines that collect column-level lineage, if a message contains more than
  1,500 column-level links, the column-level information is skipped.

- **Graph scope:** Knowledge Catalog displays a lineage graph for each job run, showing the
  inputs and outputs of lineage events. It doesn't support lower-level
  processes such as Spark stages.

## OpenLineage facet attribute mapping

For information about OpenLineage mapping, see [OpenLineage mapping](https://docs.cloud.google.com/knowledge-catalog/docs/openlineage-mapping.md.txt).

## Import an OpenLineage event

If you haven't yet set up OpenLineage, see
[Getting started](https://openlineage.io/getting-started/).

To import an OpenLineage event into Knowledge Catalog, call the API method
[`ProcessOpenLineageRunEvent`](https://docs.cloud.google.com/knowledge-catalog/docs/reference/data-lineage/rest/v1/projects.locations/processOpenLineageRunEvent.md.txt).

### C#


### C#


Before trying this sample, follow the C# setup instructions in the
[Data Lineage quickstart using
client libraries](https://docs.cloud.google.com/knowledge-catalog/docs/track-lineage-quickstart).


For more information, see the
[Data Lineage C# API
reference documentation](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.DataCatalog.Lineage.V1/latest).


To authenticate to Data Lineage, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```c#
using Google.Cloud.DataCatalog.Lineage.V1;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedLineageClientSnippets
{
    /// <summary>Snippet for ProcessOpenLineageRunEvent</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void ProcessOpenLineageRunEventRequestObject()
    {
        // Create client
        LineageClient lineageClient = LineageClient.Create();
        // Initialize request argument(s)
        ProcessOpenLineageRunEventRequest request = new ProcessOpenLineageRunEventRequest
        {
            Parent = "",
            OpenLineage = new Struct(),
        };
        // Make the request
        ProcessOpenLineageRunEventResponse response = lineageClient.ProcessOpenLineageRunEvent(request);
    }
}
```

<br />

### Go


### Go


Before trying this sample, follow the Go setup instructions in the
[Data Lineage quickstart using
client libraries](https://docs.cloud.google.com/knowledge-catalog/docs/track-lineage-quickstart).


For more information, see the
[Data Lineage Go API
reference documentation](https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1).


To authenticate to Data Lineage, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```go

//go:build examples

package main

import (
	"context"

	lineage "cloud.google.com/go/datacatalog/lineage/apiv1"
	lineagepb "cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := lineage.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &lineagepb.ProcessOpenLineageRunEventRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/datacatalog/lineage/apiv1/lineagepb#ProcessOpenLineageRunEventRequest.
	}
	resp, err := c.ProcessOpenLineageRunEvent(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
```

<br />

### Java


### Java


Before trying this sample, follow the Java setup instructions in the
[Data Lineage quickstart using
client libraries](https://docs.cloud.google.com/knowledge-catalog/docs/track-lineage-quickstart).


For more information, see the
[Data Lineage Java API
reference documentation](https://docs.cloud.google.com/java/docs/reference/google-cloud-datalineage/latest/overview).


To authenticate to Data Lineage, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```java
import com.google.cloud.datacatalog.lineage.v1.LineageClient;
import com.google.cloud.datacatalog.lineage.v1.ProcessOpenLineageRunEventRequest;
import com.google.cloud.datacatalog.lineage.v1.ProcessOpenLineageRunEventResponse;
import com.google.protobuf.Struct;

public class SyncProcessOpenLineageRunEvent {

  public static void main(String[] args) throws Exception {
    syncProcessOpenLineageRunEvent();
  }

  public static void syncProcessOpenLineageRunEvent() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (LineageClient lineageClient = LineageClient.create()) {
      ProcessOpenLineageRunEventRequest request =
          ProcessOpenLineageRunEventRequest.newBuilder()
              .setParent("parent-995424086")
              .setOpenLineage(Struct.newBuilder().build())
              .setRequestId("requestId693933066")
              .build();
      ProcessOpenLineageRunEventResponse response =
          lineageClient.processOpenLineageRunEvent(request);
    }
  }
}
```

<br />

### Python


### Python


Before trying this sample, follow the Python setup instructions in the
[Data Lineage quickstart using
client libraries](https://docs.cloud.google.com/knowledge-catalog/docs/track-lineage-quickstart).


For more information, see the
[Data Lineage Python API
reference documentation](https://docs.cloud.google.com/python/docs/reference/lineage/latest).


To authenticate to Data Lineage, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import datacatalog_lineage_v1


def sample_process_open_lineage_run_event():
    # Create a client
    client = datacatalog_lineage_v1.LineageClient()

    # Initialize request argument(s)
    request = datacatalog_lineage_v1.ProcessOpenLineageRunEventRequest(
        parent="parent_value",
    )

    # Make the request
    response = client.process_open_lineage_run_event(request=request)

    # Handle the response
    print(response)

```

<br />

### Ruby


### Ruby


Before trying this sample, follow the Ruby setup instructions in the
[Data Lineage quickstart using
client libraries](https://docs.cloud.google.com/knowledge-catalog/docs/track-lineage-quickstart).


For more information, see the
[Data Lineage Ruby API
reference documentation](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-data_catalog-lineage/latest).


To authenticate to Data Lineage, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```ruby
require "google/cloud/data_catalog/lineage/v1"

##
# Snippet for the process_open_lineage_run_event call in the Lineage service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::DataCatalog::Lineage::V1::Lineage::Client#process_open_lineage_run_event.
#
def process_open_lineage_run_event
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::DataCatalog::Lineage::V1::Lineage::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::DataCatalog::Lineage::V1::ProcessOpenLineageRunEventRequest.new

  # Call the process_open_lineage_run_event method.
  result = client.process_open_lineage_run_event request

  # The returned object is of type Google::Cloud::DataCatalog::Lineage::V1::ProcessOpenLineageRunEventResponse.
  p result
end
```

<br />

### REST

To import an OpenLineage event, use the
[`processOpenLineageRunEvent` method](https://docs.cloud.google.com/knowledge-catalog/docs/reference/data-lineage/rest/v1/projects.locations/processOpenLineageRunEvent.md.txt).


Before using any of the request data,
make the following replacements:

- `PROJECT_ID`: your Google Cloud project ID.
- `LOCATION_ID`: the Google Cloud location, such as `us-central1`.


HTTP method and URL:

```
POST https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID:processOpenLineageRunEvent
```


Request JSON body:

```
{
  "eventTime": "2023-04-04T13:21:16.098Z",
  "eventType": "COMPLETE",
  "inputs": [
    {
      "name": "somename",
      "namespace": "customnamespace"
    }
  ],
  "job": {
    "name": "somename",
    "namespace": "customnamespace"
  },
  "outputs": [
    {
      "name": "somename",
      "namespace": "customnamespace"
    }
  ],
  "producer": "someproducer",
  "run": {
    "runId": "somerunid"
  },
  "schemaURL": "https://openlineage.io/spec/1-0-5/OpenLineage.json#/$defs/RunEvent"
}
```

To send your request, expand one of these options:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID:processOpenLineageRunEvent"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Save the request body in a file named `request.json`,
and execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://datalineage.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID:processOpenLineageRunEvent" | Select-Object -Expand Content
```

You should receive a JSON response similar to the following:

```
{
  "process": "projects/my-project/locations/us-central1/processes/my-process",
  "run": "projects/my-project/locations/us-central1/processes/my-process/runs/my-run",
  "lineageEvents": [
    "projects/my-project/locations/us-central1/processes/my-process/runs/my-run/lineageEvents/my-lineage-event"
  ]
}
```

<br />

## Tools for sending OpenLineage messages

To simplify sending events to the Data Lineage API, you can use various
tools and libraries:

- **Google Cloud client libraries for Data Lineage:** Google provides client libraries to interact with the Data Lineage API programmatically. For installation instructions, see [Client libraries](https://docs.cloud.google.com/knowledge-catalog/docs/reference/libraries.md.txt).
- **Google Cloud Java Producer Library:** Google provides an open-source Java library to help construct and send OpenLineage events to the Data Lineage API. For more information, see the blog post [Producer java library for Data Lineage is now open source](https://opensource.googleblog.com/2025/01/producer-java-library-for-data-lineage-is-now-open-source.html). The library is available on [GitHub](https://github.com/GoogleCloudPlatform/data-lineage-producer-java-library) and [Maven](https://central.sonatype.com/namespace/com.google.cloud.datalineage).
- **OpenLineage GCP Transport:** For Java-based OpenLineage producers, a dedicated [GcpLineage Transport](https://github.com/OpenLineage/OpenLineage/tree/main/client/java/transports-gcplineage) is available. It simplifies integration with Data Lineage API, by minimizing the code needed for sending events to Data Lineage API. The `GcpLineageTransport` can be configured as the event sink for any existing OpenLineage producer such as Airflow, Spark, and Flink. For more information and examples, see [GcpLineage](https://openlineage.io/docs/integrations/spark/configuration/transport/#gcplineage).

## Analyze information from OpenLineage

To analyze the imported OpenLineage events, see
[View lineage graphs in Knowledge Catalog UI](https://docs.cloud.google.com/knowledge-catalog/docs/use-lineage.md.txt#view-lineage).

## Stored OpenLineage facet data

The Data Lineage API doesn't store all facets data from the OpenLineage
messages. The Data Lineage API stores the following facet fields:

- `spark_version`
  - `openlineage-spark-version`
  - `spark-version`
- all `spark.logicalPlan.*`
- `environment-properties` (custom Google Cloud lineage facet)
  - `origin.sourcetype` and `origin.name`
  - `spark.app.id`
  - `spark.app.name`
  - `spark.batch.id`
  - `spark.batch.uuid`
  - `spark.cluster.name`
  - `spark.cluster.region`
  - `spark.job.id`
  - `spark.job.uuid`
  - `spark.project.id`
  - `spark.query.node.name`
  - `spark.session.id`
  - `spark.session.uuid`

The Data Lineage API stores the following information:

- `eventTime`
- `run.runId`
- `job.namespace`
- `job.name`

## What's next

- Learn more about [data lineage with Managed Service for Apache Spark](https://docs.cloud.google.com/managed-spark/docs/guides/data-lineage.md.txt) and [Hive data lineage](https://docs.cloud.google.com/managed-spark/docs/guides/hive-lineage.md.txt) integrations.
- Try it in an interactive lab: [Capture and Explore Data Updates With Data Lineage and OpenLineage](https://www.skills.google/focuses/133555?catalog_rank=%7B%22rank%22:1,%22num_filters%22:0,%22has_search%22:true%7D&parent=catalog)