# Incident Status Based Deduplication

Incident Status Based Deduplication works on the logic that all alerts that come in for a Service are related to the same issue. So, if there is an open incident for a Service - that is, the incident is in the <mark style="color:red;">`Triggered`</mark> or <mark style="color:red;">`Acknowledged`</mark> state, **all** incidents that come in for this Service will get deduplicated against the existing, open incident within the specified time window.

## 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 Deduplication Rules).

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

## Enabling the Incident Status-Based Deduplication <a href="#enabling-the-incident-status-based-deduplication" id="enabling-the-incident-status-based-deduplication"></a>

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 **Automation Rules** section, **Add Deduplication Rules**
4. Select an **Alert Source** from the drop-down -> **Add New Rule**
5. Incident Status Based Deduplication Rules can be added in two ways:

### (a) **UI-based Rule Builder (Beginner-friendly)**

1. Create a rule specifying the **Label** as <mark style="color:red;">`past_incident["is_suppressed"]`</mark>, **Condition** as <mark style="color:red;">`==`</mark> and **Value** as <mark style="color:red;">`False`</mark>.
2. Add an appropriate deduplication time window.
3. Click on **Save Rule** to complete.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-254826c8604659d919ee112adace5c9c3609d125%2FAdd_rule_1.png?alt=media" alt="Incident status based deduplication in Squadcast"><figcaption></figcaption></figure>

{% hint style="info" %}
The key of the Tag label, "tag key" can only contain letters (both lowercase and uppercase) and numbers. Anything else will be ignored.
{% endhint %}

{% hint style="info" %}
The maximum time allowed for deduplication is **48 hours**.
{% 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 %}

### (b) **Raw String Method**

{% hint style="info" %}
Once you opt for the Raw String method for a rule, you cannot revert to the UI-based Rule Builder method.
{% endhint %}

1. You can copy and paste the rule below and change the Rule Execution Priority accordingly.

![Add Incident status based deduplication in Squadcast](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-e51b1547000e49e02773cff4ccd904db32984780%2Fservices_new_1.png?alt=media)

2\. Add an appropriate deduplication time window.

3\. Click on **Save Rule** to complete.

{% hint style="info" %}
The maximum time allowed for deduplication is **48 hours**.
{% endhint %}

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-6ba02b1936e4837172d0f80e837ba39f369a3316%2FScreenshot%202022-08-09%20at%204.52.10%20PM.png?alt=media" alt="Create condition for incident status based deduplication"><figcaption></figcaption></figure>

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

1\. I have added the Deduplication Rule <mark style="color:red;">`past_incident.is_suppressed == false`</mark> manually to an existing Service to deduplicate all alerts against any open incident for the Service. Nevertheless, I do not see Incident Status Based Deduplication taking place as expected. What am I missing?

Once the Deduplication Rule <mark style="color:red;">`past_incident.is_suppressed == false`</mark> is added manually to an existing Service, please move the rule <mark style="color:red;">`up`</mark> or <mark style="color:red;">`down`</mark> based on the Rule Execution Priority you wish to have. If you do not want any of your other Deduplication Rules to be executed for the Service, move the newly added Deduplication Rule to the top of 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.png?alt=media&#x26;token=2f619b54-e282-4c6c-b11a-3b366d598b00" alt="Change rule execution priority"><figcaption></figcaption></figure>

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