unable to extra/list all event log on watson assistant wrokspace

旧巷老猫 提交于 2019-12-24 18:20:19

问题


Please help I was trying to call watson assistant endpoint https://gateway.watsonplatform.net/assistant/api/v1/workspaces/myworkspace/logs?version=2018-09-20 to get all the list of events

and filter by date range using this params

var param =
{ workspace_id: '{myworkspace}',
page_limit: 100000,
filter: 'response_timestamp%3C2018-17-12,response_timestamp%3E2019-01-01'}

apparently I got any empty response below.

{
"logs": [],
"pagination": {}
} 

回答1:


Couple of things to check.

1. You have 2018-17-12 which is a metric date. This translates to "12th day of the 17th month of 2018".

2. Assuming the date should be a valid one, your search says "Documents that are Before 17th Dec 2018 and after 1st Jan 2019". Which would return no documents.

3. Logs are only generated when you call the message() method through the API. So check your logging page in the tooling to see if you even have logs.

4. If you have a lite account logs are only stored for 7 days and then deleted. To keep logs longer you need to upgrade to a standard account.

Although not directly related to your issue, be aware that page_limit has an upper hard coded limit (IIRC 200-300?). So you may ask for 100,000 records, but it won't give it to you.


This is sample python code (unsupported) that is using pagination to read the logs:

from watson_developer_cloud import AssistantV1

username = '...'
password = '...'
workspace_id = '....'
url = '...'
version = '2018-09-20'

c = AssistantV1(url=url, version=version, username=username, password=password)

totalpages = 999
pagelimit = 200
logs = []
page_count = 1
cursor = None
count = 0

x = { 'pagination': 'DUMMY' }
while x['pagination']:
    if page_count > totalpages: 
        break

    print('Reading page {}. '.format(page_count), end='')
    x = c.list_logs(workspace_id=workspace_id,cursor=cursor,page_limit=pagelimit)
    if x is None: break

    print('Status: {}'.format(x.get_status_code()))
    x = x.get_result()

    logs.append(x['logs'])
    count = count + len(x['logs'])

    page_count = page_count + 1

    if 'pagination' in x and 'next_url' in x['pagination']:
        p = x['pagination']['next_url']
        u = urlparse(p)
        query = parse_qs(u.query)
        cursor = query['cursor'][0]

Your logs object should contain the logs.




回答2:


I believe the limit is 500, and then we return a pagination URL so you can get the next 500. I dont think this is the issue but once you start getting logs back its good to know



来源:https://stackoverflow.com/questions/54219693/unable-to-extra-list-all-event-log-on-watson-assistant-wrokspace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!