Graphic Profile
Quick Start
1, Spring Boot application exposure monitoring indicators [version] 1.5.7.RELEASE
First, add the following dependence dependent:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_spring_boot</artifactId>
<version>0.0.26</version>
</dependency>复制代码
Then, start the class Application.java
, add the following comment:
@SpringBootApplication
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}复制代码
Finally, configure the default user name and password, in the application.yml
middle:
security:
user:
name: user
password: pwd复制代码
Tip: Not recommended configuration
management.security.enabled: false
After starting the application, you will see the following series of Mappings
Using the account password to access HTTP: // localhost: 8080 / the Application / Prometheus , Prometheus can see metrics data format
2, Prometheus index data collection Spring Boot
First, get the Prometheus Docker image:
$ docker pull prom/prometheus复制代码
Then, write a configuration file prometheus.yml
:
global:
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 10m
scrape_configs:
- job_name: spring-boot
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /application/prometheus
scheme: http
basic_auth:
username: user
password: pwd
static_configs:
- targets:
- 127.0.0.1:8080 #此处填写 Spring Boot 应用的 IP + 端口号复制代码
Then, start Prometheus:
$ docker run -d \
--name prometheus \
-p 9090:9090 \
-m 500M \
-v "$(pwd)/prometheus.yml":/prometheus.yml \
-v "$(pwd)/data":/data \
prom/prometheus \
-config.file=/prometheus.yml \
-log.level=info复制代码
Finally, access to HTTP: // localhost: 9090 / Targets , check the Spring Boot collection status is normal.
3, Grafana visual monitoring data
First, get Grafana of Docker image:
$ docker pull grafana/grafana复制代码
Then, start Grafana:
$ docker run --name grafana -d -p 3000:3000 grafana/grafana复制代码
Next, access http: // localhost: 3000 / configuration Prometheus Source:
Grafana login account admin password admin
Finally, configure a single visual monitoring panel indicators:
Tip here can not fill any, can only fill existing index points, concrete can be seen in Prometheus home, namely http: // localhost: 9090 / graph
After several indicators multiple configurations, you can have the following effects:
Reference Documents
The end of the sentence welfare
Java Sourcebook link: pan.baidu.com/s/1pUCCPstP... Password: b2xc More Information: 2020 Featured Ali Java, architecture, micro-service selection information, etc., plus v ❤: qwerdd111
This article from the blog article multiple platforms OpenWrite release!