Duansg commented on code in PR #4101:
URL: https://github.com/apache/hertzbeat/pull/4101#discussion_r3065698542


##########
hertzbeat-manager/src/main/java/org/apache/hertzbeat/manager/service/impl/MonitorServiceImpl.java:
##########
@@ -382,22 +375,31 @@ public void modifyMonitor(Monitor monitor, List<Param> 
params, String collector,
             labelDao.saveAll(addLabels);
         }
 
+        boolean isStatic = 
CommonConstants.SCRAPE_STATIC.equals(monitor.getScrape())
+            || !StringUtils.hasText(monitor.getScrape());
+        if (!isStatic && !StringUtils.hasText(monitor.getInstance())) {
+            monitor.setInstance("unknown");
+        }
+
         String instance = monitor.getInstance();
         // The port field may be null
         Param portParam = params.stream()
-                .filter(param -> PARAM_FIELD_PORT.equals(param.getField()))
-                .findFirst()
-                .orElse(null);
+            .filter(param -> PARAM_FIELD_PORT.equals(param.getField()))
+            .findFirst()
+            .orElse(null);
         String portWithMark = (Objects.isNull(portParam) || 
!StringUtils.hasText(portParam.getParamValue()))
-                ? ""
-                : SignConstants.DOUBLE_MARK + portParam.getParamValue();
+            ? ""
+            : SignConstants.DOUBLE_MARK + portParam.getParamValue();
+        if (IpDomainUtil.isHasPortWithMark(instance)){

Review Comment:
   I took a look at the code, and I have a question: if 
`monitor.setInstance("unknown")` is true, will this line of code execute?
   
   Conversely, if that's not the case, I've noticed that the value of 
`instance` doesn't include port information during editing, so this line of 
code would never execute?
   
   Please help confirm this issue.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to