Setting Up Basic Alerts in Anypoint Monitoring | MuleSoft Documentation
# Setting Up Basic Alerts in Anypoint Monitoring
You can set up basic alerts for servers, Mule apps, and APIs. Alerts trigger email notifications when a metric you are measuring passes a specified threshold.
You can create basic alerts for the following metrics:
  * For on-premises servers, server groups, server clusters, and apps deployed to Anypoint Runtime Fabric or CloudHub:
    * CPU utilization
    * Memory utilization
    * Thread count
  * For hybrid, Anypoint Runtime Fabric, and CloudHub apps:
    * Message count
    * Message error count
    * Message response time
  * For APIs:
    * Total request count
    * Average response time
    * Response codes
    * Policy violations


A basic alert typically triggers an e-mail within 5 to 15 minutes of an incident. However, the basic alert’s timestamp reflects the actual time of the incident.
## Create a Basic Alert
When you create a basic alert, you can select a source for the basic alert, configure the condition under which the basic alert is triggered, and specify which email addresses receive notifications for basic alert triggers.
To create a basic alert:
  1. Navigate to Anypoint Monitoring.
  2. From the sidebar, click **Alerts**.
  3. Click the **+ New Alerts** button.
  4. Click **Basic alert**.
  5. In the **Add basic alert** window, enter the information required to create your basic alert:
     * **Alert name**
Unique and meaningful name for the alert
**Name** is limited to 40 characters.
     * **Severity level**
Severity of the alert: **Critical** , **Warning** , or **Info** See Alert Severity.
     * **Source type**
Source of the alert: an application, server, or API
     * **Environment name**
Name of the environment where the resource is deployed
     * **Resource name** (apps), **Server name** (servers), **API** (APIs)
Application, server, or API to apply the alert to
For APIs, you must also provide an API version. Only active versions of an API are selectable. Inactive APIs do not submit metrics.
     * **Metric**
Condition that triggers the alert
See Alert Conditions.
     * **Subject**
Subject of the alert email to send when the alert is triggered
The subject can include variables. See Variable Definitions.
     * **Message**
Body text for the email to send when the alert is triggered
The message body can include variables. See Variable Definitions.
     * **Recipients**
Recipients of the alert email
You can select up to 20 platform user IDs and enter up to 20 email addresses. If you add or change the email address of an alert recipient, they do not receive an email until the alert is triggered.
  6. Click **Create**.


### Alert Severity
The following levels of severity are available for basic alerts: 

Info
    
May be assigned to alerts that do not require immediate attention when triggered. This severity indicates the metric should be passively monitored. 

Warning
    
May be assigned to alerts that require prompt attention when triggered. This severity indicates an alert should be closely monitored. 

Critical
    
May be assigned to alerts that require immediate attention when triggered. This severity indicates an alert should receive an immediate response.
### Alert Conditions
For basic alerts, alert conditions consist of a metric, an operator, and a period of time that the condition is met.
#### Application Metrics
The following metrics are available if your alert is created for an application: 

Message count
    
Total number of Mule messages that are processed successfully 

Message error count
    
Number of Mule messages that return an exception in a flow 

Message response time
    
Response time (in milliseconds) of a message 

CPU utilization
    
Percent of CPU used on the virtual machine. This metric includes all processes.
This metric is available only for apps deployed to CloudHub or Anypoint Runtime Fabric. 

Memory utilization
    
Percent of heap used
This metric is available only for apps deployed to CloudHub or Anypoint Runtime Fabric.
Anypoint Monitoring tracks heap usage and triggers memory alerts based on the value of `heap_used`/`heap_total`. Note that `heap_total` isn’t the identical to the maximum heap memory allocated to the Mule app on CloudHub. For example, 0.2 vCores indicates that the maximum heap memory is 1 GB (see the table in CloudHub Workers), but the value of `heap_total` isn’t 1GB. Instead, `heap_total` is the maximum amount of memory that the JVM can use for heap memory, where objects are created and stored. In Java, this value changes dynamically depending on memory fragmentation, garbage collection, and other memory management features. For more information about the JVM Heap Total Memory values, see dashboard-config-ref.adoc#metrics_advanced. 

Thread count
    
Total number of threads used
This metric is available only for apps deployed to CloudHub or Anypoint Runtime Fabric.
#### Server Metrics
The following metrics are available if your alert is created for a server, server group, or server cluster: 

