code: def get_agg(self):
          
          """ Returns an aggregated value """
          query = self.get_query(False)
          res = self.get_metrics_data(query)
          # We need to extract the data from the JSON res
          # If we have agg data use it
          agg_id = str(ElasticQuery.AGGREGATION_ID)
          if 'aggregations' in res and 'values' in res['aggregations'][agg_id]:
              if self.AGG_TYPE == 'median':
                  agg = res['aggregations'][agg_id]['values']["50.0"]
                  if agg == 'NaN':
                      # ES returns NaN. Convert to None for matplotlib graph
                      agg = None
              else:
                  raise RuntimeError("Multivalue aggregation result not supported")
          elif 'aggregations' in res and 'value' in res['aggregations'][agg_id]:
              agg = res['aggregations'][agg_id]['value']
          else:
              agg = res['hits']['total']
  
          return agg
docs: Returns the aggregated value for the metric
  
          :return: the value of the metric