# Templates

Notification templates are **dynamically assigned at runtime** when parsing metrics for each instance sharing the same TAG(s).

A notification template is composed of:

* Filters (aka TAGs) corresponding to one or more instances
* Rules to define criteria that determine whether a notification is triggered

## Filters

To begin, you are required to set up one or more filters, commonly known as tags.

{% hint style="info" %}
For tag assignment details, refer to [Tags section](/manual/features/tips-and-hints/tags.md).
{% endhint %}

The example below creates a notification template for all instances sharing the tag **datacenter=dc1**.

<figure><img src="/files/6xmvhcZSuzZEyzxQvjC4" alt=""><figcaption><p>Adding filters</p></figcaption></figure>

{% hint style="info" %}
When adding a new instance, it will automatically be assigned this template if it shares the same tag.
{% endhint %}

When parsing metrics, Datasentinel searches for a corresponding notification template using the following sequence:

1. A template containing the instance name directly in the filter list will always take precedence.
2. The most recent rule that matches filters

## Rules

Rules are categorized into two groups.

### PostgreSQL metrics

> * Instance status
> * Max connections
> * Blocked sessions
> * Sessions consuming CPU
> * WAL files
> * WAL file-system
> * Old archived time
> * Failed archived files
> * Replication lag

### System metrics

> * CPU usage
> * Load average
> * Memory usage
> * Swap usage
> * File systems

You can allocate both WARNING and CRITICAL thresholds to each rule and decide the occurrence count (for specific rules) that will activate an event.

Metrics undergo parsing every minute, making an occurrence equivalent to a one-minute interval.

{% hint style="info" %}
Every rule can be toggled on or off.

In cases where **WARNING** and **CRITICAL** values match, only **CRITICAL** problems are generated.

Upon saving a template, it becomes active instantly.
{% endhint %}

<figure><img src="/files/a2539PD850SEXZk1Pxeu" alt=""><figcaption><p>Rules</p></figcaption></figure>


---

# 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://docs.datasentinel.io/manual/features/key-features/alerting/templates.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.
