跳转至

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

阅读本文前,请先阅读:

使用本采集器前,必须安装「观测云集成 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地域对应项目的 Dcs 实例数据

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

配置过滤器(可选项)

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

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

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

支持筛选的对象属性:

属性 描述
instance_id 实例 ID
instance_name 实例名称
engine 实例引擎
engine_version 实例引擎版本
status 实例状态
az_codes 有资源的可用区编码
port 端口
ip IP 地址
charging_mode 计费模式
enable_publicip 是否开启公网访问功能
spec_code 产品规格编码
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 示例:开启过滤器,根据实例对象的 instance_id 属性过滤,配置格式如下:
def filter_instance(instance):
    '''
    采集 instance_id 为 xxxx 的实例
    '''
    instance_id = instance.get('instance_id')
    if instance_id in ['xxx']:
        return True
    return False


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


@DFF.API('HuaweiCloud-DCS 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
{
  "measurement": "huaweicloud_redis",
  "tags": {
    "name"              : "71be0037-xxxx-xxxx-xxxx-b6b91f134066",
    "instance_id"       : "71be0037-xxxx-xxxx-xxxx-b6b91f134066",
    "instance_name"     : "dcs-iash",
    "RegionId"          : "cn-north-4",
    "project_id"        : "c631f04625xxxxxxxxxxf253c62d48585",
    "engine"            : "Redis",
    "engine_version"    : "5.0",
    "status"            : "RUNNING",
    "az_codes"          : "[\"cn-north-4c\", \"cn-north-4a\"]",
    "port"              : "6379",
    "ip"                : "192.xxx.x.144",
    "charging_mode"     : "0",
    "no_password_access": "true",
    "enable_publicip"   : "False"
  },
  "fields": {
    "created_at" : "2022-07-12T07:29:56.875Z",
    "max_memory" : 128,
    "used_memory": 2,
    "capacity"   : 0,
    "description": "",
    "message"    : "{实例 JSON 数据}"
  }
}

部分字段说明如下:

字段 类型 说明
ip String 连接缓存实例的 IP 地址。如果是集群实例,返回多个 IP 地址,使用逗号分隔。如:192.168.0.1,192.168.0.2。
charging_mode String 计费模式,0 表示按需计费,1 表示包年/包月计费。
no_password_access String 是否允许免密码访问缓存实例:
true:该实例无需密码即可访问。
false:该实例必须通过密码认证才能访问
enable_publicip String Redis 缓存实例是否开启公网访问功能
True:开启
False:不开启
max_memory Integer 总内存,单位:MB。
used_memory Integer 已使用的内存,单位:MB。
capacity Integer 缓存容量(G Byte)。
status String CREATING :申请缓存实例后,在缓存实例状态进入运行中之前的状态。
CREATEFAILED:缓存实例处于创建失败的状态。
RUNNING:缓存实例正常运行状态。
RESTARTING:缓存实例正在进行重启操作。
FROZEN:缓存实例处于已冻结状态,用户可以在“我的订单”中续费开启冻结的缓存实例。
EXTENDING:缓存实例处于正在扩容的状态。
RESTORING:缓存实例数据恢复中的状态。
FLUSHING:缓存实例数据清空中的状态。

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

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

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

  • fields.message
  • tags.az_codes

X. 附录

华为云 Dcs「地域 ID」

请参考华为云官方文档: