使用aws的boto3,我试图运行start query,并使用query id获取结果,但在python脚本中没有达到预期的效果。它返回预期的json输出为start_query,并能够获取queryID。但如果我尝试使用queryID获取查询结果,它返回空的json。
<code>
import boto3
client = boto3.client('logs')
executeQuery = client.start_query(
logGroupName='LOGGROUPNAME',
startTime=STARTDATE,
endTime=ENDDATE,
queryString='fields status',
limit=10000
)
getQueryId=executeQuery.get('queryId')
getQueryResults = client.get_query_results(
queryId=getQueryId
)
</code>
它将 get_query_results 的回复返回为
{'results': [], 'statistics': {'recordsMatched': 0.0, 'recordsScanned': 0.0, 'bytesScanned': 0.0}, 'status': 'Running',
但如果我尝试使用aws cli与脚本生成的queryID,它返回json输出的预期。
有谁能告诉我为什么从boto3 python脚本中不能工作,而在cli中却能工作?
谢谢你。