You can set alert thresholds that trigger when they're breached by any of your Java app's instances. Scoping the condition to instances of your app is helpful for detecting anomalies that occur only in a subset of your app's instances.
These sorts of anomalies are easy to miss for apps that aggregate metrics across a large number of instances. By looking at each instance, you can more quickly identify where potential problems are originating.
Example
In this example, you set up a policy for a Java app with three instances. You want to open an incident when the condition's critical threshold for any instance's error rate is greater than .02% for at least five minutes.
During a five-minute time period the three instances have these error rates:
App instance | 4:45pm | 4:50pm | Incident opened? |
---|---|---|---|
A | 0.00% | 0.00% | No. This instance remained below the target threshold the entire time. |
B | 0.02% | 0.03% | Yes. The alert threshold exceeded the 0.02% threshold for this instance for at least five minutes. |
C | 0.10% | 0.00% | No. The threshold value must be breached for at least five consecutive minutes to open an incident. However, if you had set the threshold for at least once in five minutes, then the threshold value must be breached at least once during the five-minute period. |
Create instance-based alert condition
To create a policy that triggers notifications for incidents by your app's individual instances:
- Follow the basic workflow process to set up a policy.
- When creating a condition (step 2), select APM.
- Select Application metric as the type of condition.
- To evaluate alert threshold incidents individually for each of the app's selected instances, select Scope to Java application instances.
- Select Next, select entities, then identify one or more apps for this condition.
- Optional: Change the time when will force-close the incidents (default is 24 hours).
- Use By condition or By condition and signal incident preference.
- Continue the rest of the policy workflow process (step 3).
Tip
To open incidents based on the average of all instances for your apps, select Scope to the application instead of Scope to Java application instances.
Use "By condition" incident preference
When setting the incident preference for policies containing instance-based conditions, we recommend that you select By condition instead of By condition and signal. Although apps are the selected entities for this condition, we evaluate each JVM as a separate entity.
If you set your Incident preference to By condition and signal, a separate incident will be opened for each JVM that breaches the critical threshold. When an app fails across multiple JVMs, this can lead to alert "fatigue" and frustration.
Use REST API for instance alerts
To create instance-based alert conditions with the New Relic REST API, include these items with your REST API call:
- Your API key.
- The numeric
entity_id
for the entity being monitored - The
condition_id
(available from the API Explorer: Alerts Conditions > GET > List) - The
entity_type
(set to"application"
) - The
condition_scope
(set to"instance"
for a Java application instance or"application"
for a Java app)
Here is an example of the API request format and JSON response.