When attempting to remediate the Load balancer server errors monitored (AWS), administrators may notice that the metrics listed do not appear as selectable options when creating an Alarm. This is a blocker for creating the alarm, but the good news is administrators can get around this by adding the metric via JSON. This article will provide steps on how to do this for Applications and Classic load balancers.
Steps for Application Load Balancers
Head into EC2 and click Load Balancers on the left-hand menu
Click into the load balancer you want to remediate
You should be taken to the details page for the selected load balancer, now copy the full name of the load balancer starting from 'app/' from under the Details drop-down box
Also, make note of the region the load balancer exists in; if you are not sure about this, you can click on the item on the test page and see the region the load balancer exists in
Now please open your text editor of choice and paste in the following JSON text:
{
"metrics": [
[ "AWS/ApplicationELB", "HTTPCode_Target_5XX_Count", "LoadBalancer", "NAME", { "stat": "Average" } ]
],
"view": "timeSeries",
"stacked": false,
"period": 300,
"region": "REGION"
}Replace 'NAME' with the name of the load balancer you copied from the details section, and replace 'REGION' with the region the load balancer exists in:
Once that is complete, now head back into AWS and go to Cloudwatch to create a new alarm
Click Select Metric
Then select the 'Source' tab:
Now Paste in the JSON from the text file with your load balancer name and region updated
Now click Update on the top right under Add query
Then click Select Metric on the bottom right
You will be taken to a screen where you can now customize the statistic AWS will monitor by clicking the looking glass and choosing your desired stat
You can also change the period, but the metric name and load balancer name should not be modified!
You can scroll down and also specify the conditions to your liking and click next to finish
You can finish creating the alarm as normal (provide name, description, and configure notifications settings). Once the alarm is created, Vanta should pick this up in an hour, and the load balancer should no longer be flagged on the test page.
Steps for Classic Load Balancer
Head into EC2 and click Load Balancers on the left-hand menu
Click into the load balancer you want to remediate
You should be taken to the details page for the selected load balancer, now copy the full name of the load balancer:
Also, make note of the region the load balancer exists in; if you are not sure about this, you can click on the item on the test page and see the region the load balancer exists in
then, please open your text editor of choice and paste in the following JSON text
{
"metrics": [
[ "AWS/ELB", "HTTPCode_Backend_5XX", "LoadBalancerName", "ENTER_NAME_HERE", { "stat": "Average" } ]
],
"view": "timeSeries",
"stacked": false,
"period": 300,
"region": "ENTER_REGION_HERE"
}
Replace 'ENTER_NAME_HERE' with the name of the load balancer you copied from the details section, and replace 'ENTER_REGION_HERE' with the region the load balancer exists in
Once that is complete, now head back into AWS and go to Cloudwatch to create a new alarm
Click Select Metric
Then select the Source tab
Paste in the JSON from the text file with your load balancer name and region updated
Click Update on the top right under Add query
Then click Select Metric on the bottom right
You will be taken to a screen where you can now customize the statistic AWS will monitor by clicking the looking glass and choosing your desired stat
You can also change the period, but the metric and load balancer names should not be modified
You can scroll down and also specify the conditions to your liking and click next to finish
You can finish creating the alarm as normal (provide name, description, and configure notifications settings). Once the alarm is created, Vanta should pick this up in an hour, and the load balancer should no longer be flagged on the test page.
How Can I Change the Metric in The JSON?
If you prefer to use a different metric, then you can replace the metric name in the JSON (highlighted below)
With one of the other supported metrics listed on the test page How to fix section: