src/Mapper/AnalyticsMapper.php
public function getPoints($metric, $tags, $granularity, $endDt, $timezone = 'utc') {
        if ( null == $metric ) {
            return [];
        }
        
        $where = [];

        $now = $this->normalizeUTC(date("Y-m-d H:i:s"));
        
        $min = intval(date('i'));
        $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') );       
        $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z";
        
        if (strtotime($endDt) < strtotime($lastHourDt)) {
           return [];
        }
        
        $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $now  . "'";
        
        foreach ($tags as $key => $val) {
            $where[] = "$key = '" . $val . "'";
        }
        
        $query = $this->db->getQueryBuilder()
                ->sum('value')
                ->from($metric)
                ->where($where);

        $groupBy = "time(1d) tz('" . $timezone . "')";
        if ($granularity == self::GRANULARITY_HOURLY) {
            $groupBy = "time(1h) tz('" . $timezone . "')";
        } else if ($granularity == self::GRANULARITY_DAILY) {
            $groupBy = "time(1d) tz('" . $timezone . "')";
        } else if ($granularity == self::GRANULARITY_WEEKLY) {
            $groupBy = "time(1w) tz('" . $timezone . "')";
        }
        $query->groupBy($groupBy);
        
        return $query->getResultSet()->getPoints();        
    }
public function getPoints($metric, $tags, $granularity, $endDt, $timezone = 'utc') {
        if ( null == $metric ) {
            return [];
        }
        
        $where = [];

        $now = $this->normalizeUTC(date("Y-m-d H:i:s"));
        
        $min = intval(date('i'));
        $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') );       
        $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z";
        
        if (strtotime($endDt) < strtotime($lastHourDt)) {
           return [];
        }
        
        $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $now  . "'";
        
        foreach ($tags as $key => $val) {
            $where[] = "$key = '" . $val . "'";
        }
        
        $query = $this->db->getQueryBuilder()
                ->sum('value')
                ->from($metric)
                ->where($where);

        $groupBy = "time(1d) tz('" . $timezone . "')";
        if ($granularity == self::GRANULARITY_HOURLY) {
            $groupBy = "time(1h) tz('" . $timezone . "')";
        } else if ($granularity == self::GRANULARITY_DAILY) {
            $groupBy = "time(1d) tz('" . $timezone . "')";
        } else if ($granularity == self::GRANULARITY_WEEKLY) {
            $groupBy = "time(1w) tz('" . $timezone . "')";
        }
        $query->groupBy($groupBy);
        
        return $query->getResultSet()->getPoints();        
    }
public function getPoints ( $ metric , $ tags , $ granularity , $ endDt , $ timezone = 'utc' ) { if ( null == $ metric ) { return [ ] ; } $ where = [ ] ; $ now = $ this -> normalizeUTC ( date ( "Y-m-d H:i:s" ) ) ; $ min = intval ( date ( 'i' ) ) ; $ minutes = $ min > 45 ? 45 : ( $ min > 30 ? 30 : ( $ min > 15 ? 15 : '00' ) ) ; $ lastHourDt = date ( "Y-m-d" ) . "T" . date ( 'H' ) . ":$minutes:00Z" ; if ( strtotime ( $ endDt ) < strtotime ( $ lastHourDt ) ) { return [ ] ; } $ where [ ] = "time >= '" . $ lastHourDt . "' AND time <= '" . $ now . "'" ; foreach ( $ tags as $ key => $ val ) { $ where [ ] = "$key = '" . $ val . "'" ; } $ query = $ this -> db -> getQueryBuilder ( ) -> sum ( 'value' ) -> from ( $ metric ) -> where ( $ where ) ; $ groupBy = "time(1d) tz('" . $ timezone . "')" ; if ( $ granularity == self :: GRANULARITY_HOURLY ) { $ groupBy = "time(1h) tz('" . $ timezone . "')" ; } else if ( $ granularity == self :: GRANULARITY_DAILY ) { $ groupBy = "time(1d) tz('" . $ timezone . "')" ; } else if ( $ granularity == self :: GRANULARITY_WEEKLY ) { $ groupBy = "time(1w) tz('" . $ timezone . "')" ; } $ query -> groupBy ( $ groupBy ) ; return $ query -> getResultSet ( ) -> getPoints ( ) ; }
Get points from default retention policy

@param string $metric
@param array $tags
@param string $granularity
@param string $endDt
@param string $timezone
@return array
Get points from default retention policy