# Configure Alerts

API7 Gateway monitors gateway instances, certificates, license usage, and request status codes, and can notify you when these conditions cross a threshold. Alerting is built around three concepts you configure in the Dashboard:

* **Contact Points** — reusable destinations for notifications (Email or Webhook).
* **Alert Policies** — the conditions to evaluate (event, rule, gateway groups, check interval) and which contact points to notify when triggered.
* **Alert History** — a 30-day log of past alerts and the notifications that were delivered.

For background on how alerts are evaluated and delivered, see [Alerts and Contact Points](https://docs.api7.ai/api7-gateway/enterprise-features/alerts-and-contact-points.md).

## Configure a Contact Point[​](#configure-a-contact-point "Direct link to Configure a Contact Point")

Before you create a policy, configure at least one contact point so the gateway has somewhere to send notifications.

1. From the top navigation bar, select **Organization**, then **Contact Points**.

2. Click **Add Contact Point** and choose either:

   <!-- -->

   * **Email** — enter one or more recipient addresses. Email delivery requires an SMTP server, which you configure under **Organization > Settings > SMTP Server**.
   * **Webhook** — enter the destination URL. Use this to forward notifications to Slack (via [Slack Incoming Webhooks](https://api.slack.com/messaging/webhooks)), PagerDuty, Microsoft Teams, or any HTTP endpoint that accepts an alert payload.

You can attach multiple contact points to a single alert policy, so a policy can notify both an on-call email list and a Slack channel.

## Recommended Alert Policies[​](#recommended-alert-policies "Direct link to Recommended Alert Policies")

The Dashboard exposes more than 20 built-in event types. The following policies are recommended for most production deployments. Each is created from **Alert > Policies > Add Alert Policy**.

| Event                                                             | Why it matters                                                                                                                                                            | Suggested check interval |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| Gateway instance offline                                          | The control plane has stopped receiving heartbeats. A still-running data plane may continue proxying with its last applied configuration; verify proxy health separately. | 60 minutes               |
| mTLS certificate between control plane and data plane will expire | These certificates are valid for 3,650 days by default; expiry breaks CP–DP communication.                                                                                | 1440 minutes (daily)     |
| SSL certificate will expire                                       | Listener TLS certificates need to be rotated before clients see TLS errors.                                                                                               | 1440 minutes (daily)     |
| Allowed License CPU Quota Exceeded                                | The combined CPU cores of all data plane instances has exceeded the quota allowed by your API7 Enterprise license.                                                        | 60 minutes               |
| Number of healthy gateway instances                               | Detect when a gateway group falls below the minimum instance count required for your SLO.                                                                                 | 30 minutes               |
| Number of status code 500 / Ratio of status code 500              | Surface upstream or gateway failures that affect a measurable share of traffic.                                                                                           | 30 minutes               |

For the concepts behind these events and how the control plane evaluates them, see [Alerts and Contact Points](https://docs.api7.ai/api7-gateway/enterprise-features/alerts-and-contact-points.md). For the variables you can use in notification templates, see [Alert Variables and Templates](https://docs.api7.ai/api7-gateway/reference/alert-template.md).

## Alert on Service Registry Connection Loss[​](#alert-on-service-registry-connection-loss "Direct link to Alert on Service Registry Connection Loss")

This alert was introduced in API7 Enterprise 3.10.9.

Use the **Service Registry Lost Connection** event to get notified when gateway instances lose their connection to a [service registry](https://docs.api7.ai/api7-gateway/key-concepts/service-discovery.md#service-registry-status). As with the gateway instance offline event, you scope the policy by gateway groups or labels. The rule reads `Any gateway instance in the selected gateway groups has lost connection to a service registry for more than {value} {unit}`, where you set the value and the unit.

The lost duration for each gateway-instance and service-registry pair starts when the control plane first receives a lost-connection report for that pair. The alert also fires while the registry shows **Partially Lost Connection**.

At each check, a pair matches only if its lost duration is longer than the threshold but not longer than the threshold plus the check interval. This has two effects:

* Each pair notifies once per lost episode. No notification is sent when the connection recovers.
* A pair that has been lost for longer than the threshold plus the check interval when you create the policy does not trigger an alert for that episode.

## Customize Notification Content[​](#customize-notification-content "Direct link to Customize Notification Content")

Email subjects, email bodies, and webhook payloads can include the following template variables:

| Variable                     | Description                                                                                                                                                          |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{{ .AlertPolicyName }}`     | Name of the alert policy.                                                                                                                                            |
| `{{ .Description }}`         | Description of the alert policy.                                                                                                                                     |
| `{{ .Severity }}`            | Severity (`High`, `Medium`, or `Low`).                                                                                                                               |
| `{{ .TriggerGatewayGroup }}` | Comma-separated names of the gateway groups that triggered the alert.                                                                                                |
| `{{ .AlertTime }}`           | Time of the alert. Format with `{{ .AlertTime.Format "2006 Jan 02 15:04:05" }}`.                                                                                     |
| `{{ .AlertDetail }}`         | Human-readable description of the events that triggered the alert. Use the `escape` function (`{{ .AlertDetail \| escape }}`) when embedding in a JSON webhook body. |

For the complete reference, see [Alert Variables and Templates](https://docs.api7.ai/api7-gateway/reference/alert-template.md).

## Review Alert History[​](#review-alert-history "Direct link to Review Alert History")

Alert events and the notifications delivered for them are retained for 30 days. To inspect them, select **Alert** from the side navigation bar, then click **History**. Each record includes the policy that fired, severity, trigger time, gateway groups involved, and the alert detail that was sent.

## Next Steps[​](#next-steps "Direct link to Next Steps")

* [Monitor Metrics](https://docs.api7.ai/api7-gateway/observability/metrics.md) — refine alert thresholds against the metrics they evaluate.
* [Configure Distributed Tracing](https://docs.api7.ai/api7-gateway/observability/tracing.md) — investigate the root cause of a fired alert.
* [Configure Centralized Logging](https://docs.api7.ai/api7-gateway/observability/logging.md) — correlate alert events with the corresponding access and error log entries.
