This blog walks through approaches to implement custom notifications using SMTP, SendGrid, Azure Logic Apps, and Microsoft Graph API. Using SMTP with Python inside a Databricks notebook, you can generate an Excel report and send it via email whenever a pipeline fails.This blog walks through approaches to implement custom notifications using SMTP, SendGrid, Azure Logic Apps, and Microsoft Graph API. Using SMTP with Python inside a Databricks notebook, you can generate an Excel report and send it via email whenever a pipeline fails.

Custom Email Notifications for Databricks Pipeline Failures

2025/09/30 06:13

When working with Databricks pipelines and workflows, failures are inevitable. While Databricks provides built-in notifications for job failures, these alerts are often not customizable and may not fit specific reporting or formatting needs. A more flexible and cost-effective approach is to set up custom email notifications that include pipeline details and error messages in a structured format, such as an Excel attachment.

This blog walks through approaches to implement custom notifications using SMTP, SendGrid, Azure Logic Apps, and Microsoft Graph API.

Why Custom Notifications?

  • Flexible formatting: Include pipeline metadata, error messages, and runtime details.
  • Attachments: Share structured reports (Excel, CSV, etc.) instead of plain text.
  • Cost efficiency: Avoid additional third-party monitoring solutions.
  • Integration options: Easily plug into existing email infrastructure.

Approach 1: SMTP-Based Notifications

Using SMTP with Python inside a Databricks notebook, you can generate an Excel report and send it via email whenever a pipeline fails.

Example Implementation

import smtplib from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText from email import encoders from io import BytesIO import pandas as pd  #Sample pipeline history df = spark.createDataFrame([ ('pipeline1', 'success', '7min'), ('pipeline1', 'fail', '3min'), ('pipeline1', 'success', '10min') ], ["PipelineName", "Status", "Duration"])  # Convert DataFrame to Excel output = BytesIO()  with pd.ExcelWriter(output, engine='xlsxwriter') as writer:  df_pd = df.toPandas()  df_pd.to_excel(writer, index=False, sheet_name='Sheet1')  workbook = writer.book  worksheet = writer.sheets['Sheet1'] 
# Apply formatting header_format = workbook.add_format({     'bold': True,     'bg_color': '#FFF00',     'border': 1,     'align': 'center',     'valign': 'vcenter' }) for col_num, value in enumerate(df_pd.columns):     worksheet.write(0, col_num, value.upper(), header_format)  cell_format = workbook.add_format({'border': 1}) for row in range(1, len(df_pd) + 1):     for col in range(len(df_pd.columns)):         worksheet.write(row, col, df_pd.iloc[row-1, col], cell_format)  for i, col in enumerate(df_pd.columns):     worksheet.set_column(i, i, 20) output.seek(0)  # Email configuration sender = "[email protected]" receiver = "[email protected]" subject = "Pipeline Execution Report" body = """Hello Team,  Please find the attachment of the latest pipeline report.  Thanks, Pipeline Team"""  msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['Subject'] = subject msg.attach(MIMEText(body, 'plain'))  part = MIMEBase('application', 'vnd.openxmlformats-officedocument.spreadsheetml.sheet') part.set_payload(output.read()) encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="pipeline_report.xlsx"') msg.attach(part)  smtp_server = "smtp.office.com" smtp_port = 587  with smtplib.SMTP(smtp_server, smtp_port) as server:     server.starttls()     server.login(sender, "sender_password")     server.send_message(msg)  print("Email sent successfully with Excel attachment") 

Scheduling Notifications

You can automate the notification trigger by scheduling the notebook:

Option 1: Databricks Jobs

  • Create or edit a Databricks job.
  • Add a task dependency so the notification script runs only if the previous task fails.
  • This ensures error details are captured and reported immediately.

Option 2: Azure Logic Apps

  • Configure a Logic App that listens for pipeline failures.
  • Pass pipeline details and attachments via an API call in JSON format.
  • Logic Apps handle email delivery and retry mechanisms.

Conclusion

While Databricks provides basic failure notifications, extending them with custom SMTP or Logic App workflows ensures:

  • Rich, formatted reports.
  • Team visibility with detailed context.
  • Seamless integration with enterprise communication tools.

This approach is cost-effective, scalable, and easily adaptable for large-scale pipeline monitoring.

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact [email protected] for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Superstate launches an on-chain direct issuance solution, enabling companies to raise funds in stablecoins to issue tokenized shares.

Superstate launches an on-chain direct issuance solution, enabling companies to raise funds in stablecoins to issue tokenized shares.

PANews reported on December 10th that Superstate, led by Compound founder Robert Leshner, announced the launch of "Direct Issuance Programs." This program allows publicly traded companies to raise funds directly from KYC-verified investors by issuing tokenized shares, with investors paying in stablecoins and settling instantly. The service will run on Ethereum and Solana, with the first offering expected to launch in 2026. The program requires no underwriters, complies with SEC regulations, and aims to promote the on-chaining of capital markets.
Share
PANews2025/12/10 21:07
Trump to start final Fed chair interviews beginning with Kevin Warsh

Trump to start final Fed chair interviews beginning with Kevin Warsh

The post Trump to start final Fed chair interviews beginning with Kevin Warsh appeared on BitcoinEthereumNews.com. President Donald Trump will begin the final interviews of candidates for the Federal Reserve chair this week, putting back on track the formal selection process that began this summer. “We’re going to be looking at a couple different people, but I have a pretty good idea of who I want,” Trump said Tuesday night aboard Air Force One to reporters. The interviews by Trump and Treasury Secretary Scott Bessent will begin with former Fed governor Kevin Warsh on Wednesday and also include Kevin Hassett, the director of the National Economic Council, at some point, according to two sources. It restarts the process that was derailed a bit last week when interviews with candidates were abruptly canceled. Trump said recently he knew who he was going to pick to replace current Chair Jerome Powell, and prediction markets overwhelmingly believed it would be Hassett. But his possible selection received some pushback from the markets recently, especially among fixed income investors concerned Hassett would only do Trump’s bidding and keep rates too low even if inflation snaps back. So it’s unclear if these interviews are a sign Trump has changed his mind or just the final stage of the formal process. CNBC first reported in October that Trump had narrowed the candidate list down to five people. Four of those five will be part of these final interviews. The group also includes current Governors Christopher Waller and Michelle Bowman as well as BlackRock fixed income chief Rick Rieder. The Fed will likely lower rates for a third time this year on Wednesday, but Powell, whose term as chair is up in May, is expected to strike a cautious tone at his post-meeting press conference on how much lower the central bank will go next year. The Fed’s latest forecast released in September called…
Share
BitcoinEthereumNews2025/12/10 21:07