From 99764d2191af318a182d6e9afddc8a930ef17188 Mon Sep 17 00:00:00 2001 From: tangjiawei Date: Wed, 20 Nov 2024 16:28:43 +0800 Subject: [PATCH] =?UTF-8?q?#845=20=E4=B8=9A=E5=8A=A1=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=94=AF=E6=8C=81=E8=87=AA=E5=8A=A8=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=91=8A=E8=AD=A6=E7=9C=8B=E6=9D=BF&=E9=9D=9E?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitor-server/api/v2/service/log_metric.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/monitor-server/api/v2/service/log_metric.go b/monitor-server/api/v2/service/log_metric.go index 0df4c9d74..c384acfd7 100644 --- a/monitor-server/api/v2/service/log_metric.go +++ b/monitor-server/api/v2/service/log_metric.go @@ -389,6 +389,8 @@ func ImportLogMetric(c *gin.Context) { middleware.ReturnHandleError(c, "file open error ", err) return } + // autoCreate 是否自动创建告警和看板,yes表示自动,no表示不自动,不传递就根据导出数据判断 + autoCreate := c.Query("autoCreate") var paramObj models.LogMetricQueryObj b, err := io.ReadAll(f) defer f.Close() @@ -419,6 +421,17 @@ func ImportLogMetric(c *gin.Context) { } for _, metricGroup := range logMonitor.MetricGroups { metricGroup.ServiceGroup = serviceGroup + if autoCreate == "yes" { + metricGroup.AutoDashboard = 1 + metricGroup.AutoCreateDashboard = true + metricGroup.AutoAlarm = 1 + metricGroup.AutoCreateWarn = true + } else if autoCreate == "no" { + metricGroup.AutoDashboard = 0 + metricGroup.AutoCreateDashboard = false + metricGroup.AutoAlarm = 0 + metricGroup.AutoCreateWarn = false + } } } for _, dbMonitor := range paramObj.DBConfig {