Complete the code to define an alert condition that triggers when the CPU usage is above 80%.
{
"trigger": {
"name": "High CPU Usage",
"condition": {
"script": {
"source": "return ctx.payload.cpu > [1];"
}
}
}
}The alert triggers when CPU usage is greater than 80%, so the correct value is 80.
Complete the code to send an email notification when the alert triggers.
{
"actions": {
"send_email": {
"email": {
"to": "admin@example.com",
"subject": "Alert: CPU Usage High",
"body": {
"text": "CPU usage has exceeded [1]%."
}
}
}
}
}The email body should mention the threshold that triggers the alert, which is 80% CPU usage.
Fix the error in the alert condition script to correctly check if memory usage is below 30%.
{
"trigger": {
"name": "Low Memory Usage",
"condition": {
"script": {
"source": "return ctx.payload.memory [1] 30;"
}
}
}
}The condition should check if memory usage is less than 30%, so the operator is <.
Fill both blanks to create a dictionary alert that maps each server to its disk usage percentage, but only include servers with usage above 75%.
{
"disk_alerts": {
[1]: [2] for server, usage in servers.items() if usage > 75
}
}The dictionary comprehension maps each server name to its usage, filtering for usage above 75%.
Fill all three blanks to create an alert action that logs the alert name, the triggered condition, and the timestamp.
{
"actions": {
"log_alert": {
"logging": {
"text": "Alert [1] triggered because [2] at [3]"
}
}
}
}The log message includes the alert name, the condition name, and the execution timestamp from the context.