Auto-scaling for instances
Configure Autoscaling in Red Hat OpenStack Platform
Abstract
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
We appreciate your input on our documentation. Tell us how we can make it better.
Providing documentation feedback in Jira
Use the Create Issue form to provide feedback on the documentation for Red Hat OpenStack Services on OpenShift (RHOSO) or earlier releases of Red Hat OpenStack Platform (RHOSP). When you create an issue for RHOSO or RHOSP documents, the issue is recorded in the RHOSO Jira project, where you can track the progress of your feedback.
To complete the Create Issue form, ensure that you are logged in to Jira. If you do not have a Red Hat Jira account, you can create an account at https://issues.redhat.com.
- Click the following link to open a Create Issue page: Create Issue
- Complete the Summary and Description fields. In the Description field, include the documentation URL, chapter or section number, and a detailed description of the issue. Do not modify any other fields in the form.
- Click Create.
Chapter 1. Introduction to autoscaling components Copy linkLink copied to clipboard!
Use telemetry components to collect data about your Red Hat OpenStack Platform (RHOSP) environment, such as CPU, storage, and memory usage. You can launch and scale instances in response to workload demand and resource availability. You can define the upper and lower bounds of telemetry data that control the scaling of instances in your Orchestration service (heat) templates.
Control automatic instance scaling with the following telemetry components:
- Data collection: Telemetry uses the data collection service (Ceilometer) to gather metric and event data.
- Storage: Telemetry stores metrics data in the time-series database service (gnocchi).
- Alarm: Telemetry uses the Alarming service (aodh) to trigger actions based on rules against metrics or event data collected by Ceilometer.
1.1. Data collection service (Ceilometer) for autoscaling Copy linkLink copied to clipboard!
You can use Ceilometer to collect data about metering and event information for Red Hat OpenStack Platform (RHOSP) components.
The Ceilometer service uses three agents to collect data from RHOSP components:
- A compute agent (ceilometer-agent-compute): Runs on each Compute node and polls for resource use statistics.
- A central agent (ceilometer-agent-central): Runs on the Controller nodes to poll for resource use statistics for resources that are not provided by Compute nodes.
- A notification agent (ceilometer-agent-notification): Runs on the Controller nodes and consumes messages from the message queues to build event and metering data.
The Ceilometer agents use publishers to send data to the corresponding end points, for example the time-series database service (gnocchi).
Additional resources
- Ceilometer in the Managing overcloud observability guide.
1.1.1. Publishers Copy linkLink copied to clipboard!
In Red Hat OpenStack Platform (RHOSP), you can use several transport methods to transfer the collected data into storage or external systems, such as Service Telemetry Framework (STF).
When you enable the gnocchi publisher, the measurement and resource information is stored as time-series data.
1.2. Time-series database service (gnocchi) for autoscaling Copy linkLink copied to clipboard!
Gnocchi is a time-series database that you can use for storing metrics in SQL. The Alarming service (aodh) and Orchestration service (heat) use the data stored in gnocchi for autoscaling.
Additional resources
1.3. Alarming service (aodh) Copy linkLink copied to clipboard!
You can configure the Alarming service (aodh) to trigger actions based on rules against metrics data collected by Ceilometer and stored in gnocchi. Alarms can be in one of the following states:
- Ok: The metric or event is in an acceptable state.
-
Firing: The metric or event is outside of the defined
Ok
state. - insufficient data: The alarm state is unknown, for example, if there is no data for the requested granularity, or the check has not been executed yet, and so on.
1.4. Orchestration service (heat) for autoscaling Copy linkLink copied to clipboard!
Director uses Orchestration service (heat) templates as the template format for the overcloud deployment. Heat templates are usually expressed in YAML format. The purpose of a template is to define and create a stack, which is a collection of resources that heat creates, and the configuration of the resources. Resources are objects in Red Hat OpenStack Platform (RHOSP) and can include compute resources, network configuration, security groups, scaling rules, and custom resources.
Chapter 2. Configuring and deploying the overcloud for autoscaling Copy linkLink copied to clipboard!
You must configure the templates for the services on your overcloud that enable autoscaling.
Procedure
- Create environment templates and a resource registry for autoscaling services before you deploy the overcloud for autoscaling. For more information, see Section 2.1, “Configuring the overcloud for autoscaling”
- Deploy the overcloud. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”
2.1. Configuring the overcloud for autoscaling Copy linkLink copied to clipboard!
Create the environment templates and resource registry that you need to deploy the services that provide autoscaling.
Procedure
-
Log in to the undercloud host with your overcloud administrator credentials, for example
overcloudrc
. Create a directory for the autoscaling configuration files:
mkdir -p $HOME/templates/autoscaling/
$ mkdir -p $HOME/templates/autoscaling/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the resource registry file for the definitions that the services require for autoscaling:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an environment template to configure the services required for autoscaling:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use Red Hat Ceph Storage as the data storage back end for the time-series database service, add the following parameters to your
parameters-autoscaling.yaml
file:parameter_defaults: GnocchiRbdPoolName: 'metrics' GnocchiBackend: 'rbd'
parameter_defaults: GnocchiRbdPoolName: 'metrics' GnocchiBackend: 'rbd'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must create the defined archive policy
generic
before you can store metrics. You define this archive policy after the deployment. For more information, see Section 3.1, “Creating the generic archive policy for autoscaling”.-
Set the
polling_interval
parameter, for example, 60 seconds. The value of thepolling_interval
parameter must match the gnocchi granularity value that you defined when you created the archive policy. For more information, see Section 3.1, “Creating the generic archive policy for autoscaling”. - Deploy the overcloud. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”
2.2. Deploying the overcloud for autoscaling Copy linkLink copied to clipboard!
You can deploy the overcloud for autoscaling by using director.
Prerequisites
- You have created the environment templates for deploying the services that provide autoscaling capabilities. For more information, see Section 2.1, “Configuring the overcloud for autoscaling”.
2.2.1. Deploying the overcloud for autoscaling by using director Copy linkLink copied to clipboard!
Use director to deploy the overcloud.
Prerequisites
- A deployed undercloud. For more information, see Installing director on the undercloud.
Procedure
-
Log in to the undercloud as the
stack
user. Source the
stackrc
undercloud credentials file:source ~/stackrc
[stack@director ~]$ source ~/stackrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the autoscaling environment files to the stack with your other environment files and deploy the overcloud:
openstack overcloud deploy --templates \ -e [your environment files] \ -e $HOME/templates/autoscaling/parameters-autoscaling.yaml \ -e $HOME/templates/autoscaling/resources-autoscaling.yaml
(undercloud)$ openstack overcloud deploy --templates \ -e [your environment files] \ -e $HOME/templates/autoscaling/parameters-autoscaling.yaml \ -e $HOME/templates/autoscaling/resources-autoscaling.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Verifying the overcloud deployment for autoscaling Copy linkLink copied to clipboard!
Verify that the autoscaling services are deployed and enabled. The verification output examples might be different from your use case.
Prerequisites
- You have deployed the autoscaling services in an existing overcloud using director. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”.
Procedure
-
Log in to your environment as the
stack
user. For director environments, source the
overcloudrc
overcloud credentials file:source ~/overcloudrc
$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the deployment was successful and ensure that the service API endpoints for autoscaling are available:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the overcloud credentials to check the heat service:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the services are running on the overcloud:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the time-series database service is available:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Using the heat service for autoscaling Copy linkLink copied to clipboard!
After you deploy the services required to provide autoscaling in the overcloud, you must configure the overcloud environment so that the Orchestration service (heat) can manage instances for autoscaling.
Prerequisites
- A deployed overcloud. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”.
Procedure
3.1. Creating the generic archive policy for autoscaling Copy linkLink copied to clipboard!
After you deploy the services for autoscaling in the overcloud, you must configure the overcloud environment so that the Orchestration service (heat) can manage the instances for autoscaling.
Prerequisites
- You have deployed an overcloud that has autoscaling services. For more information, see Section 2.1, “Configuring the overcloud for autoscaling”.
Procedure
-
Log in to your environment as the
stack
user. For director environments source the
overcloudrc
overcloud credentials file:source ~/overcloudrc
$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the archive policy defined in
$HOME/templates/autoscaling/parameters-autoscaling.yaml
:openstack metric archive-policy create generic \ --back-window 0 \ --definition timespan:'4:00:00',granularity:'0:01:00',points:240 \ --aggregation-method 'rate:mean' \ --aggregation-method 'mean'
$ openstack metric archive-policy create generic \ --back-window 0 \ --definition timespan:'4:00:00',granularity:'0:01:00',points:240 \ --aggregation-method 'rate:mean' \ --aggregation-method 'mean'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the archive policy was created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Configuring a heat template for automatically scaling instances Copy linkLink copied to clipboard!
You can configure an Orchestration service (heat) template to create the instances, and configure alarms that create and scale instances when triggered.
This procedure uses example values that you must change to suit your environment.
Prerequisites
- You have deployed the overcloud with the autoscaling services. For more information, see Section 2.2, “Deploying the overcloud for autoscaling”.
- You have configured the overcloud with an archive policy for autoscaling telemetry storage. For more information, see Section 3.1, “Creating the generic archive policy for autoscaling”.
Procedure
Log in to your environment as the
stack
user.source ~/overcloudrc
$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a directory to hold the instance configuration for the autoscaling group:
mkdir -p $HOME/templates/autoscaling/vnf/
$ mkdir -p $HOME/templates/autoscaling/vnf/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create an instance configuration template, for example,
$HOME/templates/autoscaling/vnf/instance.yaml
. Add the following configuration to your
instance.yaml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
The
parameters
parameter defines the custom parameters for this new resource. -
The
vnf
sub-parameter of theresources
parameter defines the name of the custom sub-resource referred to in theOS::Heat::AutoScalingGroup
, for example,OS::Nova::Server::VNF
.
-
The
Create the resource to reference in the heat template:
$ cat <<EOF > $HOME/templates/autoscaling/vnf/resources.yaml resource_registry: "OS::Nova::Server::VNF": $HOME/templates/autoscaling/vnf/instance.yaml EOF
$ cat <<EOF > $HOME/templates/autoscaling/vnf/resources.yaml resource_registry: "OS::Nova::Server::VNF": $HOME/templates/autoscaling/vnf/instance.yaml EOF
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the deployment template for heat to control instance scaling:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteOutputs on the stack are informational and are not referenced in the ScalingPolicy or AutoScalingGroup. To view the outputs, use the
openstack stack show <stack_name>
command.
3.3. Creating the stack deployment for autoscaling Copy linkLink copied to clipboard!
Create the stack deployment for the worked VNF autoscaling example.
Procedure
Log in to the undercloud host with your overcloud administrator credentials, for example
overcloudrc
:source ~/overcloudrc
(undercloud)$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must first launch the ephemeral Heat process to use the
openstack stack
commands:openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db export OS_CLOUD=heat
(undercloud)$ openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db (undercloud)$ export OS_CLOUD=heat
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the stack:
openstack stack create \ -t $HOME/templates/autoscaling/vnf/template.yaml \ -e $HOME/templates/autoscaling/vnf/resources.yaml \ vnf
$ openstack stack create \ -t $HOME/templates/autoscaling/vnf/template.yaml \ -e $HOME/templates/autoscaling/vnf/resources.yaml \ vnf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the stack was created successfully:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the stack resources were created, including alarms, scaling policies, and the autoscaling group:
export STACK_ID=$(openstack stack show vnf -c id -f value)
$ export STACK_ID=$(openstack stack show vnf -c id -f value)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that an instance was launched by the stack creation:
openstack server list --long | grep $STACK_ID
$ openstack server list --long | grep $STACK_ID | 62e1b27c-8d9d-44a5-a0f0-80e7e6d437c7 | vn-dvaxcqb-6bqh2qd2fpif-hicmkm5dzjug-vnf-ywrydc5wqjjc | ACTIVE | None | Running | private=192.168.100.61, 192.168.25.99 | fedora36 | a6aa7b11-1b99-4c62-a43b-d0b7c77f4b72 | m1.small | 5cd46fec-50c2-43d5-89e8-ed3fa7660852 | nova | host-80.localdomain | metering.server_group='cb082cbd-535e-4779-84b0-98925e103f5e' |
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the alarms were created for the stack:
List the alarm IDs. The state of the alarms might reside in the
insufficient data
state for a period of time. The minimal period of time is the polling interval of the data collection and data storage granularity setting:Copy to Clipboard Copied! Toggle word wrap Toggle overflow List the resources for the stack and note the
physical_resource_id
values for thecpu_alarm_high
andcpu_alarm_low
resources.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The value of the
physical_resource_id
must match thealarm_id
in the output of theopenstack alarm list
command.
Verify that metric resources exist for the stack. Set the value of the
server_group
query to the stack ID:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that measurements exist for the instance resources created through the stack:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the ephemeral Heat process from the undercloud:
openstack tripleo launch heat --kill
(undercloud)$ openstack tripleo launch heat --kill
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. Testing and troubleshooting autoscaling Copy linkLink copied to clipboard!
Use the Orchestration service (heat) to automatically scale instances up and down based on threshold definitions. To troubleshoot your environment, you can look for errors in the log files and history records.
4.1. Testing automatic scaling up of instances Copy linkLink copied to clipboard!
You can use the Orchestration service (heat) to scale instances automatically based on the cpu_alarm_high
threshold definition. When the CPU use reaches a value defined in the threshold
parameter, another instance starts up to balance the load. The threshold
value in the template.yaml
file is set to 80%.
Procedure
-
Log in to the host environment as the
stack
user. For director environments source the
overcloudrc
file:source ~/overcloudrc
$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Log in to the instance:
ssh -i ~/mykey.pem cirros@192.168.122.8
$ ssh -i ~/mykey.pem cirros@192.168.122.8
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run multiple
dd
commands to generate the load:sudo dd if=/dev/zero of=/dev/null & sudo dd if=/dev/zero of=/dev/null & sudo dd if=/dev/zero of=/dev/null &
[instance ~]$ sudo dd if=/dev/zero of=/dev/null & [instance ~]$ sudo dd if=/dev/zero of=/dev/null & [instance ~]$ sudo dd if=/dev/zero of=/dev/null &
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Exit from the running instance and return to the host.
After you run the
dd
commands, you can expect to have 100% CPU use in the instance. Verify that the alarm has been triggered:Copy to Clipboard Copied! Toggle word wrap Toggle overflow After approximately 60 seconds, Orchestration starts another instance and adds it to the group. To verify that an instance has been created, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After another short period of time, observe that the Orchestration service has autoscaled to three instances. The configuration is set to a maximum of three instances. Verify there are three instances:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2. Testing automatic scaling down of instances Copy linkLink copied to clipboard!
You can use the Orchestration service (heat) to automatically scale down instances based on the cpu_alarm_low
threshold. In this example, the instances are scaled down when CPU use is below 5%.
Procedure
From within the workload instance, terminate the running
dd
processes and observe Orchestration begin to scale the instances back down.killall dd
$ killall dd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Log in to the host environment as the
stack
user. For director environments source the
overcloudrc
file:source ~/overcloudrc
$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow When you stop the
dd
processes, this triggers thecpu_alarm_low event
alarm. As a result, Orchestration begins to automatically scale down and remove the instances. Verify that the corresponding alarm has triggered:Copy to Clipboard Copied! Toggle word wrap Toggle overflow After a few minutes, Orchestration continually reduce the number of instances to the minimum value defined in the
min_size
parameter of thescaleup_group
definition. In this scenario, themin_size
parameter is set to1
.
4.3. Troubleshooting for autoscaling Copy linkLink copied to clipboard!
If your environment is not working properly, you can look for errors in the log files and history records.
Procedure
-
Log in to the host environment as the
stack
user. For director environments source the
overcloudrc
file:source ~/overcloudrc
$ source ~/overcloudrc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must first launch the ephemeral Heat process to use the
openstack stack
commands:openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db export OS_CLOUD=heat
(undercloud)$ openstack tripleo launch heat --heat-dir /home/stack/overcloud-deploy/overcloud/heat-launcher --restore-db (undercloud)$ export OS_CLOUD=heat
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To retrieve information on state transitions, list the stack event records:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Read the alarm history log:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To view the records of scale-out or scale-down operations that heat collects for the existing stack, you can use the
awk
command to parse theheat-engine.log
:awk '/Stack UPDATE started/,/Stack CREATE completed successfully/ {print $0}' /var/log/containers/heat/heat-engine.log
$ awk '/Stack UPDATE started/,/Stack CREATE completed successfully/ {print $0}' /var/log/containers/heat/heat-engine.log
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To view aodh-related information, examine the
aodh-evaluator.log
:sudo grep -i alarm /var/log/containers/aodh/aodh-evaluator.log | grep -i transition
$ sudo grep -i alarm /var/log/containers/aodh/aodh-evaluator.log | grep -i transition
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the ephemeral Heat process from the undercloud:
openstack tripleo launch heat --kill
(undercloud)$ openstack tripleo launch heat --kill
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Using CPU telemetry values for autoscaling threshold when using rate:mean aggregration Copy linkLink copied to clipboard!
When using the OS::Heat::Autoscaling
heat orchestration template (HOT) and setting a threshold value for CPU, the value is expressed in nanoseconds of CPU time which is a dynamic value based on the number of virtual CPUs allocated to the instance workload. In this reference guide we’ll explore how to calculate and express the CPU nanosecond value as a percentage when using the Gnocchi rate:mean
aggregration method.
4.4.1. Calculating CPU telemetry values as a percentage Copy linkLink copied to clipboard!
CPU telemetry is stored in Gnocchi (OpenStack time-series data store) as CPU utilization in nanoseconds. When using CPU telemetry to define autoscaling thresholds it is useful to express the values as a percentage of CPU utilization since that is more natural when defining the threshold values. When defining the scaling policies used as part of an autoscaling group, we can take our desired threshold defined as a percentage and calculate the required threshold value in nanoseconds which is used in the policy definitions.
Value (ns) | Granularity (s) | Percentage |
---|---|---|
60000000000 | 60 | 100 |
54000000000 | 60 | 90 |
48000000000 | 60 | 80 |
42000000000 | 60 | 70 |
36000000000 | 60 | 60 |
30000000000 | 60 | 50 |
24000000000 | 60 | 40 |
18000000000 | 60 | 30 |
12000000000 | 60 | 20 |
6000000000 | 60 | 10 |
4.4.2. Displaying instance workload vCPU as a percentage Copy linkLink copied to clipboard!
You can display the gnocchi-stored CPU telemetry data as a percentage rather than the nanosecond values for instances by using the openstack metric aggregates
command.
Prerequisites
- Create a heat stack using the autoscaling group resource that results in an instance workload.
Procedure
- Login to your OpenStack environment as the cloud adminstrator.
Retrieve the ID of the autoscaling group heat stack:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the value of the stack ID to an environment variable:
export STACK_ID=$(openstack stack show vnf -c id -f value)
$ export STACK_ID=$(openstack stack show vnf -c id -f value)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Return the metrics as an aggregate by resource type instance (server ID) with the value calculated as a percentage. The aggregate is returned as a value of nanoseconds of CPU time. We divide that number by 1000000000 to get the value in seconds. We then divide the value by our granularity, which in this example is 60 seconds. That value is then converted to a percentage by multiplying by 100. Finally, we divide the total value by the number of vCPU provided by the flavor assigned to the instance, in this example a value of 2 vCPU, providing us a value expressed as a percentage of CPU time:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4.3. Retrieving available telemetry for an instance workload Copy linkLink copied to clipboard!
Retrieve the available telemetry for an instance workload and express the vCPU utilization as a percentage.
Prerequisites
- Create a heat stack using the autoscaling group resource that results in an instance workload.
Procedure
- Login to your OpenStack environment as the cloud adminstrator.
Retrieve the ID of the autoscaling group heat stack:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the value of the stack ID to an environment variable:
export STACK_ID=$(openstack stack show vnf -c id -f value)
$ export STACK_ID=$(openstack stack show vnf -c id -f value)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the ID of the workload instance you want to return data for. We are using the server list long form and filtering for instances that are part of our autoscaling group:
openstack server list --long --fit-width | grep "metering.server_group='$STACK_ID'"
$ openstack server list --long --fit-width | grep "metering.server_group='$STACK_ID'" | bc1811de-48ed-44c1-ae22-c01f36d6cb02 | vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e | ACTIVE | None | Running | private=192.168.100.139, 192.168.25.179 | fedora36 | d21f1aaa-0077-4313-8a46-266c39b705c1 | m1.small | 692533fe-0912-417e-b706-5d085449db53 | nova | host.localdomain | metering.server_group='e0a15cee-34d1-418a-ac79-74ad07585730' |
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the instance ID for one of the returned instance workload names:
INSTANCE_NAME='vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e' ; export INSTANCE_ID=$(openstack server list --name $INSTANCE_NAME -c ID -f value)
$ INSTANCE_NAME='vn-xlfb4jb-yhbq6fkk2kec-qsu2lr47zigs-vnf-y27wuo25ce4e' ; export INSTANCE_ID=$(openstack server list --name $INSTANCE_NAME -c ID -f value)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify metrics have been stored for the instance resource ID. If no metrics are available it’s possible not enough time has elapsed since the instance was created. If enough time has elapsed, you can check the logs for the data collection service in
/var/log/containers/ceilometer/
and logs for the time-series database service gnocchi in/var/log/containers/gnocchi/
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify there are available measures for the resource metric and note the granularity value as we’ll use it when running the
openstack metric aggregates
command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the number of vCPU cores applied to the workload instance by reviewing the configured flavor for the instance workload:
openstack server show $INSTANCE_ID -cflavor -f value openstack flavor show 692533fe-0912-417e-b706-5d085449db53 -c vcpus -f value
$ openstack server show $INSTANCE_ID -cflavor -f value m1.small (692533fe-0912-417e-b706-5d085449db53) $ openstack flavor show 692533fe-0912-417e-b706-5d085449db53 -c vcpus -f value 2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Return the metrics as an aggregate by resource type instance (server ID) with the value calculated as a percentage. The aggregate is returned as a value of nanoseconds of CPU time. We divide that number by 1000000000 to get the value in seconds. We then divide the value by our granularity, which in this example is 60 seconds (as previously retrieved with
openstack metric measures show
command). That value is then converted to a percentage by multiplying by 100. Finally, we divide the total value by the number of vCPU provided by the flavor assigned to the instance, in this example a value of 2 vCPU, providing us a value expressed as a percentage of CPU time:Copy to Clipboard Copied! Toggle word wrap Toggle overflow