Skip to content

Commit

Permalink
[MAIN-1909] Severity improvements (#1512)
Browse files Browse the repository at this point in the history
* added additional severity_maps

* added custom severity mapping

* update severity map

* removed log

* added docs for custom severity

---------

Co-authored-by: arik <[email protected]>
  • Loading branch information
Avi-Robusta and arikalon1 authored Aug 1, 2024
1 parent 83cb34f commit 853dcdf
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/setup-robusta/additional-settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ For example:
- source: "job_name"
target: "job"
Mapping Custom Alert Severity
----------------
To correctly map your custom alert severity, you need to add ``custom_severity_map``. The values for each alert should be: high, medium, low, info, and debug.

For example:

.. code-block:: yaml
globalConfig:
custom_severity_map:
devs_high: high
ops_high: high
devs_low: low
Two-way Interactivity
------------------------
Expand Down
1 change: 1 addition & 0 deletions helm/robusta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ globalConfig:
account_id: ""
signing_key: ""
custom_annotations: []
custom_severity_map: {}

# see https://docs.robusta.dev/master/user-guide/configuration/additional-settings.html#relabel-prometheus-alerts
alertRelabel: []
Expand Down
14 changes: 14 additions & 0 deletions src/robusta/integrations/prometheus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,26 @@

SEVERITY_MAP = {
"critical": FindingSeverity.HIGH,
"high": FindingSeverity.HIGH,
"medium": FindingSeverity.MEDIUM,
"error": FindingSeverity.MEDIUM,
"warning": FindingSeverity.LOW,
"low": FindingSeverity.LOW,
"info": FindingSeverity.INFO,
"debug": FindingSeverity.DEBUG,
}


def update_severity_map(global_config):
try:
global SEVERITY_MAP
custom_severity_map = global_config.get("custom_severity_map", {})
for key in custom_severity_map.keys():
SEVERITY_MAP[key] = FindingSeverity.from_severity(custom_severity_map[key].upper())
except:
logging.exception("Failed to map custom severities")


# for parsing incoming data
class PrometheusAlert(BaseModel):
endsAt: datetime
Expand Down
1 change: 1 addition & 0 deletions src/robusta/model/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __init__(
self.default_sinks = default_sinks
self.triggers_to_playbooks = defaultdict(list)
self.global_config = global_config

for playbook_def in active_playbooks:
# Merge playbooks params with global params and default sinks
if not playbook_def.sinks:
Expand Down
3 changes: 3 additions & 0 deletions src/robusta/runner/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
GitRepo,
GitRepoManager,
)
from robusta.integrations.prometheus.models import update_severity_map
from robusta.integrations.receiver import ActionRequestReceiver
from robusta.integrations.scheduled.playbook_scheduler_manager_impl import PlaybooksSchedulerManagerImpl
from robusta.integrations.scheduled.trigger import ScheduledTriggerEvent
Expand Down Expand Up @@ -195,6 +196,8 @@ def __reload_playbook_packages(self, change_name):
cluster_provider.init_provider_discovery()
self.registry.set_global_config(runner_config.global_config)
self.registry.set_relabel_config(runner_config.alert_relabel)
update_severity_map(runner_config.global_config)

action_registry = ActionsRegistry()
# reordering playbooks repos, so that the internal and default playbooks will be loaded first
# It allows to override these, with playbooks loaded afterwards
Expand Down

0 comments on commit 853dcdf

Please sign in to comment.