Skip to content

Commit

Permalink
feat(backend): mongodb 采集指标裁剪 TencentBlueKing#8090
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Nov 21, 2024
1 parent e5e9a5e commit b72e6c6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
50 changes: 50 additions & 0 deletions dbm-ui/backend/db_monitor/tpls/collect/dbm_mongodb_exporter.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit b72e6c6

Please sign in to comment.