def get(self, request, *args, **kwargs): """ 获取组件安装的插件的简要信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 组件别名 required: true type: string paramType: path """ bean = dict() try: service_abled_plugins = app_plugin_service.get_service_abled_plugin( self.service) plugin_list = [p.to_dict() for p in service_abled_plugins] result = general_message(200, "success", "操作成功", bean=bean, list=plugin_list) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])
def get(self, request, *args, **kwargs): """ 查询组件的性能分析插件 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 组件别名 required: true type: string paramType: path """ try: service_abled_plugins = app_plugin_service.get_service_abled_plugin( self.service) analyze_plugins = [] for plugin in service_abled_plugins: if plugin.category == PluginCategoryConstants.PERFORMANCE_ANALYSIS: analyze_plugins.append(plugin) result = general_message( 200, "success", "查询成功", list=[p.to_dict() for p in analyze_plugins]) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])
def get(self, request, team_id, region_name, app_id, *args, **kwargs): is_outer = request.GET.get("is_outer", False) if is_outer == "true": is_outer = True data = [] start = request.GET.get("start") end = request.GET.get("end") step = request.GET.get("step", 60) if not start or not end: raise ServiceHandleException(msg="params error", msg_show="缺少query参数") services_relation = group_service_relation_repo.get_services_by_group(self.app.ID) service_ids = services_relation.values_list('service_id', flat=True) if service_ids: services = service_repo.get_services_by_service_ids(service_ids).exclude(service_source="third_party") for service in services: is_outer_service = True has_plugin = False service_abled_plugins = app_plugin_service.get_service_abled_plugin(service) for plugin in service_abled_plugins: if plugin.category == PluginCategoryConstants.PERFORMANCE_ANALYSIS: has_plugin = True if is_outer: is_outer_service = False tenant_service_ports = port_service.get_service_ports(service) for service_port in tenant_service_ports: if service_port.is_outer_service: is_outer_service = True break if has_plugin and is_outer_service: dt = { "service_id": service.service_id, "service_cname": service.service_cname, "service_alias": service.service_alias, "monitors": [] } for k, v in list(monitor_query_range_items.items()): monitor = {"monitor_item": k} body = {} try: res, body = region_api.get_query_range_data(self.region_name, self.team.tenant_name, v % (service.service_id, start, end, step)) except Exception as e: logger.debug(e) if body.get("data"): if body["data"]["result"]: result_list = [] for result in body["data"]["result"]: result["value"] = [str(value) for value in result["value"]] result_list.append(result) body["data"]["result"] = result_list monitor.update(body) dt["monitors"].append(monitor) data.append(dt) serializers = ComponentMonitorSerializers(data=data, many=True) serializers.is_valid(raise_exception=True) return Response(serializers.data, status=200)