Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bkmonitor/api/cmdb/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ class GetProcess(Resource):
class RequestSerializer(serializers.Serializer):
bk_biz_id = serializers.IntegerField(label="业务ID")
bk_host_id = serializers.IntegerField(label="主机ID", required=False, allow_null=True)
bk_host_ids = serializers.ListField(label="主机ID列表", child=serializers.IntegerField(), required=False)
include_multiple_bind_info = serializers.BooleanField(
required=False, label="是否返回多个绑定信息", default=False
)
Expand All @@ -696,6 +697,11 @@ def perform_request(self, validated_request_data):
if validated_request_data.get("bk_host_id"):
params["bk_host_id"] = validated_request_data["bk_host_id"]
response_data = batch_request(client.list_service_instance_detail, params, limit=500)
elif validated_request_data.get("bk_host_ids") is not None:
if not validated_request_data["bk_host_ids"]:
return []
params["bk_host_list"] = validated_request_data["bk_host_ids"]
response_data = batch_request(client.list_service_instance_detail, params, limit=500)
else:
response_data = get_service_instance_by_biz(validated_request_data["bk_biz_id"])

Expand Down
1 change: 1 addition & 0 deletions bkmonitor/bkmonitor/models/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class AuthType:
"monitor_web.grafana.views.GrafanaViewSet": {"time_series/unify_query"},
"monitor_web.performance.views.SearchHostInfoViewSet": {"create"},
"monitor_web.performance.views.SearchHostMetricViewSet": {"create"},
"monitor_web.performance.views.HostMetricSnapshotViewSet": {"create", "retrieve"},
"monitor_web.scene_view.views.SceneViewViewSet": {
"get_host_metric_group_panel_order",
"get_host_or_topo_node_detail",
Expand Down
3 changes: 3 additions & 0 deletions bkmonitor/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@
#
IS_ACCESS_BK_DATA = os.getenv("BKAPP_IS_ACCESS_BK_DATA", "") == "true" # 是否接入计算平台
IS_ENABLE_VIEW_CMDB_LEVEL = False # 是否开启前端视图部分的CMDB预聚合
ENABLE_HOST_METRIC_PROGRESSIVE = os.getenv("ENABLE_HOST_METRIC_PROGRESSIVE", "false").lower() == "true"
HOST_METRIC_PROGRESSIVE_MIN_HOST_COUNT = int(os.getenv("HOST_METRIC_PROGRESSIVE_MIN_HOST_COUNT", "2000"))
HOST_METRIC_SNAPSHOT_MAX_CONCURRENT_PER_BIZ = max(1, int(os.getenv("HOST_METRIC_SNAPSHOT_MAX_CONCURRENT_PER_BIZ", 1)))
IS_MIGRATE_AIOPS_STRATEGY = False

# 数据接入相关
Expand Down
4 changes: 4 additions & 0 deletions bkmonitor/packages/common/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def get_basic_context(request, space_list: list[dict[str, Any]], bk_biz_id: int)
"GRAPH_WATERMARK": settings.GRAPH_WATERMARK,
# 是否开启前端视图部分,按拓扑聚合的能力。(不包含对监控策略部分的功能)
"ENABLE_CMDB_LEVEL": settings.IS_ACCESS_BK_DATA and settings.IS_ENABLE_VIEW_CMDB_LEVEL,
# 是否开启主机列表指标渐进式加载
"ENABLE_HOST_METRIC_PROGRESSIVE": settings.ENABLE_HOST_METRIC_PROGRESSIVE,
# 主机列表启用指标渐进式加载的最小主机数
"HOST_METRIC_PROGRESSIVE_MIN_HOST_COUNT": settings.HOST_METRIC_PROGRESSIVE_MIN_HOST_COUNT,
# 事件中心一键拉取功能展示
"ENABLE_CREATE_CHAT_GROUP": settings.ENABLE_CREATE_CHAT_GROUP,
# 用于全局设置蓝鲸监控机器人发送图片是否开启
Expand Down
12 changes: 12 additions & 0 deletions bkmonitor/packages/common/tests/test_context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,15 @@ def test_get_basic_context_disables_ai_assistant_by_environment_variable():
context = get_basic_context(make_request(), [{"bk_biz_id": 2}], 2)

assert context["ENABLE_AI_ASSISTANT"] == "false"


@override_settings(ENABLE_HOST_METRIC_PROGRESSIVE=True, HOST_METRIC_PROGRESSIVE_MIN_HOST_COUNT=2000)
def test_get_basic_context_exposes_host_metric_progressive_switch():
with (
mock.patch("common.context_processors.get_core_context", return_value={}),
mock.patch("common.context_processors.is_ipv6_biz", return_value=False),
):
context = get_basic_context(make_request(), [{"bk_biz_id": 2}], 2)

assert context["ENABLE_HOST_METRIC_PROGRESSIVE"] is True
assert context["HOST_METRIC_PROGRESSIVE_MIN_HOST_COUNT"] == 2000
Loading
Loading