采集器「Azure-Virtual Network Gateway Collection 采集」配置手册¶
阅读本文前,请先阅读:
Tip
使用本采集器前,必须安装「集成 Core 核心包」及其配套的第三方依赖包
1. 配置结构¶
本采集器配置结构如下:
字段 | 类型 | 是否必须 | 说明 |
---|---|---|---|
subscriptions |
list | 非必须 | 所需采集的订阅 ID 列表 |
subscriptions[#] |
str | 订阅 ID | |
locations |
list | 非必须 | 地域列表 |
locations[#] |
str | 地域,例:westus2 |
2. 配置示例¶
无配置¶
不需要额外配置,自动获取已授权订阅下的所有目标资源
指定订阅¶
采集订阅 ID 为:xxxx1
下的所有实例对象
指定订阅和地域¶
采集订阅 ID 为:xxxx1 且在 westus2
,westus
地域下的所有实例对象
配置过滤器(可选项)¶
本采集器脚本支持用户自定义过滤器,让用户通过对象属性筛选出目标资源。过滤器函数返回值为 True|False
-
True:目标资源需要被采集。
-
False 目标资源不需要被采集
支持筛选的对象属性:
属性 | 描述 |
---|---|
name | 资源 ID |
resourceId | 资源 ID (同 name 字段) |
resourceName | 资源名称 |
resourceGroup | 资源组名称 |
location | 资源位置 |
gatewayType | 网关类型:Vpn、LocalGateway、ExpressRoute |
# 示例:开启过滤器,根据对象的 resourceId 过滤,配置格式如下:
def filter_instance(instance):
'''
采集 resourceId 为 xxx 的实例
'''
# return True
r_id = instance['resourceId']
if r_id in ['xxx']:
return True
return False
@DFF.API('Azure-Virtual Network Gateway Collection', timeout=3600, fixed_crontab='*/15 * * * *')
def run():
Runner(main.DataCollector(account, collector_configs, filters=[filter_instance])).run()
3. 数据上报格式¶
数据正常同步后,可以在 观测云 的「基础设施-资源目录」中查看数据。
上报的数据示例如下:
{
"measurement": "azure_network_virtualnetworkgateways",
"tags": {
"cloud_provider" : "azure",
"location" : "westus2",
"RegionId" : "westus2",
"name" : "/subscriptions/sss/func-resource/providers/microsoft.network/virtualnetworkgateways/ggg",
"resource_group" : "xxx",
"resource_id" : "/subscriptions/sss/func-resource/providers/microsoft.network/virtualnetworkgateways/ggg",
"resource_name" : "ggg",
"subscription_id" : "sss",
"subscription_name": "xxx",
"tenant_id" : "ce9fe5b4-xxxx",
"gateway_type" : "Vpn"
},
"fields": {
"provisioning_state": "Succeeded",
"ip_configurations" : "[IP 配置信息]",
"message" : "{实例 JSON 数据}",
"tags" : "{Azure 控制台配置的 tags}"
}
}
Note
tags、fields 中的字段可能会随后续更新有所变动
Tip
tags.name 值为实例 ID,作为唯一标识
Tip
以下字段均为 JSON 序列化后字符串
fields.message
fields.tags
fields.ip_configurations
X. 附录¶
Azure 相关文档: