跳转至

采集器「火山云-Redis」配置手册

阅读本文前,请先阅读:

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

1. 配置结构

本采集器配置结构如下:

字段 类型 是否必须 说明
regions list 必须 所需采集的地域列表
regions[#] str 必须 地域 ID。如:'cn-beijing'
总表见附录

2. 配置示例

指定地域

采集北京地域的数据

Python
1
2
3
collector_configs = {
    'regions': [ 'cn-beijing' ]
}

配置过滤器(可选项)

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

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

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

支持筛选的对象属性:

属性 描述
InstanceId 实例 ID
InstanceName 实例名称
ChargeType 计费类型
EngineVersion Redis 版本
RegionId 地域 ID
Status 实例状态
VpcId 专用网络 ID
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 示例:开启过滤器,根据对象的 InstanceId 和 name 属性过滤,配置格式如下:
def filter_instance(instance):
    '''
    采集 instance_id 为 xxxxx 或者 instance_name 为 xxxxx 的实例
    '''
    # return True
    instance_id = instance['InstanceId']
    instance_name = instance['name']
    if instance_id in ['xxxxx'] or instance_name in ['xxxxx']:
        return True
    return False


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


@DFF.API('Volcengine-Redis 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
{
  "measurement": "volcengine_redis",
  "tags": {
    "ChargeType": "PostPaid",
    "DeletionProtection": "enabled",
    "EngineVersion": "5.0",
    "InstanceClass": "PrimarySecondary",
    "InstanceId": "redis-xxxx",
    "InstanceName": "redis-xxxx",
    "MultiAZ": "disabled",
    "NodeNumber": "2",
    "ProjectName": "default",
    "RegionId": "cn-beijing",
    "ShardedCluster": "0",
    "Status": "Running",
    "VpcId": "vpc-xxxx",
    "name": "redis-xxxx"
  },
  "fields": {
    "Capacity": "{实例的内存容量信息}",
    "CreateTime": "2024-04-01T06:54:02Z",
    "ExpiredTime": "",
    "ShardCapacity": 0.25,
    "ShardNumber": 1,
    "ZoneIds": "[实例所在的可用区列表]",
    "message": "{实例 JSON 数据}"
  }
}

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

tags.name 值为实例 ID,作为唯一标识,fields.message、fields.AddressObject、fields.ChargeDetail、fields.MaintenanceWindow 均为 JSON 序列化后字符串

X. 附录

请参考火山云官方文档: