From b72e6c6836f80ecdf17a49277eaf589d8bf6bd87 Mon Sep 17 00:00:00 2001 From: durant <826035498@qq.com> Date: Thu, 21 Nov 2024 15:30:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(backend):=20mongodb=20=E9=87=87=E9=9B=86?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E8=A3=81=E5=89=AA=20#8090?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/export_collect.py | 5 +- .../tpls/collect/dbm_mongodb_exporter.json | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 dbm-ui/backend/db_monitor/tpls/collect/dbm_mongodb_exporter.json diff --git a/dbm-ui/backend/db_monitor/management/commands/export_collect.py b/dbm-ui/backend/db_monitor/management/commands/export_collect.py index 226b3dbc77..e9f3c5f495 100644 --- a/dbm-ui/backend/db_monitor/management/commands/export_collect.py +++ b/dbm-ui/backend/db_monitor/management/commands/export_collect.py @@ -19,6 +19,7 @@ from django.core.management.base import BaseCommand from django.utils import timezone +from backend import env from backend.components import BKMonitorV3Api from backend.configuration.constants import DBType from backend.db_monitor.constants import TPLS_COLLECT_DIR @@ -97,7 +98,9 @@ def handle(self, *args, **options): # 批量获取策略 for collect_id in collect_list: - instance = BKMonitorV3Api.query_collect_config_detail({"id": str(collect_id)}) + instance = BKMonitorV3Api.query_collect_config_detail( + {"bk_biz_id": env.DBA_APP_BK_BIZ_ID, "id": str(collect_id)} + ) # 策略转模板 plugin_id = instance["plugin_info"]["plugin_id"] template = self.to_template(instance) diff --git a/dbm-ui/backend/db_monitor/tpls/collect/dbm_mongodb_exporter.json b/dbm-ui/backend/db_monitor/tpls/collect/dbm_mongodb_exporter.json new file mode 100644 index 0000000000..1103b1603d --- /dev/null +++ b/dbm-ui/backend/db_monitor/tpls/collect/dbm_mongodb_exporter.json @@ -0,0 +1,50 @@ +{ + "bk_biz_id": 0, + "name": "dbm_mongodb_exporter", + "details": { + "name": "dbm_mongodb_exporter", + "collect_type": "Exporter", + "label": "component", + "target_object_type": "SERVICE", + "target_node_type": "TOPO", + "target_nodes": [], + "metric_relabel_configs": [{ + "source_labels": ["__name__"], + "action": "drop", + "regex": "^mongodb_sys_|^mongodb_ss_metrics_|^mongodb_connPoolStats_" + }], + "params": { + "collector": { + "period": 60, + "timeout": 60, + "host": "127.0.0.1", + "port": "10000", + "metric_relabel_configs": [] + }, + "plugin": { + "-addr": "{{ target.host.bk_host_innerip }}:{{ target.service.labels[\"instance_port\"] }}", + "-bind": "${host}:${port}", + "-password-file": "/home/mysql/.exporter/{{ target.service.labels[\"instance_port\"] }}.conf", + "\u670d\u52a1\u5b9e\u4f8b\u7ef4\u5ea6\u6ce8\u5165": { + "cluster_domain": "cluster_domain", + "cluster_type": "cluster_type", + "cluster_name": "cluster_name", + "app": "app", + "instance": "instance", + "instance_role": "instance_role", + "instance_host": "instance_host", + "instance_port": "instance_port", + "appid": "appid" + } + }, + "target_node_type": "TOPO", + "target_object_type": "SERVICE" + }, + "plugin_id": "dbm_mongodb_exporter" + }, + "db_type": "mongodb", + "version": 1, + "machine_types": [], + "plugin_id": "dbm_mongodb_exporter", + "export_at": "2024-11-21T15:24:01+08:00" +} \ No newline at end of file