Skip to content

Commit

Permalink
Merge branch 'master' into main-2806_ai_output_customization
Browse files Browse the repository at this point in the history
  • Loading branch information
nherment authored Jan 28, 2025
2 parents a5aa566 + 8b2710c commit 67e4378
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 28 deletions.
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@
"tutorials/playbook-track-secrets.html": "/master/playbook-reference/kubernetes-examples//playbook-track-secrets.html",
"tutorials/alert-remediation.html": "/master/playbook-reference/prometheus-examples/alert-remediation.html",
"tutorials/alert-custom-enrichment.html": "/master/playbook-reference/prometheus-examples/alert-custom-enrichment.html",
"catalog/sinks/slack.html": "/master/configuration/sinks/slack.html"


"catalog/sinks/slack.html": "/master/configuration/sinks/slack.html",
"user-guide/sinks-configuration.html": "master/notification-routing/routing-with-scopes.html"
}


Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Robusta can receive alerts from many sources and send them to many destinations.

.. grid-item-card:: :octicon:`book;1em;` Sinks (Destinations)
:class-card: sd-bg-light sd-bg-text-light
:link: configuring-sinks
:link: sinks/index
:link-type: doc

Send notifications from Robusta to 15+ integrations like Slack, MS Teams, and Email.
Expand Down
4 changes: 2 additions & 2 deletions docs/help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ CRD issues
This is often a CRD issue which can be fixed by enabling server-side apply option as shown below. Check out `this blog <https://blog.ediri.io/kube-prometheus-stack-and-argocd-25-server-side-apply-to-the-rescue>`_ to learn more.

.. image:: /images/Argocd_crd_issue_fix.png
:width: 400
:align: center
:width: 400
:align: center

.. details:: one or more objects failed to apply... CustomResourceDefinition.apiextensions.k8s.io "prometheusagents.monitoring.coreos.com" is invalid

Expand Down
11 changes: 11 additions & 0 deletions docs/notification-routing/disable-oomkill-notifications.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Disable "OOMKill" Notifications
===================================

Configure Robusta to not send OOMKill notifications by disabling the built-in OOMKill playbook.

.. code-block:: yaml
disabledPlaybooks:
- PodOOMKill
Similarly you can to disable any built-in notification using the name of the playbook. Find all the built-in playbooks `here <https://github.com/robusta-dev/robusta/blob/master/helm/robusta/values.yaml#L113>`_ and `here <https://github.com/robusta-dev/robusta/blob/master/helm/robusta/values.yaml#L169>`_
15 changes: 15 additions & 0 deletions docs/notification-routing/excluding-resolved.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Exclude "Resolved" Notifications
===================================

Configure Robusta to not send notifications for issues that are resolved. This helps you reduce noise and focus on just firing alerts

.. code-block:: yaml
sinksConfig:
- slack_sink:
name: high_severity_sink
slack_channel: high-severity-notifications
api_key: secret-key
scope:
exclude:
- title: ".*[RESOLVED].*"
2 changes: 2 additions & 0 deletions docs/notification-routing/notification-routing-examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ Routing Cookbook
routing-to-multiple-slack-channels
routing-exclusion
routing-by-severity
excluding-resolved
disable-oomkill-notifications

In this section you'll find example configurations for common routing patterns.
4 changes: 2 additions & 2 deletions helm/robusta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,11 @@ platformPlaybooks:

- name: "IngressChangeTracking"
triggers:
- on_ingress_all_changes: {}
- on_kubernetes_resource_operation:
resources: ["ingress"]
actions:
- resource_babysitter: {}
- customise_finding:
title: Ingress Changes
aggregation_key: IngressChange
sinks:
- "robusta_ui_sink"
Expand Down
50 changes: 44 additions & 6 deletions playbooks/robusta_playbooks/prometheus_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random
import string
from datetime import datetime
from typing import Dict, Optional
from typing import Dict, List, Optional

import requests

Expand All @@ -14,13 +14,49 @@
FALLBACK_PROMETHUES_GENERATOR_URL = "http://localhost:9090/graph?g0.expr=up%7Bjob%3D%22apiserver%22%7D&g0.tab=0&g0.stacked=0&g0.show_exemplars=0&g0.range_input=1h"


def parse_by_operator(pairs: str, operator: str) -> Dict[str, str]:
def parse_by_operator(pairs: str, operators: List[str]) -> Dict[str, str]:
"""
Parses a comma-separated string of key-value segments where each segment
can be split by one of multiple possible operators.
For example:
pairs_str = "foo:bar,baz=qux"
operators = [":", "="]
would return:
{"foo": "bar", "baz": "qux"}
:param pairs_str: Comma-separated string of key-value segments
:param operators: List of possible operators (e.g., [":", "="])
:return: Dictionary of parsed key-value pairs
"""

if not pairs:
return {}

results: Dict[str, str] = {}
for pairs in pairs.split(","):
key, val = pairs.split(operator)
segments = pairs.split(",")

for segment in segments:
segment = segment.strip()
# If segment is empty, skip
if not segment:
continue

# Find which operator appears first (lowest index) in this segment
lowest_index = None
chosen_operator = None

for op in operators:
idx = segment.find(op)
if idx != -1 and (lowest_index is None or idx < lowest_index):
lowest_index = idx
chosen_operator = op

# If none of the operators is found, skip or handle differently
if chosen_operator is None:
continue

# Split once, using the chosen operator
key, val = segment.split(chosen_operator, 1)
results[key.strip()] = val.strip()

return results
Expand Down Expand Up @@ -106,7 +142,7 @@ def prometheus_alert(event: ExecutionBaseEvent, prometheus_event_data: Prometheu
if prometheus_event_data.daemonset_name is not None:
labels["daemonset"] = prometheus_event_data.daemonset_name
if prometheus_event_data.labels is not None:
labels.update(parse_by_operator(prometheus_event_data.labels, ":"))
labels.update(parse_by_operator(prometheus_event_data.labels, [":", "="]))

starts_at = prometheus_event_data.starts_at if prometheus_event_data.starts_at else datetime.now().astimezone()

Expand All @@ -123,7 +159,9 @@ def prometheus_alert(event: ExecutionBaseEvent, prometheus_event_data: Prometheu
"summary": prometheus_event_data.summary if prometheus_event_data.summary else prometheus_event_data.alert_name,
"runbook_url": prometheus_event_data.runbook_url,
}
annotations.update(parse_by_operator(prometheus_event_data.annotations, "="))

if prometheus_event_data.annotations is not None:
annotations.update(parse_by_operator(prometheus_event_data.annotations, [":", "="]))

fingerprint = prometheus_event_data.fingerprint
if not fingerprint: # if user didn't provide fingerprint, generate random one, to avoid runner deduplication
Expand Down
24 changes: 12 additions & 12 deletions poetry.lock

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

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ supabase = "^2.4"
tabulate = { version = "^0.8.10" }
slack-sdk = { version = "^3.23.0" }
Flask = { version = "^3.0.0", optional = true }
werkzeug = { version = ">=3.0.3", optional = true }
jinja2 = { version = ">=3.1.4", optional = true }
werkzeug = { version = ">=3.0.6", optional = true }
jinja2 = { version = ">=3.1.5", optional = true }
grafana-api = { version = "^1.0.3", optional = true }
watchdog = { version = "^2.1.0", optional = true }
better-exceptions = { version = "^0.3.3", optional = true }
Expand Down

0 comments on commit 67e4378

Please sign in to comment.