跳转至

采集器「华为云-RDS-MySQL」配置手册

阅读本文前,请先阅读:

使用本采集器前,必须安装「观测云集成 Core 核心包」及其配套的第三方依赖包

1. 配置结构

本采集器配置结构如下:

字段 类型 是否必须 说明
region_projects dict 必须 所需采集数据的「地域 - 项目 ID」列表
region_projects[#] str:list 必须 键值对中:
Key 代表地域(如:'cn-north-4'
Value 代表该地域下所需采集的项目 ID 列表
总表见附录
enterprise_project_id str 企业项目 ID(详细信息见附录)

2. 配置示例

指定地域

采集cn-north-4地域对应项目的 RDS-MySQL 实例数据

Python
1
2
3
4
5
6
collector_configs = {
    'enterprise_project_id': 'xxxxxxx',
    'region_projects': {
        'cn-north-4': ['c631f046252d4exxxxxxxxxxx', '15c6ce1c12da40xxxxxxxx9'],
    }
}

配置过滤器(可选项)

本采集器脚本支持用户自定义过滤器,让用户通过对象属性筛选出目标资源。过滤器函数返回值为 True|False

  • True:目标资源需要被采集。

  • False 目标资源不需要被采集

支持筛选的对象属性:

属性 描述
name 实例 ID
id 实例 ID
instance_name 实例 名称
status 实例状态
port 实例端口
type 实例类型
security_group_id 安全组 ID
switch_strategy 切换策略
time_zone 实例时区
enable_ssl 是否开启 SSL
engine 实例引擎
engine_version 实例引擎类型
charge_info.charge_mode 实例收费类型
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 示例:开启过滤器,根据对象的 id 和 name 属性过滤,配置格式如下:
def filter_instance(instance):
    '''
    采集 instance_id 为 'xxxx' 或 instance_name 为 'xxxx' 的实例
    '''
    # return True
    instance_id = instance['id']
    instance_name = instance['instance_name']
    if instance_id in ['xxxx'] and instance_name in ['xxxx']:
        return True
    return False


###### Do not modify the following contents #####
from guance_integration__runner import Runner
import guance_huaweicloud_rds__main as main


@DFF.API('HuaweiCloud-RDS-MySQL Collection', timeout=3600, fixed_crontab='*/15 * * * *')
def run():
    Runner(main.DataCollector(account, collector_configs, filters=[filter_instance])).run()

3. 数据上报格式

数据正常同步后,可以在观测云的「基础设施 / 自定义(对象)」中查看数据。

上报的数据示例如下:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "measurement": "huaweicloud_rds",
  "tags": {
    "name"                   : "1d0c91561f4644daxxxxx68304b0520din01",
    "id"                     : "1d0c91561f4644dxxxxxxd68304b0520din01",
    "instance_name"          : "rds-df54-xxxx",
    "status"                 : "ACTIVE",
    "port"                   : "3306",
    "type"                   : "Single",
    "RegionId"               : "cn-north-4",
    "security_group_id"      : "d13ebb59-d4fe-xxxx-xxxx-c22bcea6f987",
    "switch_strategy"        : "xxx",
    "project_id"             : "c631f046252dxxxxxxxf253c62d48585",
    "time_zone"              : "UTC+08:00",
    "enable_ssl"             : "False",
    "charge_info.charge_mode": "postPaid",
    "engine"                 : "MySQL",
    "engine_version"         : "5.7"
  },
  "fields": {
    "created_time"    : "2022-06-21T06:17:27+0000",
    "updated_time"    : "2022-06-21T06:20:03+0000",
    "alias"           : "xxx",
    "private_ips"     : "[\"192.xxx.x.144\"]",
    "public_ips"      : "[]",
    "datastore"       : "{数据库信息}",
    "cpu"             : "2",
    "mem"             : "4",
    "volume"          : "{volume 信息}",
    "nodes"           : "[{主备实例信息}]",
    "related_instance": "[]",
    "backup_strategy" : "{备份策略}",
    "message"         : "{实例 JSON 数据}"
  }
}

tags、fields 中的字段可能会随后续更新有所变动

tags.name 值为实例 ID,作为唯一标识

以下字段均为 JSON 序列化后字符串

  • fields.message
  • fields.private_ips
  • fields.public_ips
  • fields.volume
  • fields.nodes
  • fields.related_instance
  • fields.backup_strategy

type 取值为 Single、Ha、Replica 或 Enterprise,分别对应于单机实例、主备实例、只读实例、分布式实例(企业版)

X. 附录

华为云 RDS-MySQL「地域 ID」

请参考华为云官方文档: