Skip to content

Commit

Permalink
Added rocketchat sink (robusta-dev#1038)
Browse files Browse the repository at this point in the history
* 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
ganeshrvel authored and pavangudiwada committed Nov 6, 2023
1 parent 3a045c3 commit 7b12f4d
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/configuration/sinks/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Sinks Reference
webex
kafka
sinks-development
rocketchat

Robusta can report issues and events in your Kubernetes cluster to various destinations, known as sinks.

Expand Down Expand Up @@ -123,6 +124,11 @@ Click a sink for setup instructions.
:link: kafka
:link-type: doc

.. grid-item-card:: :octicon:`cpu;1em;` Rocket.Chat
:class-card: sd-bg-light sd-bg-text-light
:link: rocketchat
:link-type: doc

.. grid-item-card:: :octicon:`cpu;1em;` Mail
:class-card: sd-bg-light sd-bg-text-light
:link: mail
Expand Down
68 changes: 68 additions & 0 deletions docs/configuration/sinks/rocketchat.rst
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
Binary file added docs/images/rocketchat1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rocketchat2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/robusta/core/model/runner_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from robusta.core.sinks.opsgenie.opsgenie_sink_params import OpsGenieSinkConfigWrapper
from robusta.core.sinks.pagerduty.pagerduty_sink_params import PagerdutyConfigWrapper
from robusta.core.sinks.robusta.robusta_sink_params import RobustaSinkConfigWrapper
from robusta.core.sinks.rocketchat.rocketchat_sink_params import RocketchatSinkConfigWrapper
from robusta.core.sinks.slack.slack_sink_params import SlackSinkConfigWrapper
from robusta.core.sinks.mail.mail_sink_params import MailSinkConfigWrapper
from robusta.core.sinks.telegram.telegram_sink_params import TelegramSinkConfigWrapper
Expand Down Expand Up @@ -43,6 +44,7 @@ class RunnerConfig(BaseModel):
DataDogSinkConfigWrapper,
KafkaSinkConfigWrapper,
MsTeamsSinkConfigWrapper,
RocketchatSinkConfigWrapper,
OpsGenieSinkConfigWrapper,
TelegramSinkConfigWrapper,
WebhookSinkConfigWrapper,
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions src/robusta/core/sinks/rocketchat/rocketchat_sink.py
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 src/robusta/core/sinks/rocketchat/rocketchat_sink_params.py
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
3 changes: 3 additions & 0 deletions src/robusta/core/sinks/sink_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from robusta.core.sinks.opsgenie import OpsGenieSink, OpsGenieSinkConfigWrapper
from robusta.core.sinks.pagerduty import PagerdutyConfigWrapper, PagerdutySink
from robusta.core.sinks.robusta import RobustaSink, RobustaSinkConfigWrapper
from robusta.core.sinks.rocketchat.rocketchat_sink import RocketchatSink
from robusta.core.sinks.rocketchat.rocketchat_sink_params import RocketchatSinkConfigWrapper
from robusta.core.sinks.sink_base import SinkBase
from robusta.core.sinks.sink_config import SinkConfigBase
from robusta.core.sinks.slack import SlackSink, SlackSinkConfigWrapper
Expand All @@ -26,6 +28,7 @@
class SinkFactory:
__sink_config_mapping: Dict[Type[SinkConfigBase], Type[SinkBase]] = {
SlackSinkConfigWrapper: SlackSink,
RocketchatSinkConfigWrapper: RocketchatSink,
RobustaSinkConfigWrapper: RobustaSink,
MsTeamsSinkConfigWrapper: MsTeamsSink,
KafkaSinkConfigWrapper: KafkaSink,
Expand Down
Empty file.
Loading

0 comments on commit 7b12f4d

Please sign in to comment.