Skip to content

Commit

Permalink
add missing import; remove outdated comment; reformat grouping message
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Szefler committed Apr 15, 2024
1 parent 4331279 commit 78c1298
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/robusta/integrations/slack/sender.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import ssl
import tempfile
import time
from datetime import datetime
from itertools import chain
from typing import Any, Dict, List, Set, Tuple
Expand Down Expand Up @@ -415,15 +416,16 @@ def send_or_update_summary_message(
):
"""Create or update a summary message with tabular information about the amount of events
fired/resolved and a header describing the event group that this information concerns."""
# TODO investigate button
now_ts = time.time()

rows = []
n_total_alerts = 0
for key, value in sorted(summary_table.items()):
# key is a tuple of attribute names; value is a 2-element list with
# the number of firing and resolved events.
# the number of firing and resolved notifications.
row = list(str(e) for e in chain(key, value))
rows.append(row)

now_ts = time.time()
n_total_alerts += value[0] + value[1] # count firing and resolved notifications

table_block = TableBlock(headers=finding_summary_header + ["Fired", "Resolved"], rows=rows)
summary_start_utc_dt = datetime.fromtimestamp(summary_start).astimezone(tz.UTC)
Expand All @@ -434,8 +436,11 @@ def send_or_update_summary_message(
f"*Group time range:* <!date^{int(summary_start)}^{{date_num}} {{time}}|{formatted_summary_start}>"
f" to <!date^{int(now_ts)}^{{date_num}} {{time}}|{formatted_now_ts}>"
)
group_by_criteria_str = ", ".join(f"`header`" for header in group_by_classification_header)
blocks = [
MarkdownBlock("👀 Group summary for " + ", ".join(group_by_classification_header)),
MarkdownBlock("👀 Alert summary"),
MarkdownBlock(f"Total alerts: {n_total_alerts}"),
MarkdownBlock(f"Matching criteria: {group_by_criteria_str}"),
LinksBlock(
links=[
LinkProp(
Expand Down

0 comments on commit 78c1298

Please sign in to comment.