(maas_store, entity_id, check, metric_name, from_date, to_date, points)
return {'entity_id': entity_id,
            'check_id': check.id,
            'metric': metric_name,
            'unit': metric.unit,
            'type': metric.type,
            'data': [{'numPoints': 4,
                      'timestamp': int(from_date + (i * interval)),
                      'average': metric.get_value(
                          timestamp=int(from_date + (i * interval)),
                          **metric_value_kwargs)}
                     for i in range(points)]}
Computes multiplot data for a single (entity, check, metric) group.
Computes multiplot data for a single (entity, check, metric) group.
Computes multiplot data for a single ( entity check metric ) group .
def _compute_multiplot(maas_store, entity_id, check, metric_name, from_date, to_date, points):
    """
    Computes multiplot data for a single (entity, check, metric) group.
    """
    fallback = {'entity_id': entity_id,
                'check_id': check.id,
                'metric': metric_name,
                'unit': 'unknown',
                'type': 'unknown',
                'data': []}

    if check.type not in maas_store.check_types:
        return fallback

    interval = _multiplot_interval(from_date, to_date, points)
    metric = None
    base_metric_name = metric_name
    metric_value_kwargs = {'entity_id': entity_id,
                           'check_id': check.id}
    if re.match(r'^remote\.', check.type):
        match = re.match(r'^(mz\w+)\.(\w+)$', metric_name)
        if not match:
            return fallback
        metric_value_kwargs['monitoring_zone'] = match.group(1)
        base_metric_name = match.group(2)

    try:
        metric = maas_store.check_types[
            check.type].get_metric_by_name(base_metric_name)
    except NameError:
        return fallback

    return {'entity_id': entity_id,
            'check_id': check.id,
            'metric': metric_name,
            'unit': metric.unit,
            'type': metric.type,
            'data': [{'numPoints': 4,
                      'timestamp': int(from_date + (i * interval)),
                      'average': metric.get_value(
                          timestamp=int(from_date + (i * interval)),
                          **metric_value_kwargs)}
                     for i in range(points)]}
def _compute_multiplot ( maas_store , entity_id , check , metric_name , from_date , to_date , points ) : fallback = { 'entity_id' : entity_id , 'check_id' : check . id , 'metric' : metric_name , 'unit' : 'unknown' , 'type' : 'unknown' , 'data' : [ ] } if check . type not in maas_store . check_types : return fallback interval = _multiplot_interval ( from_date , to_date , points ) metric = None base_metric_name = metric_name metric_value_kwargs = { 'entity_id' : entity_id , 'check_id' : check . id } if re . match ( r'^remote\.' , check . type ) : match = re . match ( r'^(mz\w+)\.(\w+)$' , metric_name ) if not match : return fallback metric_value_kwargs [ 'monitoring_zone' ] = match . group ( 1 ) base_metric_name = match . group ( 2 ) try : metric = maas_store . check_types [ check . type ] . get_metric_by_name ( base_metric_name ) except NameError : return fallback return { 'entity_id' : entity_id , 'check_id' : check . id , 'metric' : metric_name , 'unit' : metric . unit , 'type' : metric . type , 'data' : [ { 'numPoints' : 4 , 'timestamp' : int ( from_date + ( i * interval ) ) , 'average' : metric . get_value ( timestamp = int ( from_date + ( i * interval ) ) , * * metric_value_kwargs ) } for i in range ( points ) ] }