forked from robusta-dev/robusta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rocketchat sink (robusta-dev#1038)
* Added rocketchat sink * Added rocketchat sink docs * Improved rocketchat message * Added RocketChat docs fixes * Improved rocketchat messaging * Removed the rocketchat file upload message
- Loading branch information
1 parent
3a045c3
commit 7b12f4d
Showing
13 changed files
with
505 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,68 @@ | ||
Rocket.Chat | ||
################# | ||
|
||
Robusta can report issues and events in your Kubernetes cluster to Rocket.Chat. | ||
|
||
.. image:: /images/rocketchat1.png | ||
:width: 600 | ||
|
||
|
||
Prerequisites | ||
------------------------------------------------ | ||
|
||
Before you begin setting up the Rocket.Chat sink, ensure you have the following information ready: | ||
|
||
* Server URL | ||
* Personal Access Token | ||
* User ID | ||
* Channel name | ||
|
||
**Rocket.Chat Server Setup** | ||
|
||
First, you need to set up a Rocket.Chat server. If you haven't done this yet, you can find detailed information on deploying on-prem servers at the following URL: `Rocket.Chat Installation Guide <https://www.rocket.chat/install>`_. | ||
|
||
Or if you prefer using RocketChat's cloud SaaS platform, you can follow the instructions at this URL: `Rocket.Chat Cloud Setup <https://cloud.rocket.chat>`_. | ||
|
||
**Generating Personal Access Token and User ID** | ||
|
||
Follow these steps to generate the required `Personal Access Token` and `User ID`: | ||
|
||
1. Log in to your Rocket.Chat server using your valid username and password. | ||
|
||
2. Click on your avatar and select `My Account` from the menu. | ||
|
||
3. Navigate to `Profile` > `Personal Access Tokens`. | ||
|
||
4. Check the `Ignore Two Factor Authentication` option if enabled. | ||
|
||
5. Fill in the `Add new Personal Access Token` text field and click the `Add` button. | ||
|
||
6. Copy the provided `Personal Access Token` and `User ID` for later use. | ||
|
||
|
||
.. image:: /images/rocketchat2.png | ||
:width: 1000 | ||
|
||
Configuring the Rocket.Chat sink | ||
------------------------------------------------ | ||
|
||
.. admonition:: Add this to your generated_values.yaml | ||
|
||
.. code-block:: yaml | ||
sinks_config: | ||
# Rocket.Chat integration params | ||
- rocketchat_sink: | ||
name: main_rocketchat_sink | ||
user_id: <User ID> | ||
channel: <Rocket.Chat channel> | ||
token: <Personal Access Token> | ||
server_url: <Server URL> | ||
Save the file and run | ||
|
||
.. code-block:: bash | ||
:name: cb-add-rocketchat-sink | ||
helm upgrade robusta robusta/robusta --values=generated_values.yaml | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ version = "0.0.0" | |
description = "" | ||
authors = ["Natan Yellin <[email protected]>"] | ||
packages = [ | ||
{ include = "robusta", from = "src"}, | ||
{ include = "robusta", from = "src" }, | ||
] | ||
|
||
[tool.black] | ||
|
@@ -68,6 +68,7 @@ attrs = "^23.1.0" | |
prometrix = "0.1.10" | ||
hikaru-model-26 = "^1.1.1" | ||
apprise = "^1.5.0" | ||
rocketchat-api = "^1.30.0" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pre-commit = "^2.13.0" | ||
|
This file contains 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
Empty file.
This file contains 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,19 @@ | ||
from robusta.core.reporting.base import Finding | ||
from robusta.core.sinks.rocketchat.rocketchat_sink_params import RocketchatSinkConfigWrapper | ||
from robusta.core.sinks.sink_base import SinkBase | ||
from robusta.integrations.rocketchat.sender import RocketchatSender | ||
|
||
|
||
class RocketchatSink(SinkBase): | ||
def __init__(self, sink_config: RocketchatSinkConfigWrapper, registry): | ||
super().__init__(sink_config.rocketchat_sink, registry) | ||
self.channel = sink_config.rocketchat_sink.channel | ||
self.token = sink_config.rocketchat_sink.token | ||
self.server_url = sink_config.rocketchat_sink.server_url | ||
self.user_id = sink_config.rocketchat_sink.user_id | ||
self.rocketchat_sender = RocketchatSender(token=self.token, channel=self.channel, server_url=self.server_url, user_id=self.user_id, | ||
account_id=self.account_id, cluster_name=self.cluster_name, | ||
signing_key=self.signing_key) | ||
|
||
def write_finding(self, finding: Finding, platform_enabled: bool): | ||
self.rocketchat_sender.send_finding_to_rocketchat(finding, self.params, platform_enabled) |
23 changes: 23 additions & 0 deletions
23
src/robusta/core/sinks/rocketchat/rocketchat_sink_params.py
This file contains 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,23 @@ | ||
from typing import Dict, Optional | ||
|
||
from pydantic import validator | ||
|
||
from robusta.core.sinks.sink_base_params import SinkBaseParams | ||
from robusta.core.sinks.sink_config import SinkConfigBase | ||
|
||
|
||
class RocketchatSinkParams(SinkBaseParams): | ||
channel: str | ||
token: str | ||
user_id: str | ||
server_url: str | ||
|
||
def get_rocketchat_channel(self) -> str: | ||
return self.channel | ||
|
||
|
||
class RocketchatSinkConfigWrapper(SinkConfigBase): | ||
rocketchat_sink: RocketchatSinkParams | ||
|
||
def get_params(self) -> SinkBaseParams: | ||
return self.rocketchat_sink |
This file contains 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
Empty file.
Oops, something went wrong.