From 8542aa38bb79e7bd9e89a27eedf07d4a69350f39 Mon Sep 17 00:00:00 2001 From: Robusta Runner Date: Sat, 4 Jan 2025 21:34:48 +0200 Subject: [PATCH] Update routing-with-scopes.rst --- .../routing-with-scopes.rst | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/notification-routing/routing-with-scopes.rst b/docs/notification-routing/routing-with-scopes.rst index 8b078fd1d..b28e76b37 100644 --- a/docs/notification-routing/routing-with-scopes.rst +++ b/docs/notification-routing/routing-with-scopes.rst @@ -91,6 +91,37 @@ Note that the order of sinks matters! The first sink that matches a notification Advanced Scope Conditions -------------------------- +Mapping Prometheus Alerts to Kubernetes Resources +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +In Kubernetes environments, Robusta automatically maps Prometheus alerts to Kubernetes resources according to alert labels. +This lets you route alerts not only based on Prometheus metric labels, but also based on Kubernetes metadata. + +For example, to route a Prometheus ``KubePodCrashLooping`` alert based on the related pod's ``app.kubernetes.io/name`` label: + +.. code-block:: yaml + + sinksConfig: + - slack_sink: + name: test_sink + slack_channel: test-notifications + api_key: secret-key + scope: + include: + - identifier: "KubePodCrashLooping" + labels: "app.kubernetes.io/name=my-app" + +Note that we routed based on Kubernetes metadata, not present in Prometheus itself! + +.. details:: How does Robusta map Prometheus alerts to Kubernetes resources? + + Robusta uses alert labels to map Prometheus alerts to Kubernetes resources. + + For example, if a Prometheus alert has labels ``pod=my-pod`` and ``namespace=foo``, Robusta will fetch the relevant Kubernetes pod and associate it with the alert. + + If an alert has a label ``deployment=my-deployment``, Robusta will do something similar for Deployments. And so on. + + This mapping is done automatically, but can be customized if needed. For more details, refer to :ref:`Relabel Prometheus Alerts`. + AND Logic ^^^^^^^^^^^