예제 #1
0
    def on_get(self, req, res):
        helpers.validate_authorization(req, self._get_metrics_authorized_roles)
        tenant_id = (
            helpers.get_x_tenant_or_tenant_id(req,
                                              self._delegate_authorized_roles))
        name = helpers.get_query_name(req, True)
        helpers.validate_query_name(name)
        dimensions = helpers.get_query_dimensions(req)
        helpers.validate_query_dimensions(dimensions)
        start_timestamp = helpers.get_query_starttime_timestamp(req)
        end_timestamp = helpers.get_query_endtime_timestamp(req, False)
        helpers.validate_start_end_timestamps(start_timestamp, end_timestamp)
        statistics = helpers.get_query_statistics(req)
        period = helpers.get_query_period(req)
        offset = helpers.get_query_param(req, 'offset')
        merge_metrics_flag = get_merge_metrics_flag(req)
        group_by = helpers.get_query_group_by(req)

        result = self._metric_statistics(tenant_id, name, dimensions,
                                         start_timestamp, end_timestamp,
                                         statistics, period, req.uri,
                                         offset, req.limit, merge_metrics_flag,
                                         group_by)

        res.body = helpers.dumpit_utf8(result)
        res.status = falcon.HTTP_200
예제 #2
0
    def on_get(self, req, res):
        helpers.validate_authorization(req, self._get_metrics_authorized_roles)
        tenant_id = (
            helpers.get_x_tenant_or_tenant_id(req,
                                              self._delegate_authorized_roles))
        name = helpers.get_query_name(req, True)
        helpers.validate_query_name(name)
        dimensions = helpers.get_query_dimensions(req)
        helpers.validate_query_dimensions(dimensions)
        start_timestamp = helpers.get_query_starttime_timestamp(req)
        end_timestamp = helpers.get_query_endtime_timestamp(req, False)
        helpers.validate_start_end_timestamps(start_timestamp, end_timestamp)
        statistics = helpers.get_query_statistics(req)
        period = helpers.get_query_period(req)
        offset = helpers.get_query_param(req, 'offset')
        merge_metrics_flag = get_merge_metrics_flag(req)
        group_by = helpers.get_query_group_by(req)

        result = self._metric_statistics(tenant_id, name, dimensions,
                                         start_timestamp, end_timestamp,
                                         statistics, period, req.uri,
                                         offset, req.limit, merge_metrics_flag,
                                         group_by)

        res.body = helpers.dumpit_utf8(result)
        res.status = falcon.HTTP_200