Chapter 5. Managing alarms
You can use the alarm service called aodh to trigger actions based on defined rules against metric or event data collected by Ceilometer or Gnocchi.
5.1. Viewing existing alarms Copy linkLink copied to clipboard!
Procedure
List the existing Telemetry alarms:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To list the meters assigned to a resource, specify the UUID of the resource. For example:
openstack resource show 5e3fcbe2-7aab-475d-b42c-a440aa42e5ad
# openstack resource show 5e3fcbe2-7aab-475d-b42c-a440aa42e5ad
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Creating an alarm Copy linkLink copied to clipboard!
You can use aodh to create an alarm that activates when a threshold value is reached. In this example, the alarm activates and adds a log entry when the average CPU utilization for an individual instance exceeds 80%.
Procedure
Create an alarm and use a query to isolate the specific id of the instance (94619081-abf5-4f1f-81c7-9cedaa872403) for monitoring purposes:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To edit an existing threshold alarm, use the aodh alarm update command. For example, to increase the alarm threshold to 75%, use the following command:
openstack alarm update --name cpu_usage_high --threshold 75
# openstack alarm update --name cpu_usage_high --threshold 75
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Disabling an alarm Copy linkLink copied to clipboard!
Procedure
To disable an alarm, enter the following command:
openstack alarm update --name cpu_usage_high --enabled=false
# openstack alarm update --name cpu_usage_high --enabled=false
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Deleting an alarm Copy linkLink copied to clipboard!
Procedure
To delete an alarm, enter the following command:
openstack alarm delete --name cpu_usage_high
# openstack alarm delete --name cpu_usage_high
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5. Example: Monitoring the disk activity of instances Copy linkLink copied to clipboard!
The following example demonstrates how to use an aodh alarm to monitor the cumulative disk activity for all the instances contained within a particular project.
Procedure
Review the existing projects and select the appropriate UUID of the project you want to monitor. This example uses the
admin
tenant:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the project UUID to create an alarm that analyses the
sum()
of all read requests generated by the instances in theadmin
tenant. You can further restrain the query by using the--query
parameter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.6. Example: Monitoring CPU use Copy linkLink copied to clipboard!
To monitor the performance of an instance, examine the Gnocchi database to identify which metrics you can monitor, such as memory or CPU usage.
Procedure
Enter the
openstack metric resource show
command with an instance UUID to identify the metrics you can monitor:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this result, the metrics value lists the components you can monitor using aodh alarms, for example
cpu_util
.To monitor CPU usage, use the
cpu_util
metric:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - archive_policy: Defines the aggregation interval for calculating the std, count, min, max, sum, mean values.
Use aodh to create a monitoring task that queries
cpu_util
. This task triggers events based on the settings that you specify. For example, to raise a log entry when an instance’s CPU spikes over 80% for an extended duration, use the following command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - comparison-operator: The ge operator defines that the alarm triggers if the CPU usage is greater than or equal to 80%.
- granularity: Metrics have an archive policy associated with them; the policy can have various granularities. For example, 5 minutes aggregation for 1 hour + 1 hour aggregation over a month. The granularity value must match the duration described in the archive policy.
- evaluation-periods: Number of granularity periods that need to pass before the alarm triggers. For example, if you set this value to 2, the CPU usage must be over 80% for two polling periods before the alarm triggers.
[u’log://']: When you set
alarm_actions
orok_actions
to[u’log://']
, events, for example, the alarm is triggered or returns to a normal state, are recorded to the aodh log file.NoteYou can define different actions to run when an alarm is triggered (alarm_actions), and when it returns to a normal state (ok_actions), such as a webhook URL.
5.7. Viewing alarm history Copy linkLink copied to clipboard!
To check if your alarm has been triggered, you can query the alarm history.
Procedure
Use the
openstack alarm-history show
command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow