Ejemplo n.º 1
0
    def list(self, request, project_id):
        """get cluster metric info"""
        params = self.get_params(request)
        cluster_id = params['res_id']
        self.can_view_cluster(request, project_id, cluster_id)
        start_at, end_at = self.get_start_end_time(params['start_at'],
                                                   params['end_at'])
        # get cluster history data between start_at and end_at
        cluster_data = self.get_history_data(request, project_id, cluster_id,
                                             params['metric'], start_at,
                                             end_at)
        if not cluster_data.get('results'):
            return response.Response({'cpu': [], 'mem': [], 'disk': []})
        metrics_cpu, metrics_mem, metrics_disk = self.compose_metric(
            request, cluster_data)

        if use_prometheus_source(request):
            metrics_disk = self.get_prom_disk_data(request, cluster_id,
                                                   metrics_disk)

        return response.Response({
            'cpu': metrics_cpu,
            'mem': metrics_mem,
            'disk': metrics_disk
        })
Ejemplo n.º 2
0
    def list(self, request, project_id):
        """get cpu/mem/disk info"""
        params = self.get_params(request)
        if use_prometheus_source(request):
            data = self.get_prom_data(params['res_id'])
        else:
            data = self.get_bk_data(params['res_id'], request.project.cc_app_id)

        return response.Response(data)
Ejemplo n.º 3
0
    def multi(self, request, project_id):
        """get multiple docker info"""
        data = self.get_multi_params(request)

        if use_prometheus_source(request):
            data = self.get_multi_prom_data(data)
        else:
            data = self.get_multi_bk_data(data, request.project.cc_app_id)

        return response.Response(data)
Ejemplo n.º 4
0
    def list(self, request, project_id):
        """get docker monitor info"""
        params = self.get_params(request)

        if use_prometheus_source(request):
            data = self.get_prom_data(params)
        else:
            data = self.get_bk_data(params, request.project.cc_app_id)

        return response.Response(data)
Ejemplo n.º 5
0
    def list(self, request, project_id):
        """get node metrics info"""
        params = self.get_params(request)
        # compatible logic
        try:
            self.validate_inner_ip(request, project_id, params['res_id'])
        except Exception as err:
            return response.Response({'code': ErrorCode.NoError, 'data': {'list': []}, 'message': err})

        if use_prometheus_source(request):
            data = self.get_prom_data(params)
        else:
            data = self.get_bk_data(params, request.project.cc_app_id)
        return response.Response(data)