Skip to content

Commit a2f0140

Browse files
committed
refactoring holmes
1 parent 988e002 commit a2f0140

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

src/robusta/core/sinks/robusta/dal/supabase_dal.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,3 +753,23 @@ def set_cluster_active(self, active: bool) -> None:
753753
)
754754
except Exception as e:
755755
logging.error(f"Failed to set cluster status active=False error: {e}")
756+
757+
def holmes_slackbot_enabled(
758+
self, account_id: str
759+
) -> bool:
760+
try:
761+
res = self.client.rpc(
762+
"holmes_slackbot_enabled",
763+
{"_account_id": account_id},
764+
).execute()
765+
766+
logging.debug(f"Holmes Slackbot connected {bool(res.data)}")
767+
return bool(res.data)
768+
769+
except Exception as error:
770+
logging.error(
771+
f"Unexpected error rpc holmes_slackbot_enabled."
772+
f"account_id: {account_id}",
773+
exc_info=True,
774+
)
775+
raise error

src/robusta/integrations/slack/sender.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,17 @@ def send_holmes_analysis(
542542
except Exception:
543543
logging.exception(f"error sending message to slack. {title}")
544544

545-
def send_finding_to_slack(
545+
def get_holmes_block(self, platform_enabled: bool, slackbot_enabled) -> Optional[MarkdownBlock]:
546+
if not platform_enabled and not slackbot_enabled:
547+
return MarkdownBlock("_Ask AI questions about this alert, by connecting <https://platform.robusta.dev/create-account|Robusta SaaS> and tagging @holmes._")
548+
elif platform_enabled and not slackbot_enabled:
549+
return MarkdownBlock("_Ask AI questions about this alert, by adding @holmes to your <https://docs.robusta.dev/master/configuration/holmesgpt/index.html#enable-holmes-in-slack-in-the-platform|Slack>._")
550+
elif platform_enabled and slackbot_enabled:
551+
return MarkdownBlock("_Ask AI questions about this alert, by tagging @holmes in a threaded reply_")
552+
return None
553+
554+
555+
def send_finding_to_slack(
546556
self,
547557
finding: Finding,
548558
sink_params: SlackSinkParams,
@@ -601,18 +611,14 @@ def send_finding_to_slack(
601611

602612
blocks.append(DividerBlock())
603613

614+
holmes_block = self.get_holmes_block(platform_enabled, HOLMES_ENABLED)
615+
if holmes_block:
616+
blocks.append(holmes_block)
617+
618+
604619
if len(attachment_blocks):
605620
attachment_blocks.append(DividerBlock())
606621

607-
if not platform_enabled and not HOLMES_ENABLED:
608-
blocks.append(MarkdownBlock("_Ask AI questions about this alert, by connecting <https://platform.robusta.dev/create-account|Robusta SaaS> and tagging @holmes._"))
609-
elif platform_enabled and not HOLMES_ENABLED:
610-
blocks.append(
611-
MarkdownBlock("_Ask AI questions about this alert, by adding @holmes to your <https://docs.robusta.dev/master/configuration/holmesgpt/index.html#enable-holmes-in-slack-in-the-platform|Slack>._"))
612-
elif platform_enabled and HOLMES_ENABLED:
613-
blocks.append(
614-
MarkdownBlock("_Ask AI questions about this alert, by tagging @holmes in a threaded reply_"))
615-
616622
return self.__send_blocks_to_slack(
617623
blocks,
618624
attachment_blocks,
@@ -624,6 +630,7 @@ def send_finding_to_slack(
624630
thread_ts=thread_ts,
625631
)
626632

633+
627634
def send_or_update_summary_message(
628635
self,
629636
group_by_classification_header: List[str],

0 commit comments

Comments
 (0)