This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 84986dd1bf [feature] support auto nacos service discovery (#3324)
84986dd1bf is described below

commit 84986dd1bfa05f176b38d87a51987dacbacecf55
Author: zhangyaxi <[email protected]>
AuthorDate: Wed May 21 22:01:09 2025 +0800

    [feature] support auto nacos service discovery (#3324)
    
    Signed-off-by: tomsun28 <[email protected]>
    Signed-off-by: zhangyaxi <[email protected]>
    Co-authored-by: tomsun28 <[email protected]>
    Co-authored-by: Calvin <[email protected]>
    Co-authored-by: shown <[email protected]>
    Co-authored-by: aias00 <[email protected]>
---
 .../collector/collect/sd/NacosSdCollectImpl.java   | 114 ++++++++++
 .../collect/sd/NacosSdCollectImplTest.java         | 233 +++++++++++++++++++++
 ...che.hertzbeat.collector.collect.AbstractCollect |   1 +
 .../collector/dispatch/DispatchConstants.java      |   4 +
 .../hertzbeat/common/entity/job/Metrics.java       |   5 +
 .../entity/job/protocol/NacosSdProtocol.java       |  63 ++++++
 .../src/main/resources/define/app-nacos_sd.yml     |  90 ++++++++
 .../monitor-form/monitor-form.component.html       |   1 +
 web-app/src/assets/i18n/en-US.json                 |   1 +
 web-app/src/assets/i18n/ja-JP.json                 |   1 +
 web-app/src/assets/i18n/pt-BR.json                 |   1 +
 web-app/src/assets/i18n/zh-CN.json                 |   1 +
 web-app/src/assets/i18n/zh-TW.json                 |   1 +
 13 files changed, 516 insertions(+)

diff --git 
a/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/sd/NacosSdCollectImpl.java
 
b/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/sd/NacosSdCollectImpl.java
new file mode 100644
index 0000000000..dd6dad2a15
--- /dev/null
+++ 
b/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/sd/NacosSdCollectImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hertzbeat.collector.collect.sd;
+
+import java.util.List;
+
+import org.apache.hertzbeat.collector.collect.AbstractCollect;
+import 
org.apache.hertzbeat.collector.collect.registry.constant.DiscoveryClientInstance;
+import 
org.apache.hertzbeat.collector.collect.registry.discovery.DiscoveryClient;
+import 
org.apache.hertzbeat.collector.collect.registry.discovery.DiscoveryClientManagement;
+import 
org.apache.hertzbeat.collector.collect.registry.discovery.entity.ServiceInstance;
+import org.apache.hertzbeat.collector.dispatch.DispatchConstants;
+import org.apache.hertzbeat.common.entity.job.Metrics;
+import org.apache.hertzbeat.common.entity.job.protocol.RegistryProtocol;
+import org.apache.hertzbeat.common.entity.message.CollectRep;
+import org.apache.hertzbeat.common.util.CommonUtil;
+import org.springframework.util.CollectionUtils;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Nacos Service Discovery Collector
+ * This collector integrates with Nacos to discover registered services
+ */
+@Slf4j
+public class NacosSdCollectImpl extends AbstractCollect {
+    
+    /**
+     * Client management to interact with discovery services
+     */
+    private final DiscoveryClientManagement discoveryClientManagement = new 
DiscoveryClientManagement();
+    
+    @Override
+    public void preCheck(Metrics metrics) throws IllegalArgumentException {
+        // Validate the required configuration is present
+        if (metrics == null || metrics.getNacos_sd() == null) {
+            throw new IllegalArgumentException("Nacos service discovery 
monitoring, the config is null");
+        }
+        if (metrics.getNacos_sd().isInvalid()) {
+            throw new IllegalArgumentException("Nacos service discovery 
monitoring, the config is invalid");
+        }
+    }
+    
+    @Override
+    public void collect(CollectRep.MetricsData.Builder builder, Metrics 
metrics) {
+        // Create Registry protocol from NacosSd protocol
+        RegistryProtocol registryProtocol = RegistryProtocol.builder()
+                .host(metrics.getNacos_sd().getHost())
+                .port(metrics.getNacos_sd().getPort())
+                .discoveryClientTypeName(DiscoveryClientInstance.NACOS.name())
+                .build();
+
+        DiscoveryClient discoveryClient = null;
+        try {
+            // Use the existing NacosDiscoveryClient through 
DiscoveryClientManagement
+            discoveryClient = 
discoveryClientManagement.getClient(registryProtocol);
+            if (discoveryClient == null) {
+                builder.setCode(CollectRep.Code.FAIL);
+                builder.setMsg("Failed to get Nacos discovery client");
+                return;
+            }
+            
+            // Get all services registered in Nacos
+            List<ServiceInstance> services = discoveryClient.getServices();
+            if (CollectionUtils.isEmpty(services)) {
+                return;
+            }
+            
+            // Populate the response data with service information
+            services.forEach(service -> {
+                CollectRep.ValueRow.Builder valueRowBuilder = 
CollectRep.ValueRow.newBuilder();
+                valueRowBuilder.addColumn(service.getAddress());
+                valueRowBuilder.addColumn(String.valueOf(service.getPort()));
+                valueRowBuilder.addColumn(service.getServiceName());
+                valueRowBuilder.addColumn(service.getHealthStatus());
+                builder.addValueRow(valueRowBuilder.build());
+            });
+        } catch (Exception e) {
+            String errorMsg = CommonUtil.getMessageFromThrowable(e);
+            log.warn("Failed to fetch services from Nacos: {}", errorMsg);
+            builder.setCode(CollectRep.Code.FAIL);
+            builder.setMsg(errorMsg);
+        } finally {
+            // Close the discovery client to release resources
+            if (discoveryClient != null) {
+                try {
+                    discoveryClient.close();
+                } catch (Exception e) {
+                    log.warn("Failed to close Nacos discovery client: {}", 
CommonUtil.getMessageFromThrowable(e));
+                }
+            }
+        }
+    }
+    
+    @Override
+    public String supportProtocol() {
+        return DispatchConstants.PROTOCOL_NACOS_SD;
+    }
+}
diff --git 
a/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/sd/NacosSdCollectImplTest.java
 
b/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/sd/NacosSdCollectImplTest.java
new file mode 100644
index 0000000000..6fe312a28d
--- /dev/null
+++ 
b/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/sd/NacosSdCollectImplTest.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hertzbeat.collector.collect.sd;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import lombok.SneakyThrows;
+import 
org.apache.hertzbeat.collector.collect.registry.discovery.DiscoveryClient;
+import 
org.apache.hertzbeat.collector.collect.registry.discovery.DiscoveryClientManagement;
+import 
org.apache.hertzbeat.collector.collect.registry.discovery.entity.ServiceInstance;
+import org.apache.hertzbeat.collector.dispatch.DispatchConstants;
+import org.apache.hertzbeat.common.entity.job.Metrics;
+import org.apache.hertzbeat.common.entity.job.protocol.NacosSdProtocol;
+import org.apache.hertzbeat.common.entity.job.protocol.RegistryProtocol;
+import org.apache.hertzbeat.common.entity.message.CollectRep;
+import org.apache.hertzbeat.common.util.CommonUtil;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.util.ReflectionTestUtils;
+
+/**
+ * Test case for {@link NacosSdCollectImpl}
+ */
+@ExtendWith(MockitoExtension.class)
+class NacosSdCollectImplTest {
+
+    @InjectMocks
+    private NacosSdCollectImpl nacosSdCollectImpl;
+
+    @Mock
+    private DiscoveryClientManagement discoveryClientManagement;
+
+    @Mock
+    private DiscoveryClient discoveryClient;
+
+    private Metrics metrics;
+    private NacosSdProtocol nacosSdProtocol;
+    private CollectRep.MetricsData.Builder builder;
+
+    @BeforeEach
+    void setUp() {
+        nacosSdProtocol = NacosSdProtocol.builder()
+                .host("localhost")
+                .port("8848")
+                .username("nacos")
+                .password("nacos")
+                .build();
+
+        metrics = Metrics.builder()
+                .nacos_sd(nacosSdProtocol)
+                .build();
+
+        builder = CollectRep.MetricsData.newBuilder();
+
+        ReflectionTestUtils.setField(nacosSdCollectImpl, 
"discoveryClientManagement", discoveryClientManagement);
+    }
+    
+    @Test
+    void testPreCheckWithNullMetrics() {
+        IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, 
+                () -> nacosSdCollectImpl.preCheck(null));
+
+        assertEquals("Nacos service discovery monitoring, the config is null", 
exception.getMessage());
+    }
+    
+    @Test
+    void testPreCheckWithNullNacosSdConfig() {
+        Metrics metricsWithoutNacosSd = Metrics.builder().build();
+
+        IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, 
+                () -> nacosSdCollectImpl.preCheck(metricsWithoutNacosSd));
+
+        assertEquals("Nacos service discovery monitoring, the config is null", 
exception.getMessage());
+    }
+    
+    @Test
+    void testPreCheckWithInvalidNacosSdConfig() {
+        NacosSdProtocol invalidNacosSdProtocol = NacosSdProtocol.builder()
+                .host("")
+                .port("8848")
+                .build();
+
+        Metrics metricsWithInvalidNacosSd = Metrics.builder()
+                .nacos_sd(invalidNacosSdProtocol)
+                .build();
+
+        IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class,
+                () -> nacosSdCollectImpl.preCheck(metricsWithInvalidNacosSd));
+
+        assertEquals("Nacos service discovery monitoring, the config is 
invalid", exception.getMessage());
+
+        NacosSdProtocol portInvalidNacosSdProtocol = NacosSdProtocol.builder()
+                .host("localhost")
+                .port("")
+                .build();
+
+        Metrics portMetricsWithInvalidNacosSd = Metrics.builder()
+                .nacos_sd(portInvalidNacosSdProtocol)
+                .build();
+
+        exception = assertThrows(IllegalArgumentException.class,
+                () -> 
nacosSdCollectImpl.preCheck(portMetricsWithInvalidNacosSd));
+
+        assertEquals("Nacos service discovery monitoring, the config is 
invalid", exception.getMessage());
+    }
+    
+    @Test
+    void testPreCheckWithValidConfig() {
+        assertDoesNotThrow(() -> nacosSdCollectImpl.preCheck(metrics));
+    }
+    
+    @Test
+    void testCollectSuccess() throws Exception {
+        List<ServiceInstance> services = new ArrayList<>();
+        services.add(ServiceInstance.builder()
+                .serviceId("service-1")
+                .serviceName("user-service")
+                .address("192.168.1.10")
+                .port(8080)
+                .healthStatus("UP")
+                .build());
+        services.add(ServiceInstance.builder()
+                .serviceId("service-2")
+                .serviceName("order-service")
+                .address("192.168.1.11")
+                .port(8081)
+                .healthStatus("UP")
+                .build());
+
+        
when(discoveryClientManagement.getClient(any(RegistryProtocol.class))).thenReturn(discoveryClient);
+
+        when(discoveryClient.getServices()).thenReturn(services);
+
+        nacosSdCollectImpl.collect(builder, metrics);
+        
+
+        verify(discoveryClient, times(1)).close();
+
+        assertEquals(2, builder.getValuesCount());
+
+        CollectRep.ValueRow firstRow = builder.getValues(0);
+        assertEquals("192.168.1.10", firstRow.getColumns(0));
+        assertEquals("8080", firstRow.getColumns(1));
+        assertEquals("user-service", firstRow.getColumns(2));
+        assertEquals("UP", firstRow.getColumns(3));
+
+        CollectRep.ValueRow secondRow = builder.getValues(1);
+        assertEquals("192.168.1.11", secondRow.getColumns(0));
+        assertEquals("8081", secondRow.getColumns(1));
+        assertEquals("order-service", secondRow.getColumns(2));
+        assertEquals("UP", secondRow.getColumns(3));
+    }
+    
+    @Test
+    void testCollectClientNull() {
+        
when(discoveryClientManagement.getClient(any(RegistryProtocol.class))).thenReturn(null);
+
+        nacosSdCollectImpl.collect(builder, metrics);
+
+        assertEquals(CollectRep.Code.FAIL, builder.getCode());
+        assertEquals("Failed to get Nacos discovery client", builder.getMsg());
+    }
+    
+    @SneakyThrows
+    @Test
+    void testCollectWithException() {
+        String exceptionMessage = "Connection refused";
+        Exception testException = new RuntimeException(exceptionMessage);
+
+        
when(discoveryClientManagement.getClient(any(RegistryProtocol.class))).thenReturn(discoveryClient);
+        when(discoveryClient.getServices()).thenThrow(testException);
+
+        try (MockedStatic<CommonUtil> mockedCommonUtil = 
Mockito.mockStatic(CommonUtil.class)) {
+            mockedCommonUtil.when(() -> 
CommonUtil.getMessageFromThrowable(any(Throwable.class)))
+                    .thenReturn(exceptionMessage);
+
+            nacosSdCollectImpl.collect(builder, metrics);
+
+            assertEquals(CollectRep.Code.FAIL, builder.getCode());
+            assertEquals(exceptionMessage, builder.getMsg());
+
+            verify(discoveryClient, times(1)).close();
+        }
+    }
+    
+    @Test
+    void testCollectWithEmptyServiceList() throws Exception {
+        
when(discoveryClientManagement.getClient(any(RegistryProtocol.class))).thenReturn(discoveryClient);
+        
when(discoveryClient.getServices()).thenReturn(Collections.emptyList());
+
+        nacosSdCollectImpl.collect(builder, metrics);
+
+        assertEquals(0, builder.getValuesCount());
+
+        verify(discoveryClient, times(1)).close();
+    }
+    
+    @Test
+    void testSupportProtocol() {
+        assertEquals(DispatchConstants.PROTOCOL_NACOS_SD, 
nacosSdCollectImpl.supportProtocol());
+    }
+}
diff --git 
a/hertzbeat-collector/hertzbeat-collector-collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect
 
b/hertzbeat-collector/hertzbeat-collector-collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect
index c9e7d2b3ae..81ed299001 100644
--- 
a/hertzbeat-collector/hertzbeat-collector-collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect
+++ 
b/hertzbeat-collector/hertzbeat-collector-collector/src/main/resources/META-INF/services/org.apache.hertzbeat.collector.collect.AbstractCollect
@@ -29,6 +29,7 @@ org.apache.hertzbeat.collector.collect.mqtt.MqttCollectImpl
 org.apache.hertzbeat.collector.collect.ipmi2.IpmiCollectImpl
 org.apache.hertzbeat.collector.collect.kafka.KafkaCollectImpl
 org.apache.hertzbeat.collector.collect.sd.HttpSdCollectImpl
+org.apache.hertzbeat.collector.collect.sd.NacosSdCollectImpl
 org.apache.hertzbeat.collector.collect.sd.DnsSdCollectImpl
 org.apache.hertzbeat.collector.collect.sd.EurekaSdCollectImpl
 org.apache.hertzbeat.collector.collect.sd.ConsulSdCollectImpl
diff --git 
a/hertzbeat-collector/hertzbeat-collector-common/src/main/java/org/apache/hertzbeat/collector/dispatch/DispatchConstants.java
 
b/hertzbeat-collector/hertzbeat-collector-common/src/main/java/org/apache/hertzbeat/collector/dispatch/DispatchConstants.java
index 5e66be7202..b01a0ce8e9 100644
--- 
a/hertzbeat-collector/hertzbeat-collector-common/src/main/java/org/apache/hertzbeat/collector/dispatch/DispatchConstants.java
+++ 
b/hertzbeat-collector/hertzbeat-collector-common/src/main/java/org/apache/hertzbeat/collector/dispatch/DispatchConstants.java
@@ -127,6 +127,10 @@ public interface DispatchConstants {
      * protocol http sd
      */
     String PROTOCOL_HTTP_SD = "http_sd";
+    /**
+     * protocol nacos sd
+     */
+    String PROTOCOL_NACOS_SD = "nacos_sd";
     /**
      * protocol dns sd
      */
diff --git 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java
 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java
index 8317889d02..3b010bc399 100644
--- 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java
+++ 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/Metrics.java
@@ -36,6 +36,7 @@ import 
org.apache.hertzbeat.common.entity.job.protocol.HttpProtocol;
 import org.apache.hertzbeat.common.entity.job.protocol.EurekaSdProtocol;
 import org.apache.hertzbeat.common.entity.job.protocol.ConsulSdProtocol;
 import org.apache.hertzbeat.common.entity.job.protocol.ModbusProtocol;
+import org.apache.hertzbeat.common.entity.job.protocol.NacosSdProtocol;
 import org.apache.hertzbeat.common.entity.job.protocol.PlcProtocol;
 import org.apache.hertzbeat.common.entity.job.protocol.RegistryProtocol;
 import org.apache.hertzbeat.common.entity.job.protocol.IcmpProtocol;
@@ -280,6 +281,10 @@ public class Metrics {
      */
     private ConsulSdProtocol consul_sd;
     /**
+     * nacos sd protocol
+     */
+    private NacosSdProtocol nacos_sd;
+    /*
      * zookeeper sd protocol
      */
     private ZookeeperSdProtocol zookeeper_sd;
diff --git 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NacosSdProtocol.java
 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NacosSdProtocol.java
new file mode 100644
index 0000000000..148b3e328a
--- /dev/null
+++ 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NacosSdProtocol.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hertzbeat.common.entity.job.protocol;
+
+import org.apache.commons.lang3.StringUtils;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Nacos Service Discovery Protocol
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class NacosSdProtocol implements Protocol {
+    /**
+     * Nacos server host
+     */
+    private String host;
+    /**
+     * Nacos server port
+     */
+    private String port;
+    /**
+     * Nacos namespace
+     */
+    private String namespace;
+    /**
+     * Nacos username for authentication
+     */
+    private String username;
+    /**
+     * Nacos password for authentication
+     */
+    private String password;
+    
+    /**
+     * Check if the essential protocol parameters are invalid
+     * @return true if essential parameters are missing
+     */
+    public boolean isInvalid() {
+        return StringUtils.isAnyBlank(host, port);
+    }
+}
diff --git a/hertzbeat-manager/src/main/resources/define/app-nacos_sd.yml 
b/hertzbeat-manager/src/main/resources/define/app-nacos_sd.yml
new file mode 100644
index 0000000000..0a7bbfc9c0
--- /dev/null
+++ b/hertzbeat-manager/src/main/resources/define/app-nacos_sd.yml
@@ -0,0 +1,90 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# The monitoring type category: service-application service monitoring 
db-database monitoring custom-custom monitoring os-operating system monitoring
+category: __system__
+# Monitoring application type name (consistent with file name) eg: linux 
windows tomcat mysql aws...
+app: nacos_sd
+# The monitoring i18n name
+name:
+  zh-CN: Nacos 服务发现
+  en-US: Nacos Service Discovery
+# Input params define for app api(render web ui by the definition)
+params:
+  # field-param field key
+  - field: __nacos_sd_host__
+    # name-param field display i18n name
+    name:
+      zh-CN: Nacos 服务发现 Host
+      en-US: Nacos Service Discovery Host
+    # type-param field type(most mapping the html input type)
+    type: text
+    # required-true or false
+    required: true
+  - field: __nacos_sd_port__
+    name:
+      zh-CN: Nacos 服务发现 Port
+      en-US: Nacos Service Discovery Port
+    type: number
+    required: true
+#  - field: __nacos_namespace__
+#    name:
+#      zh-CN: Nacos 命名空间
+#      en-US: Nacos Namespace
+#    type: text
+#    required: false
+#  - field: __nacos_username__
+#    name:
+#      zh-CN: Nacos 用户名
+#      en-US: Nacos Username
+#    type: text
+#    required: false
+#  - field: __nacos_password__
+#    name:
+#      zh-CN: Nacos 密码
+#      en-US: Nacos Password
+#    type: password
+#    required: false
+
+metrics:
+  - name: target
+    i18n:
+      zh-CN: 监控目标
+      en-US: Monitor Target
+    # metrics scheduling priority(0->127)->(high->low), metrics with the same 
priority will be scheduled in parallel
+    # priority 0's metrics is availability metrics, it will be scheduled 
first, only availability metrics collect success will the scheduling continue
+    priority: 0
+    # collect metrics content
+    fields:
+      # field-metric name, type-metric type(0-number,1-string), unit-metric 
unit('%','ms','MB'), label-whether it is a metrics label field
+      - field: host
+        type: 1
+        i18n:
+          zh-CN: Host
+          en-US: Host
+      - field: port
+        type: 1
+        i18n:
+          zh-CN: Port
+          en-US: Port
+    # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, 
sdk
+    protocol: nacos_sd
+    # the config content when protocol is nacos_sd
+    nacos_sd:
+      host: ^_^__nacos_sd_host__^_^
+      port: ^_^__nacos_sd_port__^_^
+#      namespace: ^_^__nacos_namespace__^_^
+#      username: ^_^__nacos_username__^_^
+#      password: ^_^__nacos_password__^_^
\ No newline at end of file
diff --git 
a/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html 
b/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html
index 15adc0fd41..9a90897738 100644
--- a/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html
+++ b/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html
@@ -31,6 +31,7 @@
           >
             <nz-option nzValue="static" 
[nzLabel]="'monitor.scrape.type.static' | i18n"></nz-option>
             <nz-option nzValue="http_sd" 
[nzLabel]="'monitor.scrape.type.http_sd' | i18n"></nz-option>
+            <nz-option nzValue="nacos_sd" 
[nzLabel]="'monitor.scrape.type.nacos_sd' | i18n"></nz-option>
             <nz-option nzValue="dns_sd" 
[nzLabel]="'monitor.scrape.type.dns_sd' | i18n"></nz-option>
             <nz-option nzValue="eureka_sd" 
[nzLabel]="'monitor.scrape.type.eureka_sd' | i18n"></nz-option>
             <nz-option nzValue="consul_sd" 
[nzLabel]="'monitor.scrape.type.consul_sd' | i18n"></nz-option>
diff --git a/web-app/src/assets/i18n/en-US.json 
b/web-app/src/assets/i18n/en-US.json
index cb9a8d0cab..0bf7140de9 100644
--- a/web-app/src/assets/i18n/en-US.json
+++ b/web-app/src/assets/i18n/en-US.json
@@ -762,6 +762,7 @@
   "monitor.sshPrivateKey.tip": "BEGIN RSA PRIVATE KEY",
   "monitor.scrape.type.static": "Static Scrape",
   "monitor.scrape.type.http_sd": "Http Service Discovery",
+  "monitor.scrape.type.nacos_sd": "Nacos Service Discovery",
   "monitor.scrape.type.dns_sd": "Dns Service Discovery",
   "monitor.scrape.type.eureka_sd": "Eureka Service Discovery",
   "monitor.scrape.type.consul_sd": "Consul Service Discovery",
diff --git a/web-app/src/assets/i18n/ja-JP.json 
b/web-app/src/assets/i18n/ja-JP.json
index bb90d72227..7194402e6c 100644
--- a/web-app/src/assets/i18n/ja-JP.json
+++ b/web-app/src/assets/i18n/ja-JP.json
@@ -761,6 +761,7 @@
   "monitor.sshUsername.tip": "SSHトンネルオープン時に必要",
   "monitor.sshPrivateKey.tip": "RSA秘密鍵の起動",
   "monitor.scrape.type.static": "静的な設定",
+  "monitor.scrape.type.nacos_sd": "Nacos サービスディスカバリー",
   "monitor.scrape.type.dns_sd": "Dns サービスディスカバリー",
   "monitor.scrape.type.http_sd": "Http サービスディスカバリー",
   "monitor.scrape.type.eureka_sd": "Eurekaサービスディスカバリー",
diff --git a/web-app/src/assets/i18n/pt-BR.json 
b/web-app/src/assets/i18n/pt-BR.json
index 480a2420d0..d6e46475cf 100644
--- a/web-app/src/assets/i18n/pt-BR.json
+++ b/web-app/src/assets/i18n/pt-BR.json
@@ -573,6 +573,7 @@
     "monitor.sshPrivateKey.tip": "Chave privada RSA",
     "monitor.scrape.type.static": "Estatico",
     "monitor.scrape.type.http_sd": "Http Service Discovery",
+    "monitor.scrape.type.nacos_sd": "Nacos Service Discovery",
     "monitor.scrape.type.dns_sd": "Dns Service Discovery",
     "monitor.scrape.type.eureka_sd": "Eureka Service Discovery",
     "monitor.scrape.type.consul_sd": "Consul Service Discovery",
diff --git a/web-app/src/assets/i18n/zh-CN.json 
b/web-app/src/assets/i18n/zh-CN.json
index 3eb40b23c5..3c156e4624 100644
--- a/web-app/src/assets/i18n/zh-CN.json
+++ b/web-app/src/assets/i18n/zh-CN.json
@@ -762,6 +762,7 @@
   "monitor.sshPrivateKey.tip": "启动RSA私钥",
   "monitor.scrape.type.static": "静态配置",
   "monitor.scrape.type.http_sd": "Http 服务发现",
+  "monitor.scrape.type.nacos_sd": "Nacos 服务发现",
   "monitor.scrape.type.dns_sd": "Dns 服务发现",
   "monitor.scrape.type.eureka_sd": "Eureka 服务发现",
   "monitor.scrape.type.consul_sd": "Consul 服务发现",
diff --git a/web-app/src/assets/i18n/zh-TW.json 
b/web-app/src/assets/i18n/zh-TW.json
index 3559146ea8..88afe5f9d4 100644
--- a/web-app/src/assets/i18n/zh-TW.json
+++ b/web-app/src/assets/i18n/zh-TW.json
@@ -761,6 +761,7 @@
   "monitor.sshPrivateKey.tip": "啟動RSA私鑰",
   "monitor.scrape.type.static": "靜態配置",
   "monitor.scrape.type.http_sd": "Http 服務發現",
+  "monitor.scrape.type.nacos_sd": "Nacos 服務發現",
   "monitor.scrape.type.dns_sd": "Dns 服務發現",
   "monitor.scrape.type.eureka_sd": "Eureka 服務發現",
   "monitor.scrape.type.consul_sd": "Consul 服務發現",


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

Reply via email to