# Adding an Alert in the Face of an Issue

At Pandora FMS the most basic way in which to create alerts is assigning an alert to a specific module.

# Introduction

Of course, [more advanced tasks can be carried out](https://dokuwiki.pandorafms.com/manual/!development/en/documentation/04_using/01_alerts), such as alerts on events, correlation, etc. The first alert to create is sending an email when one of the [monitored machines](https://dokuwiki.pandorafms.com/manual/!development/en/quickguides/general_quick_guide#interface_network_traffic) goes offline (with the Host alive module).

Pandora FMS alerts are made up by three elements:

- **Command.**
- **Action.**
- **Template.**

In this particular case, a predefined command will be used (email forwardingt), an existing action will be modified (`Mail to XXX`) and an existing template will also be used, template Critical condition, that will execute the task when the module itself goes into critical state.

See also: "[How Pandora FMS alert system works (video)](https://www.youtube.com/watch?v=LzWx9x6ESbw&t=0s)"

# Server Setup

For the correct functioning of the `email` command, it is necessary to configure in `pandora_server.conf` file a mail server that allows to make relay.

In the example, the mail server located in our `localhost` through [Postfix](https://es.wikipedia.org/wiki/Postfix). You should enter the IP address of the local mail server, or one in Internet (configuring its authentication).

To modify the server configuration file, you must access it, located at `/etc/pandora/pandora_server.conf` as **root** user by elevating your privileges using the `sudo su` command. You are the only **responsible** for this key.

[![image.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-10/scaled-1680-/E6jimage.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-10/E6jimage.png)

To edit this configuration file in this example, the **vim** program is used. More information can be found in the video tutorial "[Editing files with VIM](https://www.youtube.com/watch?v=mjE1GD4LRXc&t=0s)".

Find the lines you see in the screenshot below and set those values. If you do not have a mail server, you may use for example a Gmail® account. You may see a quick guide on how to configure Pandora FMS server to work with a Gmail® account in the following link: [Configuring email alerts](https://dokuwiki.pandorafms.com/manual/!development/en/quickguides/configuration_emails_alerts).

The lines that begin with the character `#` are comments and are not taken into account by the server.

[![guiarapida_mailconf03.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/guiarapida-mailconf03.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/guiarapida-mailconf03.png)

Once the changes are made, click ESC and `:wq` to save the changes and exit. Once you are in the command line, restart Pandora FMS server:

```
/etc/init.d/pandora_server restart
```

# Alert Setup

As indicated before, alerts in Pandora FMS are made up by 3 parts: **Command**, **Action** and **Template**. You may find these options in the **Alerts** section. In order to configure this alert just modify the **action**, so the **Alert actions** option will be used.

[![pfms-management-alert_actions.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/pfms-management-alert-actions.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/pfms-management-alert-actions.png)

The section to be used is that of **Mail to admin**, click on said name to edit the alert action.

[![pfms-management-alert_actions-mail_to_admin.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/pfms-management-alert-actions-mail-to-admin.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/pfms-management-alert-actions-mail-to-admin.png)

Modify **Field 1** and enter your email address, in this example [\[email protected\]](https://pandorafms.com/cdn-cgi/l/email-protection) is used. **Field 2** will leave the text in the screenshot. Here two macros are used, which will replace at run time the name of the agent and the module that generated the alert.

# Assigning an Alert to a Module

Go the agent editing, where the module is defined and click on the alert tab:

[![pfms-agent_add_alert.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/pfms-agent-add-alert.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/pfms-agent-add-alert.png)

Now add the module (**Host Alive**), the template (**Critical Condition**) and the action (**Mail to admin**). Click **Add alert**.

[![pfms-agent_add_alert_2.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/pfms-agent-add-alert-2.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/pfms-agent-add-alert-2.png)

Once added, you may see in the agent view whether it is running or not, by taking a look at is state color:

[![pfms-agent_add_alert_3.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/pfms-agent-add-alert-3.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/pfms-agent-add-alert-3.png)

When the host goes offline the alert will fire:

[![pfms-agent_add_alert_4.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/pfms-agent-add-alert-4.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/pfms-agent-add-alert-4.png)

An email should be received, something similar to this one:[![guiarapida_mail.png](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/scaled-1680-/guiarapida-mail.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2023-08/guiarapida-mail.png)

Pandora FMS alerts are extremely flexible and, therefore sometimes complex to use. There is a specific chapter for those in the documentation: [Alerts in Pandora FMS](https://pandorafms.com/manual/).