from datetime import datetime
import json


def transform_to_log_line(log_event):
    """
    Transforms the CloudWatch log events into string log lines suitable
    for consumption by the Timber API.
    """
    timestamp = log_event['timestamp']
    dt = datetime.utcfromtimestamp(timestamp / 1000.0)
    datetime_iso8601 = dt.isoformat() + 'Z'
    message = log_event['message']
    log_line = {'dt': datetime_iso8601, 'message': message}
    json_log_line = json.dumps(log_line)
    return json_log_line