-
Notifications
You must be signed in to change notification settings - Fork 306
New custom slack sink, slack_sink_preview #1789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
ce49b90
WIP
aantn 96a69e2
Update sender.py
aantn 0f3710f
Update sender.py
aantn cdec3f7
Update sender.py
aantn 7ff23d6
Update sender.py
aantn 26ed319
Update sender.py
aantn ef3214d
Update sender.py
aantn d79a00d
Update sender.py
aantn 64bafc5
Update sender.py
aantn 787846a
incorporate feedback from igor
aantn c693938
Merge branch 'master' into claude-slack
aantn d72e001
add templating
aantn c4866c3
remove unused code
aantn 092f0c8
add logs
aantn 8c1a9a8
simplify code - always use jinja
aantn 9b15ca1
add legacy option
aantn 6bafca4
Merge branch 'master' into claude-slack
Avi-Robusta 9281648
bugfix sending to slack
Avi-Robusta 92c1b76
fixing template
Avi-Robusta 4e6b055
refactoring code
Avi-Robusta abe1c74
saving progress
Avi-Robusta cca0d57
added tests
Avi-Robusta ea81979
refactoring changes
Avi-Robusta 5df775d
misc changes
Avi-Robusta ed0178c
changess
Avi-Robusta 567372c
working version
Avi-Robusta 317fbf4
refactor send finding to slack
Avi-Robusta bb5d1c2
added space
Avi-Robusta 181adc1
removing unneeded code atm
Avi-Robusta d4a85a1
refactor
Avi-Robusta edd0cbd
fixing
Avi-Robusta 4650e18
docs update
Avi-Robusta ba20164
updated tests
Avi-Robusta c468f5a
bugfixes and header support
Avi-Robusta fa8a68e
fixed mentions
Avi-Robusta fcad848
added channel override test
Avi-Robusta b1dda3b
refactoring, removing useless changes
Avi-Robusta a73bf41
Merge branch 'master' into claude-slack
Avi-Robusta 3c1f709
refactoring sender
Avi-Robusta 57f094c
remove unneeded code
Avi-Robusta 7b9daf2
added additional features
Avi-Robusta 6546ba5
changed manual tests
Avi-Robusta 640ae37
add aggregation key
Avi-Robusta 1a7ee23
pr changes
Avi-Robusta e5094c4
added fingerprint to template
Avi-Robusta 24d32c7
Merge branch 'master' into claude-slack
arikalon1 052d6f4
Merge branch 'master' into claude-slack
Avi-Robusta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Slack Message Templates | ||
|
|
||
| This directory contains the Jinja2 templates used to render Slack messages. | ||
|
|
||
| ## How Templates Work | ||
|
|
||
| Slack messages are rendered using [Jinja2](https://jinja.palletsprojects.com/) templates. Each template produces one or more Slack Block Kit blocks in JSON format. | ||
|
|
||
| Templates are separated by double newlines (`\n\n`) to indicate separate blocks. Each block must be valid JSON that conforms to the [Slack Block Kit](https://api.slack.com/block-kit) format. | ||
|
|
||
| ## Available Templates | ||
|
|
||
| - `header.j2`: The header section of alert notifications, including title and metadata | ||
|
|
||
| ## Customizing Templates | ||
|
|
||
| Users can customize templates in the Robusta configuration by providing their own template content: | ||
|
|
||
| ```yaml | ||
| sinks: | ||
| slack: | ||
| slack_sink: | ||
| name: slack | ||
| slack_channel: "#alerts" | ||
| api_key: "${SLACK_TOKEN}" | ||
| custom_templates: | ||
| header.j2: | | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "{{ status_emoji }} *CUSTOM ALERT: {{ title }}*" | ||
| } | ||
| } | ||
|
|
||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": ":bell: {{ alert_type }} on cluster {{ cluster_name }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "{{ severity_emoji }} {{ severity }}" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## Template Variables | ||
|
|
||
| Each template has access to different variables. Here are the variables available in the `header.j2` template: | ||
|
|
||
| | Variable | Description | | ||
| |----------|-------------| | ||
| | `title` | The alert title | | ||
| | `status_text` | "Firing" or "Resolved" | | ||
| | `status_emoji` | "⚠️" (for firing) or "✅" (for resolved) | | ||
| | `severity` | Alert severity (e.g., "Warning", "Critical") | | ||
| | `severity_emoji` | Emoji for the severity level | | ||
| | `alert_type` | "Alert", "K8s Event", or "Notification" | | ||
| | `cluster_name` | The name of the cluster | | ||
| | `platform_enabled` | Boolean indicating if Robusta platform is enabled | | ||
| | `include_investigate_link` | Boolean indicating if investigate link should be included | | ||
| | `investigate_uri` | URI for investigation | | ||
| | `resource_text` | Resource identifier (e.g., "Pod/namespace/name") | | ||
| | `resource_emoji` | Emoji for the resource type | | ||
| | `finding` | The complete finding object as JSON | | ||
|
|
||
| ## Fallback Behavior | ||
|
|
||
| If Jinja2 is not available, a built-in fallback implementation will be used that produces the same output as the default template. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Slack message templates package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {# Default template for Slack message headers #} | ||
| {# This creates a JIRA-style header with title and context blocks #} | ||
|
|
||
| {# First create the title block with status #} | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "{{ status_emoji }} *[{{ status_text }}] {% if platform_enabled and include_investigate_link %}<{{ investigate_uri }}|{{ title }}>{% else %}{{ title }}{% endif %}*" | ||
| } | ||
| } | ||
|
|
||
| {# Then create the context block with metadata #} | ||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": ":bell: Type: {{ alert_type }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": "{{ severity_emoji }} Severity: {{ severity }}" | ||
| }, | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": ":globe_with_meridians: Cluster: {{ cluster_name }}" | ||
| } | ||
| {% if resource_text %} | ||
| ,{ | ||
| "type": "mrkdwn", | ||
| "text": "{{ resource_emoji }} Resource: {{ resource_text }}" | ||
| } | ||
| {% endif %} | ||
| ] | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.