Collector "Huawei Cloud - Cloud Monitoring" Configuration Manual¶
Before reading this document, please read:
Tip
Before using this collector, you must install "Integration Core" and its accompanying third-party dependencies.
Tip
This collector supports multi-threading by default (five threads are enabled by default). If you need to change the thread pool size, you can set the environment variable COLLECTOR_THREAD_POOL_SIZE
.
1. Configuration Structure¶
The configuration structure of this collector is as follows:
Field | Type | Required | Description |
---|---|---|---|
regions |
list | Required | List of regions to be collected |
regions[#] |
str | Required | Region ID. For example: 'cn-north-4' See the appendix for the complete list |
targets |
list | Required | Cloud monitoring collection object configuration list The logical relationship between multiple configurations with the same namespace is "AND" |
targets[#].namespace |
str | Required | Cloud monitoring namespace to be collected. For example: SYS.OBS See the appendix for the complete list |
targets[#].metrics |
list | Required | List of metric names under the cloud service to be collected |
targets[#].metrics[#] |
str | Required | Metric name pattern, supports "ALL" , "NOT" , and wildcard matchingThe logical relationship between multiple patterns is "OR" When the "NOT" tag is included, the logical relationship between multiple patterns is "AND"See below for details |
Tip
The collector will automatically obtain all IAM projects under the region, and then obtain resources based on the IAM projects.
2. Configuration Examples¶
Specify Specific Metrics¶
Collect the 2 metrics named capacity_total
and capacity_archive
in SYS.OBS
.
huaweicloud_ces_configs = {
'regions': ['cn-north-4'],
'targets': [
{
'namespace': 'SYS.OBS',
'metrics' : ['capacity_total', 'capacity_archive']
}
]
}
Wildcard Matching Metrics¶
Metric names can be matched using the *
wildcard.
In this example, the following metrics will be collected:
- Metrics named
capacity_total
- Metrics starting with
capacity
- Metrics ending with
total
- Metrics containing
capacity
huaweicloud_ces_configs = {
'regions': ['cn-north-4'],
'targets': [
{
'namespace': 'SYS.OBS',
'metrics' : ['capacity_total', 'capacity*', '*total', '*capacity*']
}
]
}
Exclude Specific Metrics¶
Adding the "NOT"
tag at the beginning indicates that the following metrics will be excluded.
In this example, the following metrics will [not] be collected:
- Metrics named
capacity_total
- Metrics starting with
capacity
- Metrics ending with
total
- Metrics containing
capacity
huaweicloud_ces_configs = {
'regions': ['cn-north-4'],
'targets': [
{
'namespace': 'SYS.OBS',
'metrics' : ['NOT', 'capacity_total', 'capacity*', '*total', '*capacity*']
}
]
}
Multiple Filters to Specify Required Metrics¶
The same namespace can be specified multiple times, and the metrics will be filtered sequentially from top to bottom.
In this example, the following filtering steps are performed on the metric names:
- Select all metrics containing
capacity
in their names. - From the results of the previous step, exclude metrics named
capacity_total
.
huaweicloud_ces_configs = {
'regions': ['cn-north-4'],
'targets': [
{
'namespace': 'SYS.OBS',
'metrics' : ['*capacity*']
},
{
'namespace': 'SYS.OBS',
'metrics' : ['NOT', 'capacity_total']
}
]
}
Configure Filters (Optional)¶
This collector script supports user-defined filters to allow users to filter target resources based on object attributes. The filter function returns True or False.
- True: The target resource should be collected.
- False: The target resource should not be collected.
Huawei Cloud Cloud Monitoring supports filtering object attributes that are consistent with the tags of cloud servers (ECS), cloud databases (RDS, Redis), load balancers (ELB), and object storage (OBS) custom objects:
# Example: Enable the filter to filter based on the instance_id and name attributes of the object. The configuration format is as follows:
def filter_instance(instance, namespace='A'):
'''
Collect metrics with namespace A and id xxxx
'''
# return True
instance_id = instance['tags'].get('id')
if instance_id in ['xxx']:
return True
return False
###### Do not modify the following contents #####
from integration_core__runner import Runner
import integration_huaweicloud_ces__main as main
@DFF.API('HuaweiCloud-Cloud monitoring and acquisition', timeout=3600, fixed_crontab='*/5 * * * *')
def run():
Runner(main.DataCollector(account, collector_configs, filters=[filter_instance])).run()
Tip
When multiple filters are configured under the same namespace, all filters must be satisfied for the data to be reported.
3. Data Collection Instructions¶
Cloud Product Configuration Information¶
Product Name | Namespace (Namespace) | Dimension (Dimension) | Description |
---|---|---|---|
Object Storage Service | SYS.OBS |
instance_id |
|
Elastic Cloud Server | SYS.ECS |
instance_id |
Basic monitoring metrics of Elastic Cloud Server |
Operating System Monitoring in Elastic Cloud Server | AGT.ECS |
instance_id |
Operating system monitoring metrics of Elastic Cloud Server (Agent installed, simplified version) |
Relational Database | SYS.RDS |
rds_cluster_id postgresql_cluster_id rds_cluster_sqlserver_id |
Corresponding to MySQL PostgreSQL SQL Server |
Elastic Load Balancing | SYS.ELB |
lbaas_instance_id |
|
Distributed Cache Service | SYS.DCS |
dcs_instance_id |
|
Bare Metal Server | SERVICE.BMS |
instance_id |
Monitoring metrics supported by Bare Metal Server (Agent installed, simplified version) |
Document Database Service | SYS.DDS |
mongodb_instance_id |
Tip
Bare Metal Server Metrics In the documentation, there are metrics with the prefix mountPointPrefix_, such as mountPointPrefix_disk_free. In actual collection, such metrics do not exist. If you need to specify the metric disk_free, you can ignore the mountPointPrefix_ prefix and directly configure disk_free.
Tip
For the master-slave instance types (Ha, Replica) of relational databases, some metrics are node-level and do not support supplementary custom objects.
Cache Mechanism¶
Huawei Cloud Cloud Monitoring introduces a cache mechanism when obtaining metric dimension information. If users frequently create and delete instances, they need to wait for 1 hour before the collector starts collecting new monitoring data.
4. Data Reporting Format¶
After data is successfully synchronized, you can view the data in the "Metrics" section of TrueWatch.
Take the following collector configuration as an example:
huaweicloud_ces_configs = {
'regions': ['cn-north-4'],
'targets': [
{
'namespace': 'SYS.OBS',
'metrics' : ['capacity_total']
}
]
}
The reported data example is as follows:
{
"measurement": "huaweicloud_SYS.OBS",
"tags": {
"bucket_name": "i-xxx"
},
"fields": {
"capacity_total_average" : "{...}",
"capacity_total_max" : "{...}",
"capacity_total_min" : "{...}",
"capacity_total_sum" : "{...}",
"capacity_total_variance": "{...}"
}
}
Tip
All metric values will be reported as float type.
Tip
This collector collects the capacity_total metric data under the SYS.OBS namespace (Namespace). For details, see the Data Collection Instructions table.
5. Interaction with Custom Object Collectors¶
When other custom object collectors (e.g., OBS) are running in the same DataFlux Func, this collector will supplement fields based on the dimension information in the Data Collection Instructions table. For example, OBS attempts to match the bucket_name
field returned by cloud monitoring data with the tags.name
field in the custom object.
Since it is necessary to know the custom object information in advance for interaction in the cloud monitoring collector, it is generally recommended to place the cloud monitoring collector at the end of the list, such as:
# Create collectors
collectors = [
huaweicloud_obs.DataCollector(account, common_huaweicloud_configs),
huaweicloud_ces.DataCollector(account, huaweicloud_ces_configs) # Cloud monitoring collector is usually placed last
]
When a successful match is made, additional fields from the tags of the matched custom object will be added to the tags of the cloud monitoring data, thereby achieving effects such as filtering cloud monitoring metric data using instance names. The specific effect is as follows:
Assume the original data collected by cloud monitoring is as follows:
{
"measurement": "huaweicloud_SYS.OBS",
"tags": {
"bucket_name": "i-xxx"
},
"fields": {
"key": "value"
}
}
At the same time, the custom object data collected by the Huawei Cloud OBS collector is as follows:
{
"measurement": "huaweicloud_cvm",
"tags": {
"name" : "xxx",
"bucket_type" : "xxx",
"PlatformDetails": "xxx",
"{...}" : "{...}"
},
"fields": {
"key": "value"
}
}
Then, the final reported cloud monitoring data is as follows:
{
"measurement": "huaweicloud_SYS.OBS",
"tags": {
"name" : "xxx",
"bucket_name" : "xxx", // Original field from cloud monitoring
"bucket_type" : "xxx", // Field from custom object OBS
"PlatformDetails" : "xxx", // Field from custom object OBS
"{...}"
},
"fields": {
"key": "value"
}
}
6. Troubleshooting¶
When running the program, you may encounter the following error:
Reason: The task execution time is too long, causing a timeout.
Solution:
- Reduce the number of collected metrics, clarify requirements, and only collect the metrics you actually need.
- Appropriately increase the timeout setting of the startup function, such as:
# Set the timeout to 120 seconds
@DFF.API('Execute collection', timeout=120)
def run():
# Specific code omitted
pass
7. Cloud Monitoring Call Count Instructions¶
Tip
Huawei Cloud has no restrictions on the number of calls to the cloud monitoring interfaces used in this script, and they are free to use.
X. Appendix¶
Huawei Cloud Cloud Monitoring¶
Please refer to the official Huawei Cloud documentation: