Collector "Volcengine-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 |
|---|---|---|---|
targets |
list | Required | List of cloud monitoring target configurations Multiple configurations under the same namespace have a logical relationship of "AND" |
targets[#].namespace |
str | Required | The cloud monitoring namespace to be collected. For example: 'VCM_ECS'See the appendix for the complete list |
targets[#].subnamespace |
str | Required | The cloud monitoring sub-namespace to be collected. For example: 'acs_ecs_dashboard'See the appendix for the complete list |
targets[#].metrics |
list | Required | List of cloud monitoring metric names to be collected See the appendix for the complete list |
targets[#].metrics[#] |
str | Required | Metric name |
2. Configuration Examples¶
Specifying Specific Metrics¶
Collect the 2 metrics named CpuTotal and MemoryUsedSpace in ECS.
collector_configs = {
'targets': [
{
'namespace': 'VCM_ECS',
'subnamespace':'Instance',
'metrics' : ['CpuSystem', 'CpuTotal', 'MemoryUsedSpace'],
},
]
}
Wildcard Matching Metrics¶
Metric names can use the * wildcard for matching.
In this example, the following metrics will be collected:
- Metric named
MemoryUsedSpace - Metrics starting with
Cpu - Metrics ending with
Connection - Metrics containing
Used
collector_configs = {
'targets': [
{
'namespace': 'VCM_ECS',
'subnamespace':'Instance',
'metrics' : ['MemoryUsedSpace', 'Cpu*', '*Connection', '*Used*'],
},
],
}
Excluding 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:
- Metric named
MemoryUsedSpace - Metrics starting with
Cpu - Metrics ending with
Connection - Metrics containing
Used
collector_configs = {
'targets': [
{
'namespace': 'VCM_ECS',
'subnamespace':'Instance',
'metrics' : ['NOT', 'MemoryUsedSpace', 'Cpu*', '*Connection', '*Used*'],
},
],
}
Multiple Filters to Specify Required Metrics¶
The same namespace can be specified multiple times, and metrics will be filtered sequentially from top to bottom.
In this example, the metric names are filtered through the following steps:
- Select all metrics containing
Cpuin their names. - From the previous result, exclude the metric named
CpuTotal.
collector_configs = {
'targets': [
{
'namespace': 'VCM_ECS',
'subnamespace':'Instance',
'metrics' : ['*Cpu*'],
},
{
'namespace': 'VCM_ECS',
'subnamespace':'Instance',
'metrics' : ['NOT', 'CpuTotal'],
},
],
}
Configuring Filters (Optional)¶
This collector script supports custom filters, allowing users to filter target resources based on object attributes. The filter function returns True or False.
- True: The target resource needs to be collected.
- False: The target resource does not need to be collected.
# Example: Enable filter, filter based on InstanceId, RegionId attributes, configuration format as follows:
def filter_instance(instance, namespace='VCM_ECS'):
'''
Collect metrics with InstanceId as i-xxxxxa, i-xxxxxb and RegionId as cn-hangzhou
'''
instance_id = instance['tags'].get('InstanceId')
status = instance['tags'].get('Status')
if instance_id in ['i-xxxxxa', 'i-xxxxxb'] and status in ['RUNNING']:
return True
return False
from integration_core__runner import Runner
import integration_volcengine_monitor__main as main
@DFF.API('Volcengine-Monitor Collection', 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 Reporting Format¶
After data is successfully synchronized, you can view the data in the "Metrics" section of Guance.
Take the following collector configuration as an example:
collector_configs = {
'targets': [
{
'namespace': 'VCM_ECS',
'subnamespace':'Instance',
'metrics' : ['CpuTotal', 'MemoryUsedSpace'],
},
],
}
The reported data example is as follows:
{
"measurement": "volcengine_VCM_ECS",
"tags": {
"ResourceID": "i-xxxx"
},
"fields": {
"CpuTotal" : 1.23,
"MemoryUsedSpace": 1.23
}
}
Tip
All metric values will be reported as float type.
4. Interaction with Custom Object Collectors¶
When other custom object collectors (such as ECS, mysql) are running in the same DataFlux Func, this collector will automatically try to match the tags.name field in the custom objects based on fields like tags.ResourceID.
Since it is necessary to first obtain custom object information for interaction in cloud monitoring collectors, it is generally recommended to place the cloud monitoring collector at the end of the list, for example:
# Create collectors
collectors = [
main.DataCollector(account, collector_configs),
monitor_main.DataCollector(account, monitor_configs)
]
When a successful match is made, all fields except name from the custom object tags will be added to the monitoring data tags, thereby enabling effects such as filtering cloud monitoring metric data using instance names. The specific effect is as follows:
Assume the raw data collected by cloud monitoring is as follows:
{
"measurement": "volcengine_VCM_ECS",
"tags": {
"ResourceID": "i-xxxx",
"{key}": "{value}"
},
"fields": {
"{metric}": "{metric_value}"
}
}
At the same time, the custom object data collected by the Volcengine ECS collector is as follows:
{
"measurement": "volcengine_VCM_ECS",
"tags": {
"name" : "i-xxxx",
"InstanceId": "i-xxxx",
"RegionId" : "cn-shanghai",
"{key}": "{value}"
},
"fields": {
"{key}": "{value}"
}
}
Then, the final reported cloud monitoring data is as follows:
{
"measurement": "volcengine_VCM_ECS",
"tags": {
"instanceId": "i-xxxx",
"RegionId" : "cn-beijing",
"{key}": "{value}"
},
"fields": {
"{metric}": "{metric_value}"
}
}
5. Cloud Monitoring API Call Rate Limit Explanation¶
-
Volcengine has a rate limit on the GetMetricData API: For a primary account and its IAM accounts, the number of GetMetricData API calls per second should not exceed 20, otherwise rate limiting will be triggered. (Currently, it is only rate-limited, no charges are applied).
-
How to avoid API call rate limiting caused by multiple auto-triggered tasks executing simultaneously: Since the collector supports multi-threaded collection by default and there are multiple auto-triggered tasks executing in parallel, it is easy to trigger API rate limiting. Here are two suggestions to mitigate API rate limiting:
-
Set a small value for the environment variable
COLLECTOR_THREAD_POOL_SIZE; - Delay the execution of auto-triggered tasks to avoid multiple tasks calling the API at the same time. Add the
delayed_crontabparameter to the startup function decoratorDFF.API(xxx), wheredelayed_crontabis the delay execution parameter, in seconds. For example, the following configuration will execute the task at the 5th second of every minute:
Note: Please adjust the above suggestions based on the task execution time to find suitable parameters.
X. Appendix¶
Please refer to the official Volcengine documentation: