Using Prometheus to Monitor ECS Metrics
An Elastic Cloud Server (ECS) is a computing server consisting of the CPU, memory, OS, and Elastic Volume Service (EVS) disk. It supports on-demand allocation and auto scaling. ECSs integrate Virtual Private Cloud (VPC), security group, and Cloud Firewall (CFW) capabilities to create an efficient, reliable, and secure computing environment. This ensures stable and uninterrupted running of services. AOM is a one-stop, multi-dimensional O&M platform for cloud applications. It enables you to monitor real-time running of applications, resources, and services and detect faults in a timely manner, improving O&M automation capability and efficiency. After an ECS is connected to AOM, AOM can monitor the ECS in real time and send alarm notifications.
This section uses the node_network_up metric of an ECS as an example to describe how to use AOM.
Procedure
- Manually Installing UniAgent on the ECS: Manually install UniAgent on the ECS to centrally manage metric collection plug-ins.
- Connecting the ECS to AOM: Collect the ECS metric to AOM through Node Exporter and store it in the Prometheus instance for ECS.
- Setting a Metric Alarm Rule: Create an alarm rule for the ECS metric. If the metric data meets the alarm condition, an alarm will be generated.
Preparation
- You have purchased an ECS. For details, see Purchasing and Using a Linux ECS. If you already have an ECS, skip this step.
- You have subscribed to AOM 2.0 and granted permissions.
Manually Installing UniAgent on the ECS
- Log in to the AOM 2.0 console.
- In the navigation pane, choose Settings. The Global Configuration page is displayed.
- Choose Collection Settings > UniAgent Installation and Configuration to view the UniAgent status of the host.
- If the UniAgent status is Running, UniAgent has been installed. In this case, go to Connecting the ECS to AOM.
- If the UniAgent status is Abnormal, UniAgent is abnormal. In this case, contact technical support.
- If the UniAgent status is Installing, UniAgent is being installed. Wait until the UniAgent is installed.
- If the UniAgent status is Installation failed or Not installed, UniAgent fails to be installed or is not installed on the host. In this case, install it.
- Select the host where UniAgent is to be installed, click Install UniAgent in the upper right corner, and then select Manual.
(When you install UniAgent for the first time, the Manual page is displayed by default.)
- On the Install UniAgent page, set parameters.
Figure 1 Manually installing UniAgent
Table 1 Parameters for manual installation Parameter
Description
Example
UniAgent Version
(Mandatory) UniAgent version.
1.1.6
Access Mode
Mode for connecting to UniAgent. Select Direct access.
Direct access: intended for Huawei Cloud hosts.
Direct access
Installation Command
Command for installing UniAgent. In this example, copy the Linux installation command.
Click
to copy the installation command.
set +o history; curl -k -X GET -m 20 --retry 1 --retry-delay 10 -o /tmp/install_uniagent https://aom-uniagent-xxxxxx/install_uniagent.sh;bash /tmp/install_uniagent -a xxxxxxxxxx -s xxxxxxxxxx -p xxxxxx -d https://aom-uniagent-xxxxxx -m https://uniagent.master.cnxxxxxx,https://xx.xx.xx.xx:xxxx -v 1.x.x -q false set -o history;
Copy the Linux installation command.
- Log in to the ECS and run the Linux installation command copied in 5 as the root user.
- Check the UniAgent status in the UniAgent list. If the UniAgent status is Running, the installation is successful.
Connecting the ECS to AOM
- Log in to the AOM 2.0 console.
- In the navigation tree on the left, choose Access > Access Center.
- On the Prometheus Running Environments panel, click the Elastic Cloud Server (ECS) card.
- On the Procedure tab page of the ECS dialog box, perform operations as prompted.
- Create a Prometheus instance for ECS: Click Create Instance. In the displayed dialog box, set related parameters.
Table 2 Parameters for creating a Prometheus instance for ECS Parameter
Description
Example
Instance Name
Prometheus instance name.
Enter a maximum of 100 characters and do not start or end with an underscore (_) or hyphen (-). Only letters, digits, underscores, and hyphens are allowed.
mon_ECS
Enterprise Project
Enterprise project.
- If Enterprise Project is set to All on the global settings page, select an enterprise project from the drop-down list here.
- If you have already selected an enterprise project on the global settings page, this option will be grayed and cannot be changed.
default
Instance Type
Type of a Prometheus instance.
Prometheus for ECS
- Select the Prometheus instance for ECS created in 4.a from the drop-down list.
- Install Node Exporter. Select the target host from the host list and click Install Exporter.
- After the installation is complete, Node Exporter can collect metrics. Click the Collection Tasks tab in the ECS dialog box to check the collection task.
Figure 2 Checking the collection task
- Create a Prometheus instance for ECS: Click Create Instance. In the displayed dialog box, set related parameters.
Setting a Metric Alarm Rule
Metric alarm rules can be created in the following modes: Select from all metrics and PromQL.
The following describes how to create an alarm rule when Configuration Mode is set to Select from all metrics.
- In the navigation pane, choose Alarm Management > Alarm Rules. Then, click Create.
- Set basic information about the alarm rule by referring to Table 3.
Table 3 Basic information Parameter
Description
Example
Rule Name
Name of the rule. Enter a maximum of 256 characters and do not start or end with any special character. Only letters, digits, underscores (_), and hyphens (-) are allowed.
monitor_ecs
Enterprise Project
Select the required enterprise project. The default value is default.
default
Description
Description of the rule. Enter up to 1,024 characters. In this example, leave this parameter blank.
-
- Set the detailed information about the alarm rule.
- Rule Type: Metric alarm rule.
- Configuration Mode: Select from all metrics. Then you can set alarm conditions for different types of resources.
- Select the target Prometheus instance from the drop-down list. In this example, select the instance created in 4.a.
- Set alarm rule details. Table 4 describes the parameters.
After the setting is complete, the monitored metric data is displayed in a line graph above the alarm conditions. You can click Add Metric to add more metrics and set the statistical period and detection rules for them.
Figure 3 Setting alarm rule detailsTable 4 Alarm rule details Parameter
Description
Example
Multiple Metrics
Calculation is performed based on the preset alarm conditions one by one. An alarm is triggered when one of the conditions is met.
Multiple Metrics
Metric
Metric to be monitored. Click the Metric text box. In the resource tree on the right, select a target metric by resource type.
node_network_up
Statistical Period
Interval at which metric data is collected.
1 minute
Conditions
Metric monitoring scope. If this parameter is left blank, all resources are covered. In this example, leave this parameter blank.
-
Grouping Condition
Aggregate metric data by the specified field and calculate the aggregation result.
Not grouped
Rule
Detection rule of a metric alarm, which consists of the statistical mode (Avg, Min, Max, Sum, and Samples), determination criterion (≥, ≤, >, and <), and threshold value.
Avg > 1
Trigger Condition
When the metric value meets the alarm condition for a specified number of consecutive periods, a metric alarm will be generated.
3
Alarm Severity
Severity of a metric alarm.
: a critical alarm.
: a major alarm.
: a minor alarm.
: a warning.
- Click Advanced Settings and set information such as Check Interval and Alarm Clearance. For details about the parameters, see Table 5.
Table 5 Advanced settings Parameter
Description
Example
Check Interval
Interval at which metric query and analysis results are checked.
Custom interval: 1 minute
Alarm Clearance
The alarm will be cleared when the alarm condition is not met for a specified number of consecutive periods.
1
Action Taken for Insufficient Data
Action to be taken if there is no or insufficient metric data within the monitoring period. Enable this option if needed.
Enabled: If the data is insufficient for 1 period, the status will change to Insufficient data and an alarm will be sent.
Alarm Tag
Click
to add an alarm tag. It is an alarm identification attribute in the format of "key:value". It is used in alarm noise reduction scenarios. In this example, leave this parameter blank.
For details, see Alarm Tags and Annotations.
-
Alarm Annotation
Click
to add an alarm annotation. Alarm non-identification attribute in the format of "key:value". It is used in alarm notification and message template scenarios. In this example, leave this parameter blank.
For details, see Alarm Tags and Annotations.
-
- Set an alarm notification policy. For details, see Table 6.
Figure 4 Setting an alarm notification policy
Table 6 Alarm notification policy parameters Parameter
Description
Example
Notify When
Set the scenario for sending alarm notifications. By default, Alarm triggered and Alarm cleared are selected.
- Alarm triggered: If the alarm trigger condition is met, the system sends an alarm notification to the specified personnel by email or SMS.
- Alarm cleared: If the alarm clearance condition is met, the system sends an alarm notification to the specified personnel by email or SMS.
Retain the default value.
Alarm Mode
- Direct alarm reporting: An alarm is directly sent when the alarm condition is met. If you select this mode, set an interval for notification and specify whether to enable an action rule.
- Frequency: frequency for sending alarm notifications. Select a desire value from the drop-down list.
- Action Rule: If you enable this function, the system sends notifications based on the associated SMN topic and message template. If there is no alarm action rule you want to select, click Create Rule in the drop-down list to create one. For details, see Setting an Alarm Action Rule.
- Alarm Mode: Select Direct alarm reporting.
- Frequency: Select Once.
- Action Rule: Select Mon_aom.
- Click Confirm. Then click View Rule to view the created rule.
In the expanded list, if a metric value meets the configured alarm condition, a metric alarm is generated on the alarm page. To view the alarm, choose Alarm Management > Alarm List in the navigation pane. If a metric value meets the preset notification policy, the system sends an alarm notification to the specified personnel by email or SMS.
Figure 5 Creating a metric alarm rule
Related Information
After an alarm rule is configured, you can perform the following operations if needed:
- Choose Alarm Management > Alarm List to check alarms. For details, see Checking Alarms.
- Create metric alarm rules using other methods. For details, see Creating a Metric Alarm Rule.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot