code: def get_ts(self):
          
  
          query = self.get_query(True)
          res = self.get_metrics_data(query)
          # Time to convert it to our grimoire timeseries format
          ts = {"date": [], "value": [], "unixtime": []}
          agg_id = ElasticQuery.AGGREGATION_ID
          if 'buckets' not in res['aggregations'][str(agg_id)]:
              raise RuntimeError("Aggregation results have no buckets in time series results.")
          for bucket in res['aggregations'][str(agg_id)]['buckets']:
              ts['date'].append(bucket['key_as_string'])
              if str(agg_id + 1) in bucket:
                  # We have a subaggregation with the value
                  # If it is percentiles we get the median
                  if 'values' in bucket[str(agg_id + 1)]:
                      val = bucket[str(agg_id + 1)]['values']['50.0']
                      if val == 'NaN':
                          # ES returns NaN. Convert to None for matplotlib graph
                          val = None
                      ts['value'].append(val)
                  else:
                      ts['value'].append(bucket[str(agg_id + 1)]['value'])
              else:
                  ts['value'].append(bucket['doc_count'])
              # unixtime comes in ms from ElasticSearch
              ts['unixtime'].append(bucket['key'] / 1000)
          return ts
docs: Returns a time series of a specific class
  
          A timeseries consists of a unixtime date, labels, some other
          fields and the data of the specific instantiated class metric per
          interval. This is built on a hash table.
  
          :return: a list with a time series with the values of the metric