[英]FAILD status when export query result from Google Vault API
I'm using Google Vault API (python script) to query message data from google chat.我正在使用 Google Vault API(python 脚本)从 Google 聊天中查询消息数据。 I have about 1800 emails but when I queried from the 1000th email to 1050th email, the export status returned FAILED without any error message and there was no error message.
我有大约 1800 封电子邮件,但是当我从第 1000 个 email 到第 1050 个 email 查询时,导出状态返回 FAILED,没有任何错误消息,也没有错误消息。 Then when I queried from 1050th to 1100th email, the file was exported normally.
然后我从第1050到第1100查询email,文件正常导出。
Considering that there are some anomalies in the emails from 1000 to 1050, I tried to queried from 1000 to 1010, from 1010 to 1020,… from 1040 to 1050. But at this time they all worked!考虑到从1000到1050的邮件有一些异常,我尝试从1000到1010,从1010到1020,……从1040到1050进行查询。但是此时它们都起作用了!
I need to build a system to automate this process, so I cannot do it manually like this and query by each 10 emails is so time-consuming.我需要建立一个系统来自动化这个过程,所以我不能像这样手动完成,而且每 10 封电子邮件查询非常耗时。 So please help me to figure out what was wrong so that I can query all 1800 emails at once without FAIED status.
因此,请帮助我找出问题所在,以便我可以一次查询所有 1800 封电子邮件而无需 FAIED 状态。
Here is my query code:这是我的查询代码:
def create_mail_all_data_export(service, matter_id,start_date,end_date,name):
df = pd.read_csv("data_users_2.csv")
email_list = list(df["email"])
email_str = ",".join(email_list)
#print(email_str)
"""
全社員のメールエクスポートを作成
Args:
service : v1 vaultでbuildされたサービス
matter_id : vault案件id
start_date : 検索開始日時
end_date : 検索修了日時
name : ファイル名接頭語
"""
hangout_query_options = {"includeRooms": True}
hangout_query = {
'corpus': 'HANGOUTS_CHAT',
'dataScope': 'ALL_DATA',
'searchMethod': 'ACCOUNT',
'accountInfo': {
"emails": [email_list[1000:1050]]
# "emails": [
# "ga4399hy@g.tdi.co.jp",
# "ga6351ob@g.tdi.co.jp"
# #email_list
# ]
},
'timeZone':"Japan",
"startTime":start_date,
"endTime":end_date,
'hangoutsChatOptions': hangout_query_options,
}
hangout_export_options = {
'exportFormat': 'MBOX'
}
wanted_export = {
'name': name,
'query': hangout_query,
'exportOptions': {
'hangoutsChatOptions': hangout_export_options
}
}
return service.matters().exports().create(
matterId=matter_id, body=wanted_export).execute()
Check your quota and compare them with your usage.检查您的配额并将其与您的使用情况进行比较。
For this为了这
Go to your Cloud Console Go 到您的云控制台
Find the G Suite Vault API under https://console.cloud.google.com/apis/api/vault.googleapis.com/overview?project=**NAME_OF_YOUR_PROJECT* *在https://console.cloud.google.com/apis/api/vault.googleapis.com/overview?project=**NAME_OF_YOUR_PROJECT*下找到 G Suite Vault API *
Check your metrics:检查您的指标:
You can try to edit the quote by clicking on the "pencil"您可以尝试通过单击“铅笔”来编辑报价
Or Request more quota limits or view quotas for your other services on the Quotas page, found in IAM & admin.
或
Request more quota limits or view quotas for your other services on the Quotas page, found in IAM & admin.
under https://console.cloud.google.com/iam-admin/quotas?service=vault.googleapis.com&project=**NAME_OF_YOUR_PROJECT* *根据https://console.cloud.google.com/iam-admin/quotas?service=vault.googleapis.com&project=**NAME_OF_YOUR_PROJECT* *
However, if you are exceeding the per minute quota, the best solution would be to modify your code in such a way that it runs slower.但是,如果您超过了每分钟的配额,最好的解决方案是修改您的代码,使其运行速度变慢。 A good way to do so would be to use Exponential Backoff .
这样做的一个好方法是使用Exponential Backoff 。
Note: The per minute quotas actually can be exceeded for a short amount of time, but once they are exceeded they can take up to 24 hours to be established.注意:每分钟配额实际上可以在短时间内超出,但一旦超出,最长可能需要 24 小时才能建立。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.