Setting up Real-Time Alerts with Alert Center
This guide explains how to set up metric, log, and event-based alerts in KakaoCloud's Alert Center.
- Estimated time: 30 minutes
- Recommended OS: macOS, Ubuntu
- Region: kr-central-2
Before you start
KakaoCloud's Alert Center allows you to configure alert policies and notification channels to receive alerts for service events and resource failures. Setting up timely notifications helps you detect and resolve issues quickly.
About this scenario
This tutorial provides step-by-step instructions for configuring metric, log, and event-based alerts in Alert Center, allowing you to receive real-time notifications.
- Notification channel setup: Create and configure channels to receive alerts in Alert Center.
- Metric-based alerts: Set up alerts by simulating a CPU load test.
- Log-based alerts: Create a log-based alert by generating error logs.
- Event-based alerts: Set up an event-based alert triggered by instance restarts.
Prework
1. Install monitoring agent
To monitor compute resources on your instance, you must install a monitoring agent. For detailed instructions, refer to the BCS Instance Monitoring tutorial.
2. Enter contact information
Ensure you have entered your email address and phone number correctly to receive alerts. For setup instructions, refer to the Modify account information guide.
3. Create notification channels in Alert Center
In KakaoCloud's Alert Center, you can Create notification channels to receive alerts for compute resource risk levels.
-
Go to KakaoCloud Console > Management > Alert Center > Notification Channels.
-
Click the [Create notification channel] button.
-
In the notification channel creation tab, enter the required information, select the channel type, and click [Create].
Type Description Default Sends alerts via email/SMS/KakaoTalk Slack/Webhook Sends alerts to a specified Slack channel or webhook
- The log file path for the monitoring agent used in this tutorial is
/var/log/messages
, and the notification channel type is Default (email).
Procedures
The following instructions explain how to configure various alert types (metric, log, event) in Alert Center.
1. Metric-based alert
Perform a CPU load test (stress) on an instance with the monitoring agent installed to confirm the metric-based alert.
Step 1. Create alert policy
Use KakaoCloud's Alert Center to configure alert policies based on compute resource risk levels.
-
In Alert Center > Notification Channel, click [Create alert policy].
-
Set the necessary alert conditions and click [Create].
Item Value Condition type Metric Service Beyond Compute Service Condition - Metric: CPU usage
- Resource: instance (select monitoring instance)
- Threshold: over 70%
- Duration: 1 minute
- Severity: CriticalNotification Channel Select the preconfigured notification channel Alert policy name tutorial-alert-metric Enabled Yes
Step 2. Test CPU load and confirm alert
On the instance with the monitoring agent installed, use the stress tool to generate CPU load and verify the alert is received.
-
SSH into the instance with the monitoring agent installed.
-
Install the stress tool.
sudo apt-get update
sudo apt-get install stress -
Generate CPU load for 2 minutes.
stress --cpu 2 --timeout 2m
stress: info: [2221] dispatching hogs: 2 cpu, 0 io, 0 vm, 0 hdd # Pausing for 2 minutes is expected behavior
stress: info: [2221] successful run completed in 120s # Output after 2 minutes -
Confirm that the metric-based alert for CPU load was sent to the registered email address from KakaoCloud.
Check Alert
2. Log-based alert
This section explains how to set up a log-based alert triggered by the occurrence of error
messages in the log files of an instance with the monitoring agent installed.
Step 1. Create alert policy
You can configure log-based alert policies in KakaoCloud's Alert Center.
-
In Alert Center > Notification Channel, click [Create alert policy].
-
Set the necessary alert conditions and click [Create].
Item Value Condition type Log Service Beyond Compute Service Condition - Keyword: error
⚠️ After entering the keyword, click + to add it.Notification Channel Select the preconfigured notification channel Alert policy name tutorial-alert-log Enabled Yes
Step 2. Check error alert
Run a test script on the instance with the monitoring agent installed to verify the log-based alert.
-
SSH into the instance with the monitoring agent installed.
-
Create and run the error test script.
# Create script file
touch script.sh
# Open the file
sudo vi script.shEnter the following script in
script.sh
and save it.script.sh#!/bin/bash
# Log file path set during monitoring agent installation
log_file="/var/log/messages"
echo "Error: Something went wrong" >&2
# Write to log file with administrator privileges
sudo bash -c "echo $(date): Custom error occurred >> $log_file"Grant execute permissions and run the script.
# Grant execute permissions to the script
sudo chmod +x script.sh
# Run the script
./script.sh
# Output when the script is executed
Error: Something went wrong -
Confirm that the log-based alert for the
error
keyword was sent to the registered email address from KakaoCloud.Check Alert
3. Event-based alert
This section explains how to set up an event-based alert triggered by instance restart events in KakaoCloud's Alert Center.
Step 1. Create alert policy
You can configure event-based alert policies in KakaoCloud's Alert Center.
-
In Alert Center > Notification Channel, click [Create alert policy].
-
Set the necessary alert conditions and click [Create].
Item Value Condition type Event Service Virtual Machine Condition - Event: Instance Restart Notification Channel Select the preconfigured notification channel Alert policy name tutorial-alert-event Enabled Yes
Step 2. Verify alerts related to the restart event
Restart the virtual machine instance and verify that the event-based alert was sent.
Check Alert