@@ -852,6 +852,15 @@ func CreateLogMetricCustomGroup(c *gin.Context) {
852
852
}
853
853
}
854
854
}
855
+ if existLogMonitorTemplate , getErr := db .GetLogMonitorTemplateByName (param .Guid , param .Name ); getErr != nil {
856
+ err = getErr
857
+ middleware .ReturnServerHandleError (c , err )
858
+ return
859
+ } else if existLogMonitorTemplate != nil {
860
+ err = fmt .Errorf ("log monitor template name:%s duplicate" , param .Name )
861
+ middleware .ReturnServerHandleError (c , err )
862
+ return
863
+ }
855
864
if err := db .ValidateLogMetricGroupName (param .Guid , param .Name , param .LogMetricMonitor ); err != nil {
856
865
err = fmt .Errorf (middleware .GetMessageMap (c ).LogGroupNameDuplicateError , param .Name )
857
866
middleware .ReturnHandleError (c , err .Error (), err )
@@ -880,7 +889,8 @@ func CreateLogMetricCustomGroup(c *gin.Context) {
880
889
881
890
func UpdateLogMetricCustomGroup (c * gin.Context ) {
882
891
var param models.LogMetricGroupObj
883
- if err := c .ShouldBindJSON (& param ); err != nil {
892
+ var err error
893
+ if err = c .ShouldBindJSON (& param ); err != nil {
884
894
middleware .ReturnValidateError (c , err .Error ())
885
895
return
886
896
}
@@ -889,8 +899,21 @@ func UpdateLogMetricCustomGroup(c *gin.Context) {
889
899
middleware .ReturnHandleError (c , err .Error (), err )
890
900
return
891
901
}
902
+ if existLogMonitorTemplate , getErr := db .GetLogMonitorTemplateByName (param .Guid , param .Name ); getErr != nil {
903
+ err = getErr
904
+ middleware .ReturnServerHandleError (c , err )
905
+ return
906
+ } else if existLogMonitorTemplate != nil {
907
+ err = fmt .Errorf ("log monitor template name:%s duplicate" , param .Name )
908
+ middleware .ReturnServerHandleError (c , err )
909
+ return
910
+ }
892
911
if len (param .MetricList ) > 0 {
893
912
for _ , metric := range param .MetricList {
913
+ // 拼接指标
914
+ if param .MetricPrefixCode != "" {
915
+ metric .Metric = param .MetricPrefixCode + metric .Metric
916
+ }
894
917
if middleware .IsIllegalLogParamNameOrMetric (metric .LogParamName ) || middleware .IsIllegalLogParamNameOrMetric (metric .Metric ) {
895
918
middleware .ReturnValidateError (c , "log_param_name or metric param invalid" )
896
919
return
0 commit comments