src/lib/metrics.js
/**
   * Query metrics
   *
   * The query map accepts the following keys:
   *
   * To specify the time series:
   *    name     string   required  The name of the time series
   *
   * To filter time series:
   *    tags     map      optional  Set of tags for exact match (TODO: wildcards?)
   *
   * To specify the time range:
   *    start    int      optional  Seconds since Unix  epoch. Lower time bound (inclusive)
   *    end      int      optional  Upper time bound (exclusive)
   *
   * To group by time interval:
   *    step     int      optional  Interval in seconds
   *
   * To group results by tag:
   *    by       string   optional  A tag's value.
   */
Query metrics
The query map accepts the following keys.

To specify the time series:
name     string   required  The name of the time series

To filter time series:
tags     map      optional  Set of tags for exact match (TODO: wildcards?)

To specify the time range:
start    int      optional  Seconds since Unix  epoch. Lower time bound (inclusive)
end      int      optional  Upper time bound (exclusive)

To group by time interval:
step     int      optional  Interval in seconds

To group results by tag:
by       string   optional  A tag's value.
Query metrics The query map accepts the following keys . To specify the time series : name string required The name of the time series To filter time series : tags map optional Set of tags for exact match ( TODO : wildcards? ) To specify the time range : start int optional Seconds since Unix epoch . Lower time bound ( inclusive ) end int optional Upper time bound ( exclusive ) To group by time interval : step int optional Interval in seconds To group results by tag : by string optional A tag ' s value .
query(query) {
    let seriesSet = Set.intersect(
      seriesFor(query)
        .entrySeq()
        .map(e => Set(this.indices.getIn(e, [])))
    );
    let points = [];
    if (query.has('by')) {
      points = this.indices
        .get(query.get('by'), Map())
        .map(
          function(s) {
            return this.querySeriesSet(query, Set.intersect([s, seriesSet]));
          }.bind(this)
        )
        .map((data, tag) =>
          data.map(([t, v]) => {
            let m = Map();
            if (v !== 0) {
              m = m.set(tag, v);
            }
            return [t, m];
          })
        )
        .reduce((results, data) => {
          return mergeWith((a, b) => a.merge(b), results, data);
        }, [])
        .map(([t, v]) => [t, v.toJS()]);
    } else {
      points = this.querySeriesSet(query, seriesSet);
    }
    return points;
  }
query ( query ) { let seriesSet = Set . intersect ( seriesFor ( query ) . entrySeq ( ) . map ( e => Set ( this . indices . getIn ( e , [ ] ) ) ) ) ; let points = [ ] ; if ( query . has ( 'by' ) ) { points = this . indices . get ( query . get ( 'by' ) , Map ( ) ) . map ( function ( s ) { return this . querySeriesSet ( query , Set . intersect ( [ s , seriesSet ] ) ) ; } . bind ( this ) ) . map ( ( data , tag ) => data . map ( ( [ t , v ] ) => { let m = Map ( ) ; if ( v !== 0 ) { m = m . set ( tag , v ) ; } return [ t , m ] ; } ) ) . reduce ( ( results , data ) => { return mergeWith ( ( a , b ) => a . merge ( b ) , results , data ) ; } , [ ] ) . map ( ( [ t , v ] ) => [ t , v . toJS ( ) ] ) ; } else { points = this . querySeriesSet ( query , seriesSet ) ; } return points ; }
Query metrics
 The query map accepts the following keys:
Query metrics The query map accepts the following keys :
// Find the series we need to query // Query a set of series for each known value of the tag // no by -> set of series