跳转至

采集器「腾讯云-Memcached」配置手册

阅读本文前,请先阅读:

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

1. 配置结构

本采集器配置结构如下:

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

2. 配置示例

指定地域

采集上海、广州地域的数据

Python
1
2
3
collector_configs = {
    'regions': [ 'ap-shanghai', 'ap-guangzhou' ]
}

配置过滤器(可选项)

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

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

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

支持筛选的对象属性:

属性 描述
AutoRenewFlag 实例是否设置自动续费标识,1:设置自动续费;0:未设置自动续费
Status 实例当前状态,0:发货中;1:运行中;2:创建失败;4:销毁中;5:隔离中;6:下线中
CmemId 实例内置ID
InstanceId 实例ID
InstanceName 实例名称
ZoneId 区域ID
PayMode 计费模式:0-按量计费,1-包年包月
AppId 用户AppID
Vport 实例端口号
Python
 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
# 示例:开启过滤器,根据对象的 InstanceId 和 name 属性过滤,配置格式如下:
def filter_instance(instance):
    '''
    采集 instance_id 为 xxxx 并且 instance_name 为 xxx 的实例
    '''
    # return True
    instance_id = instance['InstanceId']
    instance_name = instance['InstanceName']
    if instance_id in ['xxxx'] and instance_name in ['xxx']:
        return True
    return False


###### Do not modify the following contents #####
from guance_integration__runner import Runner
import guance_tencentcloud_memcached__main as memcached_main
import guance_tencentcloud_monitor__main as monitor_main


@DFF.API('TencentCloud-Memcached Collection', timeout=3600, fixed_crontab='* * * * *')
def run():
    collectors = [
        memcached_main.DataCollector(account, collector_configs, filter_instance=filter_instance),
    ]
    Runner(collectors).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
{
  "measurement": "tencentcloud_memcached",
  "tags": {
    "AppId"         : "1311317185",
    "AutoRenewFlag" : "0",
    "CmemId"        : "100007773",
    "InstanceId"    : "cmem-xxxxxxx",
    "InstanceName"  : "cmem-xxxxxx",
    "PayMode"       : "0",
    "RegionId"      : "ap-shanghai",
    "Status"        : "1",
    "Vport"         : "9101",
    "ZoneId"        : "200005",
    "name"          : "cmem-xxxx"
  },
  "fields": {
    "AddTimeStamp"     : "2023-08-18 14:51:02",
    "DeadlineTimeStamp": "0001-01-01 08:05:43",
    "Expire"           : 0,
    "InstanceDesc"     : "cmem-aaaekm1p",
    "ModTimeStamp"     : "2023-08-18 14:51:08",
    "message"          : "{实例 JSON 数据}"
  }
}

部分参数说明如下

字段 类型 说明
AutoRenewFlag String 实例是否设置自动续费标识,1:设置自动续费;0:未设置自动续费
CmemId String 实例内置ID
PayMode String 计费模式:0-按量计费,1-包年包月
Status String 实例当前状态,0:发货中;1:运行中;2:创建失败;4:销毁中;5:隔离中;6:下线中
AddTimeStamp String 实例创建时间
DeadlineTimeStamp String 实例截止时间
Expire Integer 过期策略

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

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

X. 附录

请参考腾讯云官方文档: