跳转至

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

阅读本文前,请先阅读:

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

1. 配置结构

本采集器配置结构如下:

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

2. 配置示例

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

配置过滤器(可选项)

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

支持筛选的对象属性:

属性 描述
Address 节点访问地址
Hidden 是否为Hidden节点
NodeName 节点名称
Priority 节点优先级
ReplicateSetId 副本集Id
Role 角色
SlaveDelay 主从延迟,单位秒
Status 节点状态
Votes 节点投票权
WanServiceAddress 可用区信息
Zone 节点所在的可用区
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 示例:开启过滤器,根据对象的 InstanceId 和 NodeName 属性过滤,配置格式如下:

def filter_instance(instance):
    '''
    return True|False
    '''
    instance_id = instance.get('InstanceId')
    node_name = instance.get('NodeName')
    if instance_id in ['xxx'] and node_name in ['xxx']:
        return True
    return False

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

def run():
    collectors = [
        main.DataCollector(account, collector_configs, filters=[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
{
  "measurement": "tencentcloud_mongodb_node",
  "tags": {
      "Address"          : "172.xx.xx.x: xx",
      "GroupId"          : "node-primary",
      "Hidden"           : "False",
      "InstanceId"       : "cmgo-xxxx",
      "NodeName"         : "cmgo-xxxx_0-node-primary",
      "Priority"         : "1",
      "RegionId"         : "ap-shanghai",
      "ReplicateSetId"   : "cmgo-xxxx_0",
      "Role"             : "PRIMARY",
      "SlaveDelay"       : "0",
      "Status"           : "NORMAL",
      "Votes"            : "1",
      "WanServiceAddress": "",
      "Zone"             : "ap-shanghai-4",
      "name"             : "cmgo-xxxx_0-node-primary"
  },
  "fields": {
    "message": "{实例 JSON 数据}"
  }
}

部分字段说明如下,具体可看附录接口返回参数

字段 类型 说明
Status string 节点状态
包括:ORMAL/STARTUP/RECOVERING/STARTUP2/UNKNOWN/DOWN/ROLLBACK/REMOVED等

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

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

fields.message 为 JSON 序列化后字符串

X. 附录

请参考华为云官方文档: