跳转至

采集器「AWS-MQ」配置手册

阅读本文前,请先阅读:

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

1. 配置结构

本采集器配置结构如下:

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

2. 配置示例

指定地域

采集宁夏、北京地域的实例数据

Python
1
2
3
collector_configs = {
    'regions': [ 'cn-northwest-1', 'cn-north-1' ]
}

配置过滤器(可选项)

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

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

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

支持筛选的对象属性:

属性 描述
BrokerArn 代理的 ARN
BrokerId AmazonMQ 为代理生成的唯一 ID
BrokerName 代理的名字。此值在您的 Amazon Web 服务帐户中是唯一的
BrokerState Broker 状态
DeploymentMode 代理的部署模式
EngineType 代理类型
HostInstanceType 代理实例类型
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 示例:开启过滤器,根据对象的 BrokerName 和 EngineType 属性过滤,配置格式如下:
def filter_instance(instance):
    '''
    采集 BrokerName 为 xxx 并且 EngineType 为 RabbitMQ 的实例
    '''
    # return True
    borker_name = instance['BrokerName']
    engine_type = instance['EngineType']
    if borker_name in ['xxx'] and engine_type in ['RabbitMQ']:
        return True
    return False


@DFF.API('AWS-MQ Collection', timeout=3600, fixed_crontab='* * * * *')
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
{
  "measurement": "aws_mq",
  "tags": {
    "BrokerArn"       : "arn:xxx1",
    "BrokerId"        : "b-xxx1",
    "BrokerName"      : "xxx1",
    "BrokerState"     : "RUNNING",
    "DeploymentMode"  : "SINGLE_INSTANCE",
    "EngineType"      : "RabbitMQ",
    "HostInstanceType": "mq.m5.large",
    "name"            : "xxx1"
  },
  "fields": {
    "Created": "2024-01-05T07:55:07.687000Z",
    "message": "{实例 JSON 数据}"
  }
}

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

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

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

4. IAM 策略权限

如果用户使用带入 IAM 角色的方式采集资源,需要开启一定的操作权限

该采集器需要以下权限:

mq:ListBrokers

X. 附录

请参考 AWS 官方文档: