import re


def crush_invalid_field_name(name):
    """
    Log Insight field names must start with an underscore or an alpha character.
    :param name: A proposed field name
    :return: Field name with invalid characters replaced by underscores (_), and runs of underscores
    """
    if name[0].isdigit():
        name = "_%s" % name
    name = re.sub(r'[^a-z0-9_]', "_", name.lower())
    return re.sub(r'__*', "_", name, flags=re.I)