def run(self, service_id, **kwargs):
        """
        Retrieve a list of metrics. Ensure they are set as metric data sources.
        """
        log = self.get_logger(**kwargs)

        log.info("Loading Service for metric sync")
        try:
            service = Service.objects.get(id=service_id)
            log.info("Getting metrics for <%s>" % (service.name))
            metrics = self.get_metrics(service.url, service.token)
            result = metrics.json()
            if "metrics_available" in result:
                for key in result["metrics_available"]:
                    check = WidgetData.objects.filter(service=service, key=key)
                    if not check.exists():
                        WidgetData.objects.create(
                            service=service,
                            key=key,
                            title="TEMP - Pending update"
                        )
                        log.info("Add WidgetData for <%s>" % (key,))
            return "Completed metric sync for <%s>" % (service.name)
        except ObjectDoesNotExist:
            logger.error('Missing Service', exc_info=True)

        except SoftTimeLimitExceeded:
            logger.error(
                'Soft time limit exceed processing pull of service metrics \
                 via Celery.',
                exc_info=True)
def run ( self , service_id , ** kwargs ) : log = self . get_logger ( ** kwargs ) log . info ( "Loading Service for metric sync" ) try : service = Service . objects . get ( id = service_id ) log . info ( "Getting metrics for <%s>" % ( service . name ) ) metrics = self . get_metrics ( service . url , service . token ) result = metrics . json ( ) if "metrics_available" in result : for key in result [ "metrics_available" ] : check = WidgetData . objects . filter ( service = service , key = key ) if not check . exists ( ) : WidgetData . objects . create ( service = service , key = key , title = "TEMP - Pending update" ) log . info ( "Add WidgetData for <%s>" % ( key , ) ) return "Completed metric sync for <%s>" % ( service . name ) except ObjectDoesNotExist : logger . error ( 'Missing Service' , exc_info = True ) except SoftTimeLimitExceeded : logger . error ( 'Soft time limit exceed processing pull of service metrics \
                 via Celery.' , exc_info = True )
Retrieve a list of metrics. Ensure they are set as metric data sources.