CPU utilization
    
Percent of CPU used 

Memory utilization
    
Percent of memory used 

Thread count
    
Total number of threads used
#### API Metrics
The following metrics are available if your alert is created for an API: 

Total request count
    
Sum of requests in the selected time period for the given API.
Data is aggregated in one minute increments. 

Average response time
    
Average response time of requests in the selected time period for the given API.
Data is aggregated in one minute increments. 

Response codes
    
Sum of HTTP response codes that occur in the selected time period.
Select up to ten of the following codes: 301, 400, 401, 402, 403, 404, 405, 408, 409, 410, 411, 412, 413, 415, 416, 417, 420, 422, 429, 500, 502, 503, 504, 504, 510, 511 

Policy violation
    
Sum of requests that return policy violations that you select in the alert condition.
Select a policy associated with the selected API. If the selected API does not have policies, the list is empty.
#### Operator
The _operator_ portion of the alert condition is the logic that is used against the metric you are measuring. The following operators are available:
  * Above
  * Above or equal
  * Equal
  * Below or equal
  * Below


#### Time Period
The _time period_ specifies the duration for which the metric remains valid, based on the criteria defined using the operator and chosen value. A basic alert is triggered only if the metric continuously (not cumulatively) meets the condition for the selected time period. The following time periods are available:
  * 5 minutes
  * 10 minutes
  * 15 minutes
  * 20 minutes


## Basic Alert Email Template
You can use the following variables in a basic alert email **Subject** and **Message** fields. For the description of each variable, see Variable Definitions.
Table 1. Variables for Alerts Alert Type | Alert | Applicable Variables  
---|---|---  
CloudHub App Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${resource}`

  
**Memory Utilization**  
**Message Error Count**  
**Message Response Time**  
Anypoint Runtime Fabric App Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${resource}`

  
**Memory Utilization**  
**Message Error Count**  
**Message Response Time**  
Hybrid App Alerts |  **Message Count** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${targetName}`
  * `${resource}`

  
**Message Error Count**  
**Message Response Time**  
On-premises Server Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${targetName}`

  
**Memory Utilization**  
Server Group Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${memberName}`
  * `${targetName}`
**Memory Utilization**  
**Message Error Count**  
**Message Response Time**  
Hybrid App Alerts |  **Message Count** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${targetName}`
  * `${resource}`

  
**Message Error Count**  
**Message Response Time**  
On-premises Server Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${targetName}`

  
**Memory Utilization**  
Server Group Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${memberName}`
  * `${targetName}`

  
**Memory Utilization**  
Server Cluster Alerts |  **CPU Utilization** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${memberName}`
  * `${targetName}`

  
**Memory Utilization**  
**Total Request Count** | 
  * `${severity}`
  * `${operator}`
  * `${threshold}`
  * `${period}`
  * `${value}`
  * `${condition}`
  * `${organization}`
  * `${environment}`
  * `${alertLink}`
  * `${dashboardLink}`
  * `${timestamp}`
  * `${policy}`

  
**Average Response Time**  
**Response Codes**  
**Policy Violations**  
Table 2. Variable Definitions Variable | Definition  
---|---  
`${alertLink}` | URL of the triggered alert  
`${alertState}` | State of the alert when it was triggered. Available values are `OK` or `Alerting`.  
Name of the API that triggers the alert  
`${comparison}` | Above, above or equal, equal, below or equal, below  
`${condition}` | Metric for which the alert is triggered  
`${dashboardLink}` | URL that points to the built-in dashboard for the app or API that triggers the alert  
`${environment}` | Name of the environment in which the resource is deployed  
`${memberName}` | Name of the server within the server group or cluster  
`${operator}` | An operator, such as `< > =`  
`${organization}` | Name of the organization that owns the alert  
`${period}` | Period of time over which to measure  
`${policy}` | Name of the policy whose violation triggers the alert  
`${resource}` |  Name of the item that triggers the alert:
  * CloudHub Apps: Name of the app that triggers the alert
  * Hybrid Apps: Name of the resource in the app that triggers the alert

  
`${severity}` | Severity of the alert  
`${targetName}` | Name of the server, server group, or cluster  
`${targetState}` | Server state when the alert was triggered  
`${threshold}` | Count over the period of time that triggers the alert  
`${timestamp}` | Time when the alert was triggered  
Value of the metric that triggers the alert