Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Metadata自监控--指标化改造,后台任务耗时统计&接入链路趋势统计指标 --story=120586640 #3766

Merged
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
7 changes: 4 additions & 3 deletions bkmonitor/core/prometheus/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,13 @@ def from_exc(cls, expr):
name="bkmonitor_metadata_cron_task_cost_seconds",
documentation="监控元数据定时任务耗时统计",
labelnames=("task_name", "process_target"),
buckets=(0, 1, 5, 10, 30, 60, 120, 180, 240, 300, 600, 900, 1800, 3000, 6000, INF),
)

METADATA_DATA_LINK_ACCESS_INFO = Gauge(
name="bkmonitor_metadata_data_link_access_info",
METADATA_DATA_LINK_ACCESS_TOTAL = Counter(
name="bkmonitor_metadata_data_link_access_total",
documentation="监控元数据数据链路接入统计",
labelnames=("version", "biz_id", "data_id", 'table_id', 'strategy'),
labelnames=("version", "biz_id", 'strategy', 'status'),
)


Expand Down
18 changes: 3 additions & 15 deletions bkmonitor/metadata/models/vm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def access_bkdata(bk_biz_id: int, table_id: str, data_id: int):
version=DATA_LINK_V3_VERSION_NAME,
data_id=data_id,
biz_id=bk_biz_id,
table_id=table_id,
status=ACCESS_DATA_LINK_SUCCESS_STATUS,
strategy=DataLink.BK_STANDARD_V2_TIME_SERIES,
)
Expand All @@ -133,7 +132,6 @@ def access_bkdata(bk_biz_id: int, table_id: str, data_id: int):
version=DATA_LINK_V3_VERSION_NAME,
data_id=data_id,
biz_id=bk_biz_id,
table_id=table_id,
status=ACCESS_DATA_LINK_FAILURE_STATUS,
strategy=DataLink.BK_STANDARD_V2_TIME_SERIES,
)
Expand Down Expand Up @@ -314,7 +312,6 @@ def report_metadata_data_link_access_metric(
status: int,
biz_id: int,
data_id: int,
table_id: str,
strategy: str,
) -> None:
"""
Expand All @@ -323,18 +320,13 @@ def report_metadata_data_link_access_metric(
@param status: 接入状态(失败-1/成功1) 以是否成功向bkbase发起请求为准
@param biz_id: 业务ID
@param data_id: 数据ID
@param table_id: 结果表ID
@param strategy: 链路策略(套餐类型)
"""
try:
logger.info("try to report metadata data link component status metric,data_id->[%s]", data_id)
metrics.METADATA_DATA_LINK_ACCESS_INFO.labels(
version=version,
biz_id=biz_id,
data_id=data_id,
table_id=table_id,
strategy=strategy,
).set(status)
metrics.METADATA_DATA_LINK_ACCESS_TOTAL.labels(
version=version, biz_id=biz_id, strategy=strategy, status=status
).inc()
metrics.report_all()
except Exception as err: # pylint: disable=broad-except
logger.error("report metadata data link access metric error->[%s],data_id->[%s]", err, data_id)
Expand Down Expand Up @@ -553,7 +545,6 @@ def access_v2_bkdata_vm(bk_biz_id: int, table_id: str, data_id: int):
version=DATA_LINK_V4_VERSION_NAME,
data_id=data_id,
biz_id=bk_biz_id,
table_id=table_id,
status=ACCESS_DATA_LINK_SUCCESS_STATUS,
strategy=DataLink.BK_STANDARD_V2_TIME_SERIES,
)
Expand All @@ -563,7 +554,6 @@ def access_v2_bkdata_vm(bk_biz_id: int, table_id: str, data_id: int):
version=DATA_LINK_V4_VERSION_NAME,
data_id=data_id,
biz_id=bk_biz_id,
table_id=table_id,
status=ACCESS_DATA_LINK_FAILURE_STATUS,
strategy=DataLink.BCS_FEDERAL_SUBSET_TIME_SERIES,
)
Expand All @@ -581,7 +571,6 @@ def access_v2_bkdata_vm(bk_biz_id: int, table_id: str, data_id: int):
version=DATA_LINK_V4_VERSION_NAME,
data_id=data_id,
biz_id=bk_biz_id,
table_id=table_id,
status=ACCESS_DATA_LINK_SUCCESS_STATUS,
strategy=DataLink.BCS_FEDERAL_SUBSET_TIME_SERIES,
)
Expand All @@ -591,7 +580,6 @@ def access_v2_bkdata_vm(bk_biz_id: int, table_id: str, data_id: int):
version=DATA_LINK_V4_VERSION_NAME,
data_id=data_id,
biz_id=bk_biz_id,
table_id=table_id,
status=ACCESS_DATA_LINK_FAILURE_STATUS,
strategy=DataLink.BCS_FEDERAL_SUBSET_TIME_SERIES,
)
Expand Down
2 changes: 1 addition & 1 deletion bkmonitor/metadata/task/refresh_data_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def refresh_data_link_status():

bkbase_rt_records = models.BkBaseResultTable.objects.filter(monitor_table_id__in=table_id_list)
logger.info("refresh_data_link_status: now try to bulk_refresh_data_link_status,len->[%s] ", len(bkbase_rt_records))
bulk_refresh_data_link_status.delay(bkbase_rt_records)
bulk_refresh_data_link_status.delay(bkbase_rt_records) # task_id
Loading