Skip to content

Commit

Permalink
add promtheus labels to slack message
Browse files Browse the repository at this point in the history
  • Loading branch information
romg67 committed May 21, 2024
1 parent 4494f3a commit 3fe4b33
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/robusta/core/sinks/webhook/webhook_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@ def __write_json(self, finding: Finding, platform_enabled: bool):
else:
break
if self.slack_webhook:
labels = message.get('subject', {}).get('labels')
if labels:
labels_as_text = ", ".join(f"{k}: {v}" for k, v in labels.items())
else:
labels_as_text = None
message = {
"text": f"*Title:* {message['title']}\n"
f"*Description:* {message['description']}\n"
f"*Failure:* {message['failure']}\n"
f"*Aggregation Key:* {message['aggregation_key']}\n"
f"*labels*: {labels_as_text}\n"
}
logging.info(f"message after is {json.dumps(message)}")
try:
r = requests.post(self.url, json=message, headers=self.headers)
r.raise_for_status()
Expand Down

0 comments on commit 3fe4b33

Please sign in to comment.