def _show_endpoint_logs(endpoint_name, sagemaker_session):
    log_group = '/aws/sagemaker/Endpoints/{}'.format(endpoint_name)
    try:
        # print out logs before deletion for debuggability
        LOGGER.info('cloudwatch logs for log group {}:'.format(log_group))
        logs = AWSLogs(log_group_name=log_group, log_stream_name='ALL', start='1d',
                       aws_region=sagemaker_session.boto_session.region_name)
        logs.list_logs()
    except Exception:
        LOGGER.exception('Failure occurred while listing cloudwatch log group %s. ' +
                         'Swallowing exception but printing stacktrace for debugging.', log_group)
Exemple #2
0
def _show_logs(resource_name, resource_type, sagemaker_session):
    log_group = '/aws/sagemaker/{}/{}'.format(resource_type, resource_name)
    try:
        # print out logs before deletion for debuggability
        LOGGER.info('cloudwatch logs for log group {}:'.format(log_group))
        logs = AWSLogs(log_group_name=log_group,
                       log_stream_name='ALL',
                       start='1d',
                       aws_region=sagemaker_session.boto_session.region_name)
        logs.list_logs()
    except Exception:
        LOGGER.exception(
            'Failure occurred while listing cloudwatch log group %s. Swallowing exception but printing '
            'stacktrace for debugging.', log_group)
def _cleanup_endpoint_logs(endpoint_name, sagemaker_session):
    log_group = '/aws/sagemaker/Endpoints/{}'.format(endpoint_name)
    try:
        # print out logs before deletion for debuggability
        LOGGER.info('cloudwatch logs for log group {}:'.format(log_group))
        logs = AWSLogs(log_group_name=log_group,
                       log_stream_name='ALL',
                       start='1d',
                       aws_region=sagemaker_session.boto_session.region_name)
        logs.list_logs()

        cwl_client = sagemaker_session.boto_session.client('logs')
        cwl_client.delete_log_group(logGroupName=log_group)
        LOGGER.info('deleted cloudwatch log group: {}'.format(log_group))
    except Exception:
        LOGGER.exception(
            'Failure occurred while cleaning up cloudwatch log group %s. ' +
            'Swallowing exception but printing stacktrace for debugging.',
            log_group)
Exemple #4
0
sys.path.append('~/Library/Python/3.7/lib/python/site-packages')

from awslogs.core import AWSLogs
import awslogs.bin as AWSLogsBin

import inquirer

if __name__ == "__main__":

    if len(sys.argv) == 1:
        print("Please provide log name")
        exit(1)

    searched = sys.argv[1]

    logs = AWSLogs()
    found = []

    for group in logs.get_groups():
        if searched in group:
            found.append(group)

    if len(found) == 0:
        print("No logs found for " + searched)
        exit(1)

    if len(found) == 1:
        group = found[0]

    if len(found) > 1:
        questions = [