> For the complete documentation index, see [llms.txt](https://docs.datasentinel.io/manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasentinel.io/manual/features/key-features/alerting/templates.md).

# Templates

Defining notification templates is the next step after enabling Alerting at the platform level.

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="https://1072624949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlcWi6G1jtNuyGT9C0pkc%2Fuploads%2FaPAsXB45Cf99f4fE2l9s%2Frule_filters.gif?alt=media&amp;token=f34c64ef-bd7d-457e-b881-65924538c11a" 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="https://1072624949-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlcWi6G1jtNuyGT9C0pkc%2Fuploads%2FlPNoDot9pD7UAP8yT0cq%2Fpostgresql-rules.png?alt=media&amp;token=990a0889-ee36-4fcc-a800-c1023c27c91c" alt=""><figcaption><p>Rules</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.datasentinel.io/manual/features/key-features/alerting/templates.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
