通过拉取 VPC 流日志来估算 GuardDuty 成本
Estimating GuardDuty costs by pulling VPC flow logs
我正在尝试估算 GuardDuty 每月要花多少钱,根据 https://aws.amazon.com/guardduty/pricing/ 我应该看看我一个月生成多少 cloudtrail 日志以及多少 VPC 日志(以 GB 为单位)我生产一个月。
使用 boto3 S3 我可以计算我的存储桶中有多少日志,这告诉我我将花费多少让 GuardDuty 读取我的日志。现在我想知道我的 VPC 日志产生了多少 GB 的数据,但我似乎无法弄清楚我可以从哪里提取此类信息。我想以编程方式查看我每月生成多少 GB 的 VPC 流日志,以最好地估计我将在 GD 上花费多少。
此代码段用于展示如何获取与 VPC 中每个网络接口关联的 VPC 流日志的大小。您必须修改脚本以获取整个月的日志并对其求和。
import boto3
logs = boto3.client('logs')
# List the log groups and identify the VPC flow log group
for log in logs.describe_log_groups()['logGroups']:
print log['logGroupName']
# Get the logstreams in 'vpc-flow-logs'
for log in logs.describe_log_streams(logGroupName='vpc-flow-logs')['logStreams']:
print log['logStreamName'], log['storedBytes']
Lists the log streams for the specified log group. You can list all
the log streams or filter the results by prefix. You can also control
how the results are ordered.
This operation has a limit of five transactions per second, after which transactions are throttled.
请求语法
response = client.describe_log_streams(
logGroupName='string',
logStreamNamePrefix='string',
orderBy='LogStreamName'|'LastEventTime',
descending=True|False,
nextToken='string',
limit=123
)
我正在尝试估算 GuardDuty 每月要花多少钱,根据 https://aws.amazon.com/guardduty/pricing/ 我应该看看我一个月生成多少 cloudtrail 日志以及多少 VPC 日志(以 GB 为单位)我生产一个月。
使用 boto3 S3 我可以计算我的存储桶中有多少日志,这告诉我我将花费多少让 GuardDuty 读取我的日志。现在我想知道我的 VPC 日志产生了多少 GB 的数据,但我似乎无法弄清楚我可以从哪里提取此类信息。我想以编程方式查看我每月生成多少 GB 的 VPC 流日志,以最好地估计我将在 GD 上花费多少。
此代码段用于展示如何获取与 VPC 中每个网络接口关联的 VPC 流日志的大小。您必须修改脚本以获取整个月的日志并对其求和。
import boto3
logs = boto3.client('logs')
# List the log groups and identify the VPC flow log group
for log in logs.describe_log_groups()['logGroups']:
print log['logGroupName']
# Get the logstreams in 'vpc-flow-logs'
for log in logs.describe_log_streams(logGroupName='vpc-flow-logs')['logStreams']:
print log['logStreamName'], log['storedBytes']
Lists the log streams for the specified log group. You can list all the log streams or filter the results by prefix. You can also control how the results are ordered.
This operation has a limit of five transactions per second, after which transactions are throttled.
请求语法
response = client.describe_log_streams(
logGroupName='string',
logStreamNamePrefix='string',
orderBy='LogStreamName'|'LastEventTime',
descending=True|False,
nextToken='string',
limit=123
)