forked from eacdy/spring-boot-study
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spring boot使用prometheus + grafana实现监控数据可视化
- Loading branch information
Showing
8 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.1.4.RELEASE</version> | ||
<relativePath/> | ||
</parent> | ||
<groupId>com.itmuch.actuator.prometheus</groupId> | ||
<artifactId>spring-boot-actuator-prometheus-grafana</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>spring-boot-actuator-prometheus-grafana</name> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-actuator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micrometer</groupId> | ||
<artifactId>micrometer-registry-prometheus</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
3 changes: 3 additions & 0 deletions
3
spring-boot-actuator-prometheus-grafana/prometheus+grafana/grafana.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
docker run -d -p 3000:3000 grafana/grafana |
7 changes: 7 additions & 0 deletions
7
spring-boot-actuator-prometheus-grafana/prometheus+grafana/prometheus.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
scrape_configs: | ||
- job_name: 'spring' | ||
scrape_interval: 15s | ||
scrape_timeout: 10s | ||
metrics_path: '/actuator/prometheus' | ||
static_configs: | ||
- targets: ['30.1.229.89:8080'] |
5 changes: 5 additions & 0 deletions
5
spring-boot-actuator-prometheus-grafana/prometheus+grafana/start_prometheus.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
docker run -d -p 9090:9090 \ | ||
-v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \ | ||
prom/prometheus --config.file=/etc/prometheus/prometheus.yml |
13 changes: 13 additions & 0 deletions
13
...heus-grafana/src/main/java/com/itmuch/actuator/prometheus/demo/PrometheusApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.itmuch.actuator.prometheus.demo; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class PrometheusApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(PrometheusApplication.class, args); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...-prometheus-grafana/src/main/java/com/itmuch/actuator/prometheus/demo/TestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.itmuch.actuator.prometheus.demo; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author itmuch.com | ||
*/ | ||
@RestController | ||
public class TestController { | ||
@GetMapping("/test") | ||
public String test() { | ||
return "test"; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
spring-boot-actuator-prometheus-grafana/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server: | ||
port: 8080 | ||
spring: | ||
application: | ||
name: prometheus-test | ||
management: | ||
endpoints: | ||
web: | ||
exposure: | ||
include: 'prometheus' | ||
metrics: | ||
tags: | ||
application: ${spring.application.name} | ||
|