跳转至

采集器「AWS-VPC-Endpoint」配置手册

阅读本文前,请先阅读:

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

1. 配置结构

本采集器配置结构如下:

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

2. 配置示例

采集北京地域的实例数据

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

配置过滤器(可选项)

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

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

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

支持筛选的对象属性:

属性 描述
VpcId VPC ID
VpcEndpointId Endpoint 的 ID
State Endpoint 的状态
VpcEndpointType Endpoint 的ID
ServiceName 与端点关联的服务的名称
PrivateDnsEnabled (接口端点)指示 VPC 是否与私有宿主区域关联
RequesterManaged 指示端点是否由其服务管理
OwnerId 拥有端点的 AmazonWeb 服务帐户的 ID
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 示例:开启过滤器,根据对象的 VpcEndpointId 和 State 属性过滤,配置格式如下:
def filter_instance(instance):
    '''
    return True|False
    '''
    instance_id = instance['VpcEndpointId']
    state = instance['State']
    if instance_id in ['xxx'] and state in ['xxx']:
        return True
    return False

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


@DFF.API('AWS-VPC Endpoint Collection', timeout=3600, fixed_crontab='* * * * *')
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
24
25
26
{
  "measurement": "aws_vpc_endpoint",
  "tags": {
    "OwnerId"          : "xxxx",
    "PrivateDnsEnabled": "False",
    "RegionId"         : "cn-north-1",
    "RequesterManaged" : "False",
    "ServiceName"      : "com.amazonaws.cn-north-1.s3",
    "State"            : "available",
    "VpcEndpointId"    : "vpce-xxx",
    "VpcEndpointType"  : "Gateway",
    "VpcId"            : "vpc-xxx",
    "name"             : "vpce-xxx"
  },
  "fields": {
    "CreationTimestamp"  : "2023-11-22T06:19:15Z",
    "DnsEntries"         : "[(接口端点)端点的 DNS 条目]",
    "Groups"             : "[(接口端点)有关与网络接口关联的安全组的信息]",
    "NetworkInterfaceIds": "[(接口端点)端点的网络接口]",
    "PolicyDocument"     : "{与端点关联的策略文档(如果适用)}",
    "RouteTableIds"      : "[(网关端点)与端点关联的路由表的 ID]",
    "SubnetIds"          : "[(接口端点)端点的子网]",
    "Tags"               : "[分配给端点的标记]",
    "message"            : "{实例 JSON 数据}"
  }
}

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

4. IAM 策略权限

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

该采集器需要以下权限:

ec2:DescribeVpcEndpoints

X. 附录

请参考 AWS 官方文档: