TheKoguryo's Tech Blog

 Version 2024.04.01

Warning

This content has been generated by machine translation. The translations are automated and have not undergone human review or validation.

12.2 Creating Monitoring Alarm

Let’s create an alarm to send an email when CPU utilization reaches a specified number among monitoring set on Compute instance.

  • Defined in Observability & Management > Monitoring > Alarm Definition in the navigation menu in the OCI console
  • Defined in the options menu of the resource monitoring metric

There are two methods above, but in this document, we will proceed to the second method, which is easy to use because the alarm’s metric is automatically set as the selected monitoring metric.

Create Alarm from Metric

  1. Select Resources > Metrics of the Compute instance you set up earlier.

  2. In the options of CPU Utilization, click Create an Alarm on the Query image-20220117105529351

Alarm Definition

Complex alarm conditions are possible with the advanced mode Query, and the following is the basic mode for selecting the UI.

  1. Alarm definition

    • Alarm Name: Enter the alarm name to create
    • Alarm severity: select the level, first select the default Critical
    • Alarm body: Alarm message, enter a message to be forwarded by email later image-20220117105957925
  2. Metric description

    • Select Metric name: CpuUtilization. image-20220117110055063
  3. Metric dimensions
    Specifies the scope of the cloud resource to be monitored.
    The Compute instance you selected earlier is set up automatically.
    Image

  4. Trigger rule

    Specify the condition to set the alarm. When the previously set metric criterion (CPU usage average for 1 minute) is 50% or more image-20220117110546257

Notification Definition

  1. Select Notification Target

    Specifies the target topic of the Notification service to be notified when an alarm is triggered. If you already have a topic, you can select it, but if it doesn’t, click Create a topic to create one

    image-20220117111015497

  2. Create a target topic

    image-20220117112344823

  3. Select the topic created as Destination

    image-20220117112244636

  4. Click Save alarm below

Notification - EMail authentication

  1. If you set the topic’s subscription protocol to email, a verification email is sent to the target email.

  2. Check the received email and click the verification link.

    image-20220117112457939

  3. Subscription confirmation window

    image-20220117115058796

Notification - Check EMail Topic Status

  1. Click the notification target of CPU Alarm created earlier

    image-20220117112710502

  2. Select the topic you created earlier

    image-20220117112734182

  3. Confirm that your email subscription is Active

    image-20220117112830811

Alarm occurrence test

  1. Connect to the Compute instance where monitoring and alarm are set via SSH.

  2. Install the stress tool

    sudo yum-config-manager --enable ol7_developer_EPEL
    sudo yum install -y stress
    
  3. Perform stress

    sudo stress --cpu N --timeout N
    

Execution example

Adjust according to the number of CPUs of the Compute Instance to be used.

[opc@webserver1 ~]$ sudo stress --cpu 4 --timeout 60
stress: info: [12194] dispatching hogs: 4 cpu, 0 io, 0 vm, 0 hdd
stress: info: [12194] successful run completed in 60s

Alarm occurrence confirmation

  1. You can check the history of the created Alarm below.

    image-20220117114655575

  2. Confirm receipt of alarm mail

    image-20220117114840447



As an individual, this article was written with my personal time. There may be errors in the content of the article, and the opinions in the article are personal opinions.

Last updated on 17 Jan 2022