【发布时间】:2019-05-07 10:46:30
【问题描述】:
所以我是 python 和 AWS/Lambda 的新手,我遇到了一些麻烦。我想使用 boto3 读取 cloudwatch 日志,但它不起作用。当我在 AWS 中运行以下代码时,出现以下错误:
An error occurred during JSON serialization of response: AttributeError("'CloudWatchLogs' object has no attribute 'start_query'",) is not JSON serializable
import boto3
import time
boto_client = boto3.client('logs')
def start_query(query):
current_time = time.time()
response = boto_client.start_query(
logGroupName='app-start-logging',
startTime=current_time,
endTime=current_time - 86400,
queryString=query
)
return response
【问题讨论】:
-
pip freeze 的输出是什么?我能够重现您的错误。我设置了一个 virtualenv 并安装了 boto3,你的代码似乎很开心。尝试 virtualenv 它可能有助于查明问题。
-
我无法在本地运行代码,因为我还没有设置我的机器进行连接。我只是想直接在 AWS lambda 上运行它
-
可以加
import botocore -
可悲的是似乎没有工作。
标签: python-3.x amazon-web-services aws-lambda boto3