采集器「腾讯云-MongoDB」配置手册¶
阅读本文前,请先阅读:
Tip
使用本采集器前,必须安装「集成(核心包)」及其配套的第三方依赖包
1. 配置结构¶
本采集器配置结构如下:
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
regions |
list | 必须 | 所需采集的 MongoDB 地域列表 |
regions[#] |
str | 必须 | 地域 ID。如:'ap-shanghai' 总表见附录 |
2. 配置示例¶
配置过滤器(可选项)¶
本采集器脚本支持用户自定义过滤器,让用户通过对象属性筛选出目标资源。过滤器函数返回值为 True|False
- True:目标资源需要被采集。
- False 目标资源不需要被采集
支持筛选的对象属性:
属性 | 描述 |
---|---|
InstanceId | 实例 ID |
InstanceName | 实例名称 |
InstanceType | 实例类型 |
ClusterType | 集群类型 |
MongoVersion | 实例版本信息 |
NetType | 网络类型 |
PayMode | 付费类型 |
ProjectId | 项目 ID |
Status | 实例当前状态 |
VpcId | 私有网络的ID |
Zone | 可用区信息 |
# 示例:开启过滤器,根据对象的 InstanceId 和 VpcId 属性过滤,配置格式如下:
def filter_instance(instance):
'''
return True|False
'''
instance_id = instance['InstanceId']
vpc_id = instance['VpcId']
if instance_id in ['xxx'] and vpc_id in ['yyy']:
return True
return False
###### Do not modify the following contents #####
from integration_core__runner import Runner
import integration_tencentcloud_mongodb__main as main
def run():
Runner(main.DataCollector(account, collector_configs, filters=[filter_instance])).run()
3. 数据上报格式¶
数据正常同步后,可以在 观测云 的「基础设施-资源目录」中查看数据。
上报的数据示例如下:
{
"measurement": "tencentcloud_mongodb",
"tags": {
"ClusterType" : "0",
"InstanceId" : "cmxxxx",
"InstanceName": "test_01",
"InstanceType": "1",
"MongoVersion": "MONxxxx",
"NetType" : "1",
"PayMode" : "0",
"ProjectId" : "0",
"RegionId" : "ap-nanjing",
"Status" : "2",
"VpcId" : "vpc-nf6xxxxx",
"Zone" : "ap-nanjing-1",
"name" : "cmxxxx"
},
"fields": {
"CloneInstances" : "[]",
"CreateTime" : "2022-08-24 13:54:00",
"DeadLine" : "2072-08-24 13:54:00",
"ReadonlyInstances": "[]",
"RelatedInstance" : "{实例 JSON 数据}",
"ReplicaSets" : "{实例 JSON 数据}",
"StandbyInstances" : "[]",
"message" : "{实例 JSON 数据}",
}
}
部分字段说明如下,具体可看附录接口返回参数
字段 | 类型 | 说明 |
---|---|---|
ClusterType |
string | 集群类型 0:副本集实例 1:分片实例 |
status |
string | 实例状态 0:待初始化 1:流程处理中 2:运行中 -2:实例已过期 |
InstanceType |
string | 实例类型 1:正式实例 2:临时实例 3:只读实例 4:灾备实例 |
NetType |
string | 网络类型 0:基础网络 1:私有网络 |
PayMode |
string | 付费类型 1:包年包月 0:按量计费 |
Note
tags、fields 中的字段可能会随后续更新有所变动
Tip
tags.name 值为实例 ID,作为唯一标识
Tip
fields.message 为 JSON 序列化后字符
X. 附录¶
请参考华为云官方文档: