Commit a6ecd1b0 authored by 赵啸非's avatar 赵啸非

添加prometheus指标测算

parent a9e36f61
...@@ -2,11 +2,18 @@ package com.mortals.xhx; ...@@ -2,11 +2,18 @@ package com.mortals.xhx;
import com.mortals.framework.springcloud.boot.BaseWebApplication; import com.mortals.framework.springcloud.boot.BaseWebApplication;
import com.mortals.framework.util.HttpUtil; import com.mortals.framework.util.HttpUtil;
import io.prometheus.client.exporter.MetricsServlet;
import io.prometheus.client.hotspot.DefaultExports;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.ImportResource;
import javax.annotation.PostConstruct;
@EnableFeignClients @EnableFeignClients
@SpringBootApplication(scanBasePackages = {"com.mortals"}) @SpringBootApplication(scanBasePackages = {"com.mortals"})
@ServletComponentScan("com.mortals") @ServletComponentScan("com.mortals")
...@@ -17,5 +24,17 @@ public class ManagerBaseApplication extends BaseWebApplication { ...@@ -17,5 +24,17 @@ public class ManagerBaseApplication extends BaseWebApplication {
SpringApplication.run(ManagerBaseApplication.class, args); SpringApplication.run(ManagerBaseApplication.class, args);
} }
@Bean
public ServletRegistrationBean<MetricsServlet> getServletRegistrationBean() {
ServletRegistrationBean<MetricsServlet> bean = new ServletRegistrationBean<MetricsServlet>(new MetricsServlet());
bean.addUrlMappings("/metrics");
return bean;
}
@PostConstruct
public void init() {
DefaultExports.initialize();
}
} }
...@@ -91,6 +91,22 @@ ...@@ -91,6 +91,22 @@
<version>1.6.12</version> <version>1.6.12</version>
</dependency> </dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_servlet</artifactId>
<version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_hotspot</artifactId>
<version>0.16.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment