采集器「火山引擎-NAT 网关」配置手册¶
阅读本文前,请先阅读:
Tip
使用本采集器前,必须安装「集成 Core 核心包」及其配套的第三方依赖包
1. 配置结构¶
本采集器配置结构如下:
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
regions |
list | 必须 | 所需采集的地域列表 |
regions[#] |
str | 必须 | 地域 ID。如:'cn-shanghai' 总表见附录 |
2. 配置示例¶
指定地域¶
采集上海地域的数据
配置过滤器(可选项)¶
本采集器脚本支持用户自定义过滤器,让用户通过对象属性筛选出目标资源。过滤器函数返回值为 True|False
- True:目标资源需要被采集。
- False:目标资源不需要被采集
支持筛选的对象属性:
属性 | 描述 |
---|---|
NatGatewayId | NAT 网关的 ID |
NatGatewayName | 节点名称 |
Spec | NAT 网关的规格 |
BillingType | NAT 网关计费方式 1: 包年包月。 2:按量计费。 |
VpcId | NAT 网关所属私有网络的 ID |
SubnetId | NAT 网关所属子网的 ID |
ZoneId | NAT 网关所属主可用区的 ID |
NetworkInterfaceId | NAT 网关占用网卡的 ID |
ProjectName | NAT 网关所属项目的名称 |
Status | NAT 网关的状态 Available:可用。 Creating:创建中。 Pending:操作中。 Deleting:删除中。 |
BusinessStatus | NAT 网关是否被锁定 |
# 示例:开启过滤器,根据对象的 Id 属性过滤,配置格式如下:
def filter_instance(instance):
'''
采集 instance_id 为 xxxxx 或者 instance_name 为 xxxxx 的实例
'''
# return True
instance_id = instance['NatGatewayId']
if instance_id in ['xxx']:
return True
return False
###### Do not modify the following contents #####
from integration_core__runner import Runner
import integration_volcengine_nat__main as main
@DFF.API('Volcengine-NAT Collection', timeout=3600, fixed_crontab='* * * * *')
def run():
collectors = [
main.DataCollector(account, collector_configs),
# main.DataCollector(account, collector_configs, filters=[filter_instance]),
]
Runner(collectors).run()
3. 数据上报格式¶
数据正常同步后,可以在 观测云 的「基础设施-资源目录」中查看数据。
上报的数据示例如下:
{
"fields": {
"CreationTime": "2024-04-08T14:01:10+08:00",
"EipAddresses": "[NAT 网关绑定公网 IP 的信息]",
"DnatEntryIds": "{DNAT 规则 ID 列表}",
"ExpiredTime": "",
"Description": "",
"SnatEntryIds": "{SNAT 规则 ID 列表}",
"message": "{实例 JSON 数据}"
},
"measurement": "volcengine_nat",
"tags": {
"BillingType": "2",
"BusinessStatus": "Normal",
"EipAddresses": "{NAT 网关绑定公网 IP 的信息}",
"NatGatewayId": "ngw-xxx",
"NatGatewayName": "xxx",
"NetworkInterfaceId": "eni-xxx",
"ProjectName": "default",
"RegionId": "cn-shanghai",
"Spec": "Small",
"Status": "Available",
"SubnetId": "subnet-xxx",
"VpcId": "vpc-xxx",
"ZoneId": "cn-shanghai-a",
"name": "ngw-xxx"
}
}
Note
tags、fields 中的字段可能会随后续更新有所变动
Tip
tags.name 值为实例 ID,作为唯一标识,fields.message、fields.EipAddresses、fields.DnatEntryIds、fields.SnatEntryIds 均为 JSON 序列化后字符串
X. 附录¶
请参考火山引擎官方文档: