cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Lakeflow connect Ingestion pipeline notification for gateway pipeline

srikanthp24
New Contributor III

Hi Guys,

As you guys know that when we are building lake flow connect ingestion pipeline in UI. The pipeline consist both gateway pipeline and ingestion pipeline together. We have notification for the ingestion pipeline but not for gateway pipeline. I would like to track or keep an on gateway pipeline, If it fail I need to get the email alert. How we can achiever this. Can anybody face similer problem. the UI looks like as below ss

srikanthp24_0-1788542943980.png

 

6 REPLIES 6

Ashwin_DSA
Databricks Employee
Databricks Employee

Hi @srikanthp24,

Yeah... this is something others have run into as well.

When you create a Lakeflow Connect ingestion pipeline via the UI wizard, the "Schedules and notifications" step (step 6) only configures alerts for that pipeline. The gateway pipeline gets created alongside it, but the wizard does not surface a notification option for it. The good news is that the gateway is just a regular Lakeflow pipeline under the hood, so you can absolutely set up failure alerts on it. You just need to do it as a separate step after the wizard finishes.

The easiest option is to add notifications through the pipeline UI. Once your pipeline is created, go to Jobs & Pipelines in the sidebar and find your gateway pipeline (it will be named the one you entered in the "Gateway" field during setup). Open it, click into the pipeline settings, and you will see a Notifications section. Click "Add notification", enter your email address, and select the failure events you care about (such as "on update failure" or "on fatal failure"). Save, and you are done. The docs walk through this here: Add email notifications for pipeline events.

If you prefer a programmatic approach, just send a PUT request to /api/2.0/pipelines/{gateway_pipeline_id} with a body like this:

{
  "notifications": [
    {
      "email_recipients": ["your-email@example.com"],
      "alerts": [
        "on-update-failure",
        "on-update-fatal-failure",
        "on-flow-failure"
      ]
    }
  ]
}

Or with the Databricks CLI:

databricks pipelines update --pipeline-id <gateway_pipeline_id> --json '{
  "notifications": [
    {
      "email_recipients": ["your-email@example.com"],
      "alerts": ["on-update-failure", "on-update-fatal-failure", "on-flow-failure"]
    }
  ]
}'

You can grab the gateway pipeline ID from the pipeline details page in the UI. More details on this are in the Common pipeline maintenance tasks doc.

If you manage pipelines with DABs, you can define notifications directly in the gateway pipeline's YAML definition so they are version-controlled from the start:

pipelines:
  gw_pipeline:
    name: 'my-gateway'
    continuous: true
    notifications:
      - email_recipients:
          - "team@example.com"
        alerts:
          - "on-update-failure"
          - "on-update-fatal-failure"
          - "on-flow-failure"
    gateway_definition:
      connection_name: ${var.connection_name}
      gateway_storage_catalog: ${var.staging_catalog}
      gateway_storage_schema: ${var.staging_schema}

The SQL Server pipeline bundle examples in the docs actually show this as a commented-out option on the ingestion pipeline. The same block works on the gateway pipeline definition too.

As a starting point, navigate to your gateway pipeline in Jobs & Pipelines, open its settings, and add your email notification there. It takes about 30 seconds and covers most use cases. If you want something more automated or integrated into your deployment workflow, go with the API or DABs approach.

Hope this helps. Let us know if you run into any issues getting it set up.

If this answer resolves your question, could you mark it as โ€œAccept as Solutionโ€? That helps other users quickly find the correct fix.

Regards,
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***

Hello @Ashwin_DSA,

I have checked I didn't find out the UI option for the notification option for the gateway pipeline. I don't see any setting option in the gateway ingestion pipeline and also we don't have any edit options. It would be great If you can give me insights. 
Could you please DAB approach in detail. I have never implemented DAB before.

data_pulse
New Contributor III

Hi @srikanthp24 

Yes, the solution mentioned by @Ashwin_DSA is the mechanism currently available is either with DABs (preferred)/ CLI based as the UI doesn't yet allow configuring notifications at pipeline level.

One caveat is that, even after configuring the notifications using any of the above ways, they do not appear in the Gateway pipeline UI as they do for a standard CDC pipeline. However, if you open the pipeline settings YAML, you can see that the notifications are configured correctly.

data_pulse_0-1788785882994.png

The Databricks docs could also be updated to call out this caveat, since the notifications are configured successfully but are not currently visible in the Gateway pipeline UI.

 

data_pulse
New Contributor III

@srikanthp24 

If Asset bundles weren't configured yet, the practical feasible approach is via Databricks REST API calls.

Follow the below to update via API call by calling it from a Notebook to configure notifications. Add the Gateway Pipeline Id and Email's in the mentioned places to run the below.

import requests
import json
import copy

gateway_pipeline_id = ""  ## --> Add your Gateway PipelineId

host = spark.conf.get("spark.databricks.workspaceUrl")
token = (
    dbutils.notebook.entry_point
    .getDbutils()
    .notebook()
    .getContext()
    .apiToken()
    .get()
)

url = f"https://{host}/api/2.0/pipelines/{gateway_pipeline_id}"

headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json"
}


get_response = requests.get(url, headers=headers)
get_response.raise_for_status()

current_config = get_response.json()

payload = copy.deepcopy(current_config["spec"])
payload.pop("id", None)

payload["notifications"] = [
    {
        "email_recipients": [
            "----"  ## --> Add the Email here to get the notificaitons
        ],
        "alerts": [
            "on-update-failure",
            "on-update-fatal-failure",
            "on-flow-failure"
        ]
    }
]


if current_config.get("run_as"):
    payload["run_as"] = current_config["run_as"]

if current_config.get("last_modified"):
    payload["expected_last_modified"] = current_config["last_modified"]


response = requests.put(
    url,
    headers=headers,
    json=payload
)

print("Status Code:", response.status_code)

if response.content:
    print(json.dumps(response.json(), indent=2))

Migrating to Asset bundles would incur few changes to your code base and CI/CD pipelines but in the Interim, can try above work around.

Hey @data_pulse ,

As I mentioned my pipeline now created from UI. So, In the prod also I should create in similar way and write this notification code and run as separate job right ?
Is my understanding correct ?

data_pulse
New Contributor III

@srikanthp24 

As mentioned earlier, The UI currently doesn't allow to configure notifications. The work arounds suggested are :

  • DAB - In Asset bundles, can declare the Yaml constructs with all the config along with notifications and deploy via CI/CD.  This is bit comprehensive and time consuming effort currently in your use case.
  • Databricks API Call: Just run a one off code manually (The one I replied earlier) by copying and pasting it into a notebook in the Prod workspace -> Add the Gateway Pipeline Id (In the place mentioned) along with Email -> Attach the notebook to any Interactive Cluster/Serverless -> Run it. Once the API call returns a response code as 200 in the output, it means successful and notifications are added to it. Alternatively, Can run that notebook via JOB cluster as well.