Spring-Boot-应用可视化监控
图文简介
快速开始
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-应用可视化监控的更多相关文章
- 微服务监控之三:Prometheus + Grafana Spring Boot 应用可视化监控
一.Springboot增加Prometheus 1.Spring Boot 应用暴露监控指标,添加如下依赖 <dependency> <groupId>org.springf ...
- 拒绝黑盒应用-Spring Boot 应用可视化监控
图文简介 逻辑关系 效果演示 快速开始 1.Spring Boot 应用暴露监控指标[版本 1.5.7.RELEASE] 首先,添加依赖如下依赖: <dependency> <gro ...
- (转)Spring Boot(二十):使用 spring-boot-admin 对 Spring Boot 服务进行监控
http://www.ityouknow.com/springboot/2018/02/11/spring-boot-admin.html 上一篇文章<Spring Boot(十九):使用 Sp ...
- Spring Boot Admin2.X监控的服务context-path问题
在使用Spring Boot Admin进行监控时,如果被监控的服务没有加context-path的话是不会有任何问题的,一旦服务加了context-path的配置,监控就会失败. 下图是正常情况的显 ...
- Spring Boot 2.x监控数据可视化(Actuator + Prometheus + Grafana手把手)
TIPS 本文基于Spring Boot 2.1.4,理论支持Spring Boot 2.x所有版本 众所周知,Spring Boot有个子项目Spring Boot Actuator,它为应用提供了 ...
- Spring Cloud第十三篇 | Spring Boot Admin服务监控
本文是Spring Cloud专栏的第十三篇文章,了解前十二篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...
- spring boot/cloud 应用监控
应用的监控功能,对于分布式系统非常重要.如果把分布式系统比作整个社会系统.那么各个服务对应社会中具体服务机构,比如银行.学校.超市等,那么监控就类似于警察局和医院,所以其重要性显而易见.这里说的,监控 ...
- spring Boot 学习(八、Spring Boot与与监控管理)
一.监控管理通过引入spring-boot-starter-actuator,可以使用Spring Boot为我们提供的准 生产环境下的应用监控和管理功能.我们可以通过HTTP,JMX,SSH协议来进 ...
- Spring Boot配置druid监控页功能
1.导入坐标 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http ...
- 基于spring boot admin 做监控的一些问题记录
问题一 各个健康节点权限问题 解决方式 加入权限模块 <dependency> <groupId>org.springframework.boot</groupId> ...
随机推荐
- LeetCode No.97,98,99
No.97 IsInterleave 交错字符串 题目 给定三个字符串 s1, s2, s3, 验证 s3 是否是由 s1 和 s2 交错组成的. 示例 输入: s1 = "aabcc&qu ...
- 关于Java杂项知识总结
JVM内存结构 JVM在运行时把从操作系统申请到的内存分为若干区域,主要有栈.堆和方法区,方便Java程序使用 堆内存 使用new关键字创建出来的对象都存储在堆内存中 方法区 被加载的类的信息存储在方 ...
- idea 创建项目没有web.xml文件,如何添加
1.首先看下项目工程里面是否有WEB-INF文件夹,没有就创建一个 2.点击 file 选择 project structure 3.选择 facets,点击+号, 选择 web 4.弹出 弹框 选择 ...
- python中安装surprise中出现error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":
pip安装 安装之前要先进行numpy的安装 pip install numpy pip install surprise 安装出错: 安装surprise需要Microsoft visual c++ ...
- [LC] 161. One Edit Distance
Given two strings s and t, determine if they are both one edit distance apart. Note: There are 3 pos ...
- 学习C++之前要先学习C语言吗?
C++ 读作“C加加”,是“C Plus Plus”的简称.顾名思义,C++ 是在C语言的基础上增加新特性,玩出了新花样,所以叫“C Plus Plus”,就像 iPhone 7S 和 iPhone ...
- 用Spring Tool Suite简化你的开发
如果你是一个喜欢用spring的人,你可能会在欣赏spring的强大功能外,对其各样的配置比较郁闷,尤其是相差较大的版本在配置文件方面会存在差异,当然你可以去花不少的时间去网上查找相关的资料,当你准备 ...
- svn使用3 (转)
接下来,试试用TortoiseSVN修改文件,添加文件,删除文件,以及如何解决冲突等. 添加文件 在检出的工作副本中添加一个Readme.txt文本文件,这时候这个文本文件会显示为没有版本控制的状态, ...
- Qt 信号阻塞和断开
Qt程序中有时候不希望信号槽的触发,在某段流程结束之后,又需要继续回复信号槽状态,这时候可以用阻塞或者断开信号槽的方法来处理. 1. 阻塞方法:bool QObject::blockSignals(b ...
- CAD安装未完成,某些产品无法安装的解决方法
CAD提示安装未完成,某些产品无法安装该怎样解决呢?,一些朋友在win7或者win10系统下安装CAD失败提示CAD安装未完成,某些产品无法安装,也有时候想重新安装CAD的时候会出现本电脑window ...