44from pydantic import BaseModel
55
66from elementary .messages .block_builders import (
7+ BoldTextBlock ,
78 BoldTextLineBlock ,
89 BulletListBlock ,
910 FactsBlock ,
1011 ItalicTextLineBlock ,
1112 JsonCodeBlock ,
13+ LinkInlineBlocks ,
1214 LinksLineBlock ,
1315 MentionLineBlock ,
1416 NonPrimaryFactBlock ,
3335 TextStyle ,
3436)
3537from elementary .messages .message_body import Color , MessageBlock , MessageBody
38+ from elementary .monitor .alerts .alert import OrchestratorInfo
3639from elementary .monitor .alerts .alert_messages .alert_fields import AlertField
3740from elementary .monitor .alerts .alerts_groups .alerts_group import AlertsGroup
3841from elementary .monitor .alerts .alerts_groups .base_alerts_group import BaseAlertsGroup
4245from elementary .monitor .alerts .model_alert import ModelAlertModel
4346from elementary .monitor .alerts .source_freshness_alert import SourceFreshnessAlertModel
4447from elementary .monitor .alerts .test_alert import TestAlertModel
48+ from elementary .monitor .data_monitoring .alerts .integrations .utils .orchestrator_link import (
49+ create_orchestrator_link ,
50+ )
4551from elementary .monitor .data_monitoring .alerts .integrations .utils .report_link import (
4652 ReportLinkData ,
4753)
@@ -106,6 +112,7 @@ def _get_run_alert_subtitle_block(
106112 suppression_interval : Optional [int ] = None ,
107113 env : Optional [str ] = None ,
108114 links : list [ReportLinkData ] = [],
115+ orchestrator_info : Optional [OrchestratorInfo ] = None ,
109116 ) -> LinesBlock :
110117 summary = []
111118 summary .append ((type .capitalize () + ":" , name ))
@@ -114,16 +121,54 @@ def _get_run_alert_subtitle_block(
114121 summary .append (("Status:" , status or "Unknown" ))
115122 if detected_at_str :
116123 summary .append (("Time:" , detected_at_str ))
124+
125+ subtitle_lines = []
126+
127+ if orchestrator_info and orchestrator_info .job_name :
128+ orchestrator_name = orchestrator_info .orchestrator or "orchestrator"
129+ job_info_text = f"{ orchestrator_info .job_name } (via { orchestrator_name } )"
130+
131+ orchestrator_link = create_orchestrator_link (orchestrator_info )
132+ if orchestrator_link :
133+ job_inlines : List [InlineBlock ] = [
134+ BoldTextBlock (text = "Job:" ),
135+ TextBlock (text = job_info_text + " | " ),
136+ ]
137+ job_inlines .extend (
138+ LinkInlineBlocks (
139+ text = orchestrator_link .text ,
140+ url = orchestrator_link .url ,
141+ icon = orchestrator_link .icon ,
142+ )
143+ )
144+
145+ subtitle_lines .append (LineBlock (inlines = job_inlines ))
146+ else :
147+ summary .append (("Job:" , job_info_text ))
117148 if suppression_interval :
118149 summary .append (("Suppression interval:" , str (suppression_interval )))
119- subtitle_lines = [SummaryLineBlock (summary = summary )]
120150
121- if links :
122- subtitle_lines .append (
123- LinksLineBlock (
124- links = [(link .text , link .url , link .icon ) for link in links ]
151+ subtitle_lines .append (SummaryLineBlock (summary = summary ))
152+
153+ all_links = []
154+
155+ for link in links :
156+ all_links .append ((link .text , link .url , link .icon ))
157+
158+ if orchestrator_info and not orchestrator_info .job_name :
159+ orchestrator_link = create_orchestrator_link (orchestrator_info )
160+ if orchestrator_link :
161+ all_links .append (
162+ (
163+ orchestrator_link .text ,
164+ orchestrator_link .url ,
165+ orchestrator_link .icon ,
166+ )
125167 )
126- )
168+
169+ if all_links :
170+ subtitle_lines .append (LinksLineBlock (links = all_links ))
171+
127172 return LinesBlock (lines = subtitle_lines )
128173
129174 def _get_run_alert_subtitle_links (
@@ -151,6 +196,7 @@ def _get_run_alert_subtitle_blocks(
151196 asset_type = "snapshot" if alert .materialization == "snapshot" else "model"
152197 asset_name = alert .alias
153198 links = self ._get_run_alert_subtitle_links (alert )
199+ orchestrator_info = alert .orchestrator_info
154200 return [
155201 self ._get_run_alert_subtitle_block (
156202 type = asset_type ,
@@ -160,6 +206,7 @@ def _get_run_alert_subtitle_blocks(
160206 suppression_interval = alert .suppression_interval ,
161207 env = alert .env ,
162208 links = links ,
209+ orchestrator_info = orchestrator_info ,
163210 )
164211 ]
165212
0 commit comments