amazon-web-services - 使用 create_export_task 将日志从 cloudwatch 导出到 s3 不会丢失一些日志
问题描述
我正在尝试将 cloudwatch 中过去 15 分钟的访问日志导出到 S3 存储桶,但是在运行它时,它成功地将日志存储到 S3 中,但是丢失了很多日志。例如,在过去 15 分钟的 cloudwatch 中,有 30 条日志,而在 S3 中它只有大约 3 条日志。
group_name = '/aws/elasticbeanstalk/my-env/var/app/current/storage/logs/laravel.log'
s3 = boto3.client('s3')
log_file = boto3.client('logs')
now = datetime.now()
deletionDate = now - timedelta(minutes=15)
start = math.floor(deletionDate.replace(second=0, microsecond=0).timestamp()*1000)
end = math.floor(now.replace(second=0, microsecond=0).timestamp()*1000)
destination_bucket = 'past15mins-log'
prefix = 'lambda2-test-log/'+str(start)+'-'+str(end)
# # TODO implement
response = log_file.create_export_task(
logGroupName = group_name,
fromTime = start,
to = end,
destination = destination_bucket,
destinationPrefix = prefix
)
if not response['ResponseMetadata']['HTTPStatusCode'] == 200:
raise Exception('fail ' + str(start)+" - "+ str(end))
在文档中它说这是一个异步调用,我的猜测是因为有 3 个服务器可以从中获取日志,这会导致问题吗?
提前致谢。
解决方案
推荐阅读
- nativescript - 如何在 NativeScript 中隐藏 ScrollView 的滚动条?
- python - 用于heroku部署的pyqt4的正确whl文件是什么
- performance - x86 Windows/Linux 应用程序在最小化页数方面是否有性能提升?
- c# - 有没有混淆 .cmd 文件的方法?
- statistics - 什么统计测试使用 statsmodel 来计算显着性?
- javascript - 复合组件:如何在反应中引用点击的子元素?
- vue.js - VueJS 路由器 $routes.push 无法推送查询参数
- android - 如何通过主页按钮创建活动
- android - 当我单击按钮加载数据时出现运行时异常
- git - 在 git 中合并两个冲突的分支时,如何明确提及要应用哪些分支更改?