Browse Source

增加kafka链路监控

zyl 2 months ago
parent
commit
9604c807ec

+ 33 - 0
liutongyi-admin/src/main/java/com/citygis/web/config/KafkaConfig.java

@@ -0,0 +1,33 @@
+package com.citygis.web.config;
+
+import lombok.Data;
+import org.apache.kafka.clients.admin.AdminClient;
+import org.apache.kafka.clients.admin.AdminClientConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Properties;
+
+/**
+ * @Package com.shcd.config
+ * @Author zyl
+ * @Date 2024/5/29 0029 10:34
+ * @description: kafka配置类
+ */
+@Configuration
+@Data
+public class KafkaConfig {
+
+    @Value("${kafka.ip}")
+    private String ip;
+
+    @Bean
+    public AdminClient adminClient() {
+        Properties properties = new Properties();
+        properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, ip);
+        return AdminClient.create(properties);
+    }
+
+}
+

+ 15 - 0
liutongyi-admin/src/main/java/com/citygis/web/config/MeterRegistryConfig.java

@@ -0,0 +1,15 @@
+package com.citygis.web.config;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MeterRegistryConfig {
+
+    @Bean
+    public MeterRegistry meterRegistry() {
+        return new SimpleMeterRegistry();
+    }
+}

+ 6 - 0
liutongyi-admin/src/main/resources/application.yml

@@ -139,3 +139,9 @@ xss:
 
 catalog:
   url: http://localhost:5001
+
+kafka:
+  ip: 127.0.0.1:9092
+
+jmx:
+  jmxServiceUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:3010/jmxrmi