def METHOD_NAME(event, metric, varmap):
    obj = lookup(metric)
    if obj:
        try:
            varmap['subject'] = "{table}:{pk}".format(
                table=getattr(obj, '_meta').db_table, pk=obj.pk
            )
        except AttributeError:
            pass  # probably wasn't a Django model object, fuhgeddaboutit
        if isinstance(obj, Netbox):
            event.netbox = obj
        else:
            try:
                event.netbox = obj.netbox
            except AttributeError:
                pass
        try:
            event.device = obj.device
        except AttributeError:
            try:
                event.device = obj.netbox.device
            except AttributeError:
                pass
        if isinstance(obj, Interface):
            varmap['interface'] = obj.ifname
        elif isinstance(obj, Sensor):
            varmap['sensor'] = obj.name