图文简介

快速开始

1、Spring Boot 应用暴露监控指标【版本 1.5.7.RELEASE】

首先,添加依赖如下依赖:

        <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>

然后,在启动类 Application.java 添加如下注解:

@SpringBootApplication
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
public class Application { public static void main(String[] args) {
SpringApplication.run(Application.class, args);
} }

最后,配置默认的登录账号和密码,在 application.yml 中:

security:
user:
name: user
password: pwd

提示:不建议配置 management.security.enabled: false

启动应用程序后,会看到如下一系列的 Mappings

利用账号密码访问 http://localhost:8080/application/prometheus ,可以看到 Prometheus 格式的指标数据

2、Prometheus 采集 Spring Boot 指标数据

首先,获取 Prometheus 的 Docker 镜像:

$ docker pull prom/prometheus

然后,编写配置文件 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 + 端口号

接着,启动 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

最后,访问 http://localhost:9090/targets , 检查 Spring Boot 采集状态是否正常。

3、Grafana 可视化监控数据

首先,获取 Grafana 的 Docker 镜像:

$ docker pull grafana/grafana

然后,启动 Grafana:

$ docker run --name grafana -d -p 3000:3000 grafana/grafana

接着,访问 http://localhost:3000/ 配置 Prometheus 数据源:

Grafana 登录账号 admin 密码 admin

最后,配置单个指标的可视化监控面板:

提示,此处不能任意填写,只能填已有的指标点,具体的可以在 Prometheus 的首页看到,即 http://localhost:9090/graph

多配置几个指标之后,即可有如下效果:

参考文档

文末福利

Java 资料大全 链接:https://pan.baidu.com/s/1pUCCPstPnlGDCljtBVUsXQ 密码:b2xc

更多资料: 2020 年 精选阿里 Java、架构、微服务精选资料等,加 v ❤ :qwerdd111

转载,请保留原文地址,谢谢 ~

Spring-Boot-应用可视化监控的更多相关文章

  1. 微服务监控之三:Prometheus + Grafana Spring Boot 应用可视化监控

    一.Springboot增加Prometheus 1.Spring Boot 应用暴露监控指标,添加如下依赖 <dependency> <groupId>org.springf ...

  2. 拒绝黑盒应用-Spring Boot 应用可视化监控

    图文简介 逻辑关系 效果演示 快速开始 1.Spring Boot 应用暴露监控指标[版本 1.5.7.RELEASE] 首先,添加依赖如下依赖: <dependency> <gro ...

  3. (转)Spring Boot(二十):使用 spring-boot-admin 对 Spring Boot 服务进行监控

    http://www.ityouknow.com/springboot/2018/02/11/spring-boot-admin.html 上一篇文章<Spring Boot(十九):使用 Sp ...

  4. Spring Boot Admin2.X监控的服务context-path问题

    在使用Spring Boot Admin进行监控时,如果被监控的服务没有加context-path的话是不会有任何问题的,一旦服务加了context-path的配置,监控就会失败. 下图是正常情况的显 ...

  5. Spring Boot 2.x监控数据可视化(Actuator + Prometheus + Grafana手把手)

    TIPS 本文基于Spring Boot 2.1.4,理论支持Spring Boot 2.x所有版本 众所周知,Spring Boot有个子项目Spring Boot Actuator,它为应用提供了 ...

  6. Spring Cloud第十三篇 | Spring Boot Admin服务监控

    本文是Spring Cloud专栏的第十三篇文章,了解前十二篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...

  7. spring boot/cloud 应用监控

    应用的监控功能,对于分布式系统非常重要.如果把分布式系统比作整个社会系统.那么各个服务对应社会中具体服务机构,比如银行.学校.超市等,那么监控就类似于警察局和医院,所以其重要性显而易见.这里说的,监控 ...

  8. spring Boot 学习(八、Spring Boot与与监控管理)

    一.监控管理通过引入spring-boot-starter-actuator,可以使用Spring Boot为我们提供的准 生产环境下的应用监控和管理功能.我们可以通过HTTP,JMX,SSH协议来进 ...

  9. Spring Boot配置druid监控页功能

    1.导入坐标 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http ...

  10. 基于spring boot admin 做监控的一些问题记录

    问题一 各个健康节点权限问题 解决方式 加入权限模块 <dependency> <groupId>org.springframework.boot</groupId> ...

随机推荐

  1. Python2 和 Python3的区别 更新中

    py2和py3的区别 1.默认解释器编码 py2: ascii py3: utf-8 2.输入 输出 输入 py2: name = raw_input('请输入你的姓名:') py3: name = ...

  2. C2. Power Transmission (Hard Edition)(线段相交)

    This problem is same as the previous one, but has larger constraints. It was a Sunday morning when t ...

  3. linux上部署jenkins

    http://www.pianshen.com/article/1133171043/相关jenkins链接 下载jenkins的war包:https://blog.csdn.net/Aaron_Zh ...

  4. arduino basic issue

    1.    string char Str1[15]; char Str2[8] = {'a', 'r', 'd', 'u', 'i', 'n', 'o'}; char Str3[8] = {'a', ...

  5. Mock相关知识和简单应用

    一.moco的简单应用 moco地址:https://github.com/dreamhead/moco api文档地址: https://github.com/dreamhead/moco/blob ...

  6. file,path,uri互相转换

    uri 转 file :File file = new File(new URI(uri.toString())); uri 转 path: Path path = Files.get(uri); f ...

  7. openpyxl传入表名时不要使用默认的sheet表名

    openpyxl传入表名时不要使用默认的sheet表名,会报错 处理:改一下表名即可

  8. 吴裕雄--天生自然 R语言开发学习:方差分析

    #-------------------------------------------------------------------# # R in Action (2nd ed): Chapte ...

  9. mac安装并配置nexus3.5.1版本

    一.安装nexus 前置条件 :已经安装了JDK 1:下载nexus(http://www.sonatype.com/download-oss-sonatype) 最新版本(我的是3.5.1). 2: ...

  10. 关于HTTP协议与HTTP状态码的简要介绍

    在互联网时代HTTP协议的重要性无需多言,对于技术岗位的同学们来说理解掌握HTTP协议是必须的.本篇博客就从HTTP协议的演进.特性.重要知识点和工作中常见问题的总结等方面进行简单的介绍.理解掌握了这 ...