# Alert Routing

{% embed url="<https://www.youtube.com/watch?v=zmentTMRYFA>" %}

Alert Routing allows you to configure *Routing Rules* to ensure that alerts are routed to the right responder with the help of <mark style="color:red;">`event tags`</mark> attached to them.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* The User Role associated with the user in the Team must have required permissions to manage Services (ability to manage Routing Rules).
* Ensure you have <mark style="color:red;">`Tags`</mark> [<mark style="color:blue;">defined</mark>](https://support.squadcast.com/docs/event-tagging) for the Service.

{% hint style="warning" %} <mark style="color:orange;">**Important:**</mark>\
Automation rule CRUD operations have a 5-minute caching delay before changes take effect.
{% endhint %}

## Create Routing Rules <a href="#configuring-routing-rules" id="configuring-routing-rules"></a>

To configure Routing Rules:

1. Navigate to **Services** -> **Service Overview** -> select or search for your desired service.
2. On the extreme right, expand the accordion -> In the Automation section, **View All.**
3. In the Routing Rules section, **Add Routing Rules**.
4. You can add Routing Rules in three ways:

### UI-based Rule Builder (Beginner-friendly) <a href="#ui-based-rule-builder-beginner-friendly" id="ui-based-rule-builder-beginner-friendly"></a>

**(a)** This box displays all the <mark style="color:red;">`[event tags]`</mark>(<https://support.squadcast.com/docs/event-tagging>) defined for this Service, which can be used to define Routing Rules

**(b)** Select **Add new rule**

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-629cde36fa4719ce32b66194528e22d858141a39%2Falert_routing_3%20(1).png" alt="Add Routing Rules via UI-based rule builder"><figcaption></figcaption></figure>

**(c)** Pick the **event tag** <mark style="color:red;">`key`</mark> and <mark style="color:red;">`value`</mark> pair that you are checking for in an incident using the drop-downs

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-b44761bd9a10e1ce3026a4b5503e710b3396192e%2Falert_routing_4.png" alt="pick the event tag key and value pair for incident routing rules"><figcaption></figcaption></figure>

**(d)** **Add Conditions** to make your rules more granular

You can create Routing Rules using the following conditions:

| Operators        | Condition                                                        |
| ---------------- | ---------------------------------------------------------------- |
| ==               | if the payload value is equal to the given value                 |
| !=               | if the payload value is not equal to the given value             |
| matches/contains | if the payload value matches (***or** contains*) the given value |
| does not contain | if the payload value does not contain the given value            |

{% hint style="warning" %}
**Note**: All these operators are case-sensitive.\
\
If you want to make the rules *case insensitive*, then you have to do it with the regular expression method.
{% endhint %}

**(e)** You can route the incident containing the specific <mark style="color:red;">`event tags`</mark> to either a <mark style="color:red;">`User`</mark>, <mark style="color:red;">`Squad`</mark> or an <mark style="color:red;">`Escalation Policy`</mark>. Pick the same from the drop-down

**(f)** Click on **Save**

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-41e3f20b51d21c82c649e9ed0d96ad1d83a5bc91%2Falert_routing_5.png" alt="route the incident containing the specific event tags to user squad or Escalation Policy"><figcaption></figcaption></figure>

{% hint style="info" %}
**Default Service Escalation Policy Override**

The Alert Routing Rules will take precedence (override) over the default Escalation Policy for the Service if any of the rules match (evaluate to True) an incoming incident.
{% endhint %}

{% hint style="info" %}
**Note**: The search option under payload is not a free search, we have to search by JSON format, for example, type in payload.annotations to get annotations.

\
We also have an option for click-to-search, wherein you can click on the keys in the payload to get their required values.
{% endhint %}

### Raw String Method <a href="#raw-string-method" id="raw-string-method"></a>

{% hint style="info" %}
**Note**

Once you opt for the Raw String method, you cannot revert to the UI-based Rule Builder method for that rule.
{% endhint %}

**(a)** This box displays all the <mark style="color:red;">`event tags`</mark> [<mark style="color:blue;">defined</mark>](https://support.squadcast.com/docs/event-tagging) for this Service

**(b)** Select **Add new rule**

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-629cde36fa4719ce32b66194528e22d858141a39%2Falert_routing_31.png" alt="incident routing rules by raw string method in Squadcast"><figcaption></figcaption></figure>

**(c)** Click on **Edit** to enable **the** Raw String method

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-ec029c57298a5f48f30c7310e2f905c6b6469f88%2Falert_routing_7.png" alt="how to enable the incident routing rules by Raw String method in Squadcast"><figcaption></figcaption></figure>

{% hint style="info" %}
**How to make rules&#x20;*****case-insensitive*****?**\\

1. Click **Edit** -> **Proceed**
2. You will see the rule in the regular expression. Now you need to add the command lc (lower\_case) before the individual parameters

**Here is an example**:

`re(payload["subscription"]["type"], "Subscription")`

The rule says if the payload\["subscription"]\["type"]contains the string "Subscription" in it then do some actions.

If you want to make the above rule case insensitive, you have to add the command lc before the individual parameters.

The case insensitive rule would look like this,

`re(lc(payload["subscription"]["type"]), lc("Subscription")) or`

`re(lc(payload["subscription"]["type"]), "subscription")`
{% endhint %}

**(d)** Write your custom Tagging Rule expression and select **Route To** accordingly

**(e)** Click on **Save**

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-fbb334620ebe17473d3e260f51b87ca213d905bf%2Falert_routing_6.png" alt="select custom Tagging Rule expression in incident routing rules in Squadcast"><figcaption></figcaption></figure>

### Supported Rules <a href="#supported-rules" id="supported-rules"></a>

The rule engine supports expressions with parameters, arithmetic, logical, and string operations.

#### **Basic Expressions**

<mark style="color:red;">`10 > 0`</mark>, <mark style="color:red;">`1+2`</mark>, <mark style="color:red;">`100/3`</mark>

#### **Parameterized Expressions**

<mark style="color:red;">`tags.severity == "high"`</mark>

The available parameters are <mark style="color:red;">`tags`</mark>

* <mark style="color:red;">`tags`</mark>: This parameter contains all the configured tags for a given Service.

#### **Regular Expressions**

<mark style="color:red;">`re(tags.severity, "high.*")`</mark>

This can be used to check if a particular tag field matches a regular expression.

#### **Example**

Below is the set of <mark style="color:red;">`event tags`</mark> defined for a Service (as shown in the right panel of the configuration space)

```
{
	"tags": [
		{
			"severity": "critical"
		},
		{
			"severity": "high"
		},
		{
			"severity": "low"
		}
	]
}
```

#### **Use-case for Routing Rules**

When:

* <mark style="color:red;">`severity`</mark> is <mark style="color:red;">`critical`</mark> : Route to a **Squad**
* <mark style="color:red;">`severity`</mark> is <mark style="color:red;">`high`</mark> : Route to an **Escalation Policy**
* <mark style="color:red;">`severity`</mark> is <mark style="color:red;">`low`</mark> : Route to a **User**

#### **Routing Rules are as follows:**

* <mark style="color:red;">`tags.severity == "critical"`</mark> *route* to a <mark style="color:red;">`squad`</mark>
* <mark style="color:red;">`tags.severity == "high"`</mark> *route* to an <mark style="color:red;">`escalation policy`</mark>
* <mark style="color:red;">`tags.severity == "low"`</mark> *route* to a <mark style="color:red;">`user`</mark>

## FAQs <a href="#faqs" id="faqs"></a>

1\. How do I know if an incident gets routed due to a Routing Rule?

In the Incident’s Activity Timeline the reason for routing, and to which entity it gets routed to, is displayed.

<figure><img src="https://github.com/solarwinds-cloud/sq-Gitbook/blob/main/.gitbook/assets/21spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-c510b89b49dac8c015d99283b9fa9663292aa3e5%2Frouting_reason.png" alt="select custom Tagging Rule expression in incident routing rules in Squadcast"><figcaption></figcaption></figure>

2\. What kind of regex can be used to write custom rules?

The rule engine supports expressions with parameters, arithmetic, logical, and string operations. You can also check [<mark style="color:blue;">this</mark>](https://regex101.com/) out to get an idea of all the expression types accepted in Squadcast. Please do your regex [<mark style="color:blue;">here</mark>](https://regex101.com/) against <mark style="color:red;">`Golang`</mark> flavor as shown in the screenshot below and then, set them up in Squadcast:

![Regex used to write custom rules in Squadcast](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-0a3de1a55aed181cdc4610c563ed06abd5bdb64f%2Fgolang.png?alt=media)

3\. Can I create OR rules?

Yes, you can. The evaluation between different Routing Rules is <mark style="color:red;">`OR`</mark>. Add multiple Routing Rules to enable <mark style="color:red;">`OR`</mark> evaluation.

4\. While adding a Routing Rule, is the *search string* in the rule case sensitive?

Yes, that is correct. For example, if your **search** string is “ALERT” and your payload does not contain “ALERT” but contains “Alert”, this will not be matched. Your search string should be “Alert”.

5\. Do Routing Rules have priority?

Yes, you can specify Execution Rule Priority for the rules defined by moving them <mark style="color:red;">`Up`</mark> or <mark style="color:red;">`Down`</mark> the list of rules.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-e546486082eeb87293e65f77c522760d1423825c%2Fstatus-based-deduplication_5%20(1).png?alt=media&#x26;token=e9252ce3-9fdc-411d-bd1f-510868aa22c5" alt="Move execution priority of Routing Rules in Squadcast"><figcaption></figcaption></figure>

6\. I have configured multiple rules for a particular Service. Can I search through the configured rules to find the rule I am looking for?

Yes, that is doable. You will notice a **Search** option on the left top of the rules modal. You can type in a word you recall from the rule. Any matching results will yield a narrowed-down set of rules.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-4137bbdb27e2827d48e91a5cebb3c0090ff3fce0%2Fautomation-rules-search-1%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(9).png?alt=media&#x26;token=66b2a721-dd8f-4b11-9849-e56f668f6c30" alt="Search through configured Routing Rules in Squadcast"><figcaption></figcaption></figure>

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.squadcast.com/services/alert-routing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
