采集器「华为云-Kafka」配置手册¶
阅读本文前,请先阅读:
Tip
使用本采集器前,必须安装「集成 Core 核心包」及其配套的第三方依赖包
1. 配置结构¶
本采集器配置结构如下:
配置一(推荐)
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
regions |
list | 必须 | 所需采集的地域列表 |
regions[#] |
str | 必须 | 地域 ID。如:'cn-north-4' 总表见附录 |
Tip
采集器会自动获取地域下的所有 IAM 项目,再根据 IAM 项目获取资源
配置二(旧版兼容)
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
region_projects |
dict | 必须 | 所需采集数据的「地域 - 项目 ID」列表 |
region_projects[#] |
str:list | 必须 | 键值对中: Key 代表地域(如: 'cn-north-4' )Value 代表该地域下所需采集的项目 ID 列表 总表见附录 |
2. 配置示例¶
配置过滤器(可选项)¶
本采集器脚本支持用户自定义过滤器,让用户通过对象属性筛选出目标资源。过滤器函数返回值为 True|False
-
True:目标资源需要被采集。
-
False 目标资源不需要被采集
支持筛选的对象属性:
属性 | 描述 |
---|---|
engine | 实例引擎 |
status | 实例状态 |
instance_id | 实例 ID |
port | 端口 |
type | 实例类型:集群,cluster |
def filter_instance(instance):
'''
采集 实例id 为 xxxx 的实例
'''
instance_id = instance.get('instance_id')
if instance_id in ['xxx']:
return True
return False
###### Do not modify the following contents ######
from integration_core__runner import Runner
import integration_huaweicloud_kafka__main as kafka_main
import integration_huaweicloud_ces__main as ces_main
@DFF.API('HuaweiCloud Kafka Collection', timeout=3600, fixed_crontab='* * * * *')
def run():
collectors = [
kafka_main.DataCollector(account, collector_configs, filter_instance=filter_instance),
]
Runner(collectors).run()
3. 数据上报格式¶
数据正常同步后,可以在 观测云 的「基础设施-资源目录」中查看数据。
上报的数据示例如下:
{
"measurement": "huaweicloud_kafka",
"tags": {
"RegionId" : "cn-north-4",
"project_id" : "f5f4c067d68xxxx86e173b18367bf",
"enterprise_project_id": "0",
"name" : "beb33e02-xxxx-xxxx-xxxx-628a3994fd1f",
"instance_id" : "beb33e02-xxxx-xxxx-xxxx-628a3994fd1f",
"instance_name" : "xxx",
"status" : "RUNNING",
},
"fields": {
"charging_mode" : "1",
"connect_address" : "192.168.0.161,192.168.0.126,192.168.0.31",
"description" : "",
"engine" : "kafka",
"engine_version" : "2.7",
"kafka_manager_user" : "",
"name" : "beb33e02-xxxx-xxxx-xxxx-628a3994fd1f",
"port" : "9092",
"resource_spec_code" : "",
"service_type" : "advanced",
"specification" : "kafka.2u4g.cluster.small * 3 broker",
"storage_type" : "hec",
"user_id" : "e4b27d49128e4bd0893b28d032a2e7c0",
"user_name" : "xxxx",
"created_at" : "1693203968959",
"maintain_begin" : "02:00:00",
"maintain_end" : "06:00:00",
"storage_space" : 186,
"total_storage_space" : 300,
"message" : "{实例 JSON 数据}"
}
}
部分字段说明如下:
字段 | 类型 | 说明 |
---|---|---|
specification |
String | 实例规格。 |
charging_mode |
String | 付费模式,1表示按需计费,0表示包年/包月计费。 |
created_at |
String | 完成创建时间。格式为时间戳,指从格林威治时间 1970年01月01日00时00分00秒起至指定时间的偏差总毫秒数。 |
resource_spec_code |
String | 资源规格 |
maintain_begin |
String | 维护时间窗开始时间,格式为HH:mm:ss |
maintain_end |
String | 维护时间窗结束时间,格式为HH:mm:ss |
Note
tags、fields 中的字段可能会随后续更新有所变动
Tip
tags.name 值为实例 ID,作为唯一标识
Tip
fields.message 为 JSON 序列化后字符串
X. 附录¶
请参考华为云官方文档: