Box Event logs are sometimes delayed.

Highlighted
First-time Contributor

Box Event logs are sometimes delayed.

Hello,

 

I am trying to get shard link eventlog within minutes using Box API, and the logs are usually available without problems.

 

However, sometimes shared link logs are delayed. Usually I can get the logs within few minutes after creating the shared link, but sometimes It takes between 10-60 minutes (of course Box service status is all ok)

 

Check code is as follows.

from boxsdk import JWTAuth
from boxsdk import Client
import datetime
import time

auth = JWTAuth.from_settings_file( 'MY_CONFIG_FILE')
admin_client = Client(auth)

start_time = datetime.datetime.now()
print('Start: {0}'.format(start_time))

user_client = admin_client.as_user(admin_client.user('MY_USER_ID')) 
upload_file = user_client.folder('MY_FOLDER_ID').upload("TEST.txt",file_name='{0}.txt'.format(start_time))
link_url = user_client.file(upload_file.id).get_shared_link(access='open')

is_found = False
while not is_found:
    time.sleep(10)
    events = admin_client.events().get_admin_events(
        created_after='{0:%Y-%m-%dT%H:%M:%S+09:00}'.format(start_time - datetime.timedelta(hours=1) ),   #Get logs within a hour
        event_types=['SHARE', 'ITEM_SHARED_UPDATE'])

    for e in events['entries']:
        if upload_file.name in e.source['item_name']: 
            print('Found: {0}  {1}  [{2}]'.format(datetime.datetime.now(), e.source['item_name'], e.event_type))
            is_found = True

 

How long does it typically take for the logs available after the shared link created? (I want to get it within minutes)
And, is there another way to get the logs immediately?

 

Thanks,
Taisuke

1 REPLY 1
Highlighted
Box Employee

Re: Box Event logs are sometimes delayed.

Hi @taisuke_kita,

 

Apologies for the delay. In the case of events, they are not always processed sequentially, and may be filled into the event logs after later events come through, meaning that you may see events coming 10-60 minutes if there are a larger number of events being processed at the same time. Another possibility is if there were any issues with the events and they were queued / retried for a later time. 

 

With that said, there isn't a definitive number of minutes that I would safely say that all events would be produced within.

 

- Jon