Skip to content

Commit

Permalink
Merge branch 'master' into add-visibility-out-of-the-box-into-evictions
Browse files Browse the repository at this point in the history
  • Loading branch information
itisallgood authored Jul 12, 2024
2 parents 7aae9a6 + fca30b1 commit 35c2401
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/configuration/sinks/slack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Alternatively, generate a key by running ``robusta integrations slack`` and set
slack_channel: MY SLACK CHANNEL
max_log_file_limit_kb: <Optional> # (Default: 1000) The maximum allowed file size for "snippets" (in kilobytes) uploaded to the Slack channel. Larger files can be sent to Slack, but they may not be viewable directly within the Slack.
channel_override: DYNAMIC SLACK CHANNEL OVERRIDE (Optional)
investigate_link: true/false # optional, if false no investigate links/buttons will be included in Slack messages
Then do a :ref:`Helm Upgrade <Simple Upgrade>`.

Expand Down
2 changes: 1 addition & 1 deletion src/robusta/core/sinks/slack/slack_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def write_finding(self, finding: Finding, platform_enabled: bool) -> None:
self.slack_sender.send_finding_to_slack(finding, self.params, platform_enabled)

def handle_notification_grouping(self, finding: Finding, platform_enabled: bool) -> None:
# There is a lock over the whole of the method to account:
# There is a lock over the whole of the method:
# 1) to prevent concurrent modifications to group accounting data structures
# 2) to make sure two threads with identical group_key don't create
# two identical messages (of which one would eventually be orphaned and
Expand Down
1 change: 1 addition & 0 deletions src/robusta/core/sinks/slack/slack_sink_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SlackSinkParams(SinkBaseParams):
api_key: str
channel_override: Optional[str] = None
max_log_file_limit_kb: int = 1000
investigate_link: bool = True

@classmethod
def _supports_grouping(cls):
Expand Down
40 changes: 22 additions & 18 deletions src/robusta/integrations/slack/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ def __create_holmes_callback(self, finding: Finding) -> CallbackBlock:
}
)

def __create_finding_header(self, finding: Finding, status: FindingStatus, platform_enabled: bool) -> MarkdownBlock:
def __create_finding_header(
self, finding: Finding, status: FindingStatus, platform_enabled: bool, include_investigate_link: bool
) -> MarkdownBlock:
title = finding.title.removeprefix("[RESOLVED] ")
sev = finding.severity
if finding.source == FindingSource.PROMETHEUS:
Expand All @@ -341,21 +343,22 @@ def __create_finding_header(self, finding: Finding, status: FindingStatus, platf
status_name: str = "👀 *K8s event detected*"
else:
status_name: str = "👀 *Notification*"
if platform_enabled:
if platform_enabled and include_investigate_link:
title = f"<{finding.get_investigate_uri(self.account_id, self.cluster_name)}|*{title}*>"
return MarkdownBlock(
f"""{status_name} {sev.to_emoji()} *{sev.name.capitalize()}*
{title}"""
)

def __create_links(self, finding: Finding):
def __create_links(self, finding: Finding, include_investigate_link: bool):
links: List[LinkProp] = []
links.append(
LinkProp(
text="Investigate 🔎",
url=finding.get_investigate_uri(self.account_id, self.cluster_name),
if include_investigate_link:
links.append(
LinkProp(
text="Investigate 🔎",
url=finding.get_investigate_uri(self.account_id, self.cluster_name),
)
)
)

if finding.add_silence_url:
links.append(
Expand Down Expand Up @@ -484,10 +487,10 @@ def send_finding_to_slack(
FindingStatus.RESOLVED if finding.title.startswith("[RESOLVED]") else FindingStatus.FIRING
)
if finding.title:
blocks.append(self.__create_finding_header(finding, status, platform_enabled))
blocks.append(self.__create_finding_header(finding, status, platform_enabled, sink_params.investigate_link))

if platform_enabled:
blocks.append(self.__create_links(finding))
blocks.append(self.__create_links(finding, sink_params.investigate_link))

if HOLMES_ENABLED:
blocks.append(self.__create_holmes_callback(finding))
Expand Down Expand Up @@ -579,17 +582,18 @@ def send_or_update_summary_message(
"type": "mrkdwn",
"text": source_txt,
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Investigate 🔎",
},
"url": investigate_uri,
},
}
]
)
if sink_params.investigate_link:
blocks[-1]["accessory"] = {
"type": "button",
"text": {
"type": "plain_text",
"text": "Investigate 🔎",
},
"url": investigate_uri,
}
else:
blocks.append(MarkdownBlock(text=source_txt))

Expand Down

0 comments on commit 35c2401

Please sign in to comment.