本文介绍SpringBoot使用蚂蚁金服SOFA-Lookout配合Prometheus进行监控。

1.SOFA-Lookout介绍

上一篇已经介绍使用Prometheus进行暴露SpringBoot的一些指标进行监控,传送门,这一篇介绍如何使用SOFA-Lookout配合Prometheus。

SOFA-Lookout是蚂蚁金服开源的一款解决系统的度量和监控问题的轻量级中间件服务。它提供的服务包括:Metrics 的埋点、收集、加工、存储与查询等。

正如介绍的,SOFA-Lookout提供了一些常用的监控指标,比如JVM线程,JVM类加载,JVM内存,JVM垃圾回收,机器文件系统信息和机器信息。在1.5.0版本之后默认也提供了一些Linux操作系统的信息。具体可以查看:https://www.sofastack.tech/sofa-lookout/docs/client-ext-metrics

2.SpringBoot使用SOFA-Lookout

2.1 配置依赖

新建项目,在项目中加入SOFA依赖,完整pom如下所示。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dalaoyang</groupId>
<artifactId>springboot2_sofa_lookout</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot2_sofa_lookout</name>
<description>springboot2_sofa_lookout</description> <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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-sofa-boot-starter</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-reg-prometheus</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

2.2 配置SOFA-Lookout端口

这里需要配置一个SOFA-Lookout的端口,生产环境使用的话一定要查看这个端口是不是被占用了。配置如下,这里配置的端口是8081。

spring.application.name=springboot2_sofa_lookout
com.alipay.sofa.lookout.prometheus-exporter-server-port=8081

其实到这里,SpringBoot项目已经配置完成了,当然还可以自定义一些指标,这里不做介绍。

3.Prometheus配置

Prometheus需要配置一下刚刚SOFA-Lookout的端口,如下:

  - job_name: 'springboot2_sofa_lookout'
scrape_interval: 5s
static_configs:
- targets: ['localhost:8081']

4.Grafana

这里也可以将Prometheus展示给Grafana,我也查询了很多,但是貌似目前Grafana还没有默认推荐的Dashboard,大家可以根据情况自行构建,当然,如果有好的也希望可以推荐一下。

5.测试

启动SpringBoot应用,控制台如下所示。

看到红框部分就是启动成功了。接下来查看Prometheus界面,如下。

这里Grafana在看一下Grafana界面,如图。

6.源码

源码地址:https://gitee.com/dalaoyang/springboot_learn/tree/master/springboot2_sofa_lookout

SpringBoot使用SOFA-Lookout监控的更多相关文章

  1. 0109 springboot的部署测试监控

    springboot的部署测试监控 部署 基于maven 打包 JAR 打包方式一般采用的jar包,使用springboot的默认方式即可: 使用maven命令: mvn clean package ...

  2. SpringBoot系列——admin服务监控

    前言 springboot项目部署起来后,如何实时监控项目的运行状况呢?本文记录使用springboot-admin对服务进行监控. springboot-admin介绍:https://codece ...

  3. spring-boot 之 使用Admin监控应用

    https://yq.aliyun.com/articles/2322 ************************************* 摘要: Spring Boot提供的监控接口,例如: ...

  4. SpringBoot集成阿里巴巴Druid监控

    druid是阿里巴巴开源的数据库连接池,提供了优秀的对数据库操作的监控功能,本文要讲解一下springboot项目怎么集成druid. 本文在基于jpa的项目下开发,首先在pom文件中额外加入drui ...

  5. 为springboot项目添加springboot-admin监控

    我们知道spring-boot-actuator暴露了大量统计和监控信息的端点,spring-boot-admin 就是为此提供的监控项目. 先来看看大概会提供什么样的功能 从图中可以看出,主要内容都 ...

  6. 给你的SpringBoot做埋点监控--JVM应用度量框架Micrometer

    JVM应用度量框架Micrometer实战 前提 spring-actuator做度量统计收集,使用Prometheus(普罗米修斯)进行数据收集,Grafana(增强ui)进行数据展示,用于监控生成 ...

  7. Spring-Boot之Admin服务监控-9

    一.Spring Boot Admin用于管理和监控一个或者多个Spring Boot程序.Spring Boot Admin分为Server端和Client 端,Client端可以通过向Http S ...

  8. SpringBoot整合SpringAdmin搭建监控平台

    在SpringBoot整合Actuator进行健康监控中,胜金讲述了通过Actuator进行健康监控,但是学习API并根据API开发前端需要花费相当大的精力,本次胜金就写一下通过SpringAdmin ...

  9. 【SpringBoot】16. 如何监控springboot的健康状况

    如何监控springboot的健康状况 SpringBoot1.5.19.RELEASE 一.使用Actuator检查与监控 actuaotr是spring boot项目中非常强大的一个功能,有助于对 ...

  10. SpringBoot 原理分析、监控、项目部署

    目录 SpringBoot 监控 概述 使用 SpringBoot Admin 概述 使用 SpringBoot 项目部署 SpringBoot 监控 概述 SpringBoot 自带监控功能 Act ...

随机推荐

  1. [面试]future模式

    Future模式 什么是future模式? 传统单线程环境下,调用函数是同步的,必须等待程序返回结果后,才可进行其他处理. Futrue模式下,调用方式改为异步. Futrue模式的核心在于:充分利用 ...

  2. Angular记录(10)

    文档资料 速查表:https://www.angular.cn/guide/cheatsheet 风格指南:https://www.angular.cn/guide/styleguide Angula ...

  3. XGBoost参数调优完全指南

    简介 如果你的预测模型表现得有些不尽如人意,那就用XGBoost吧.XGBoost算法现在已经成为很多数据工程师的重要武器.它是一种十分精致的算法,可以处理各种不规则的数据.构造一个使用XGBoost ...

  4. PC端判断浏览器类型及移动端判断移动设备类型

    浏览器代理检测,可以检测出来用户使用的浏览器类型,也可以检测浏览器所在的操作系统 navigator.userAgent (1).判断浏览器类型 var t = navigator.userAgent ...

  5. Springboot项目打包后的页面丢失问题(thymeleaf报错)

    遇到的问题目前找到两种: 返回视图路径以/开头,例如 /test/hello 在thymeleaf页面中,引入的页面以/开头,例如:<footer th:replace="/index ...

  6. php nginx 负载均衡简单配置过程

    负载均衡 负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 简单了解一下什么是负载均衡,单从字面上的意思来理解就可以解 ...

  7. 2019 icpc南昌全国邀请赛-网络选拔赛J题 树链剖分+离线询问

    链接:https://nanti.jisuanke.com/t/38229 题意: 给一棵树,多次查询,每次查询两点之间权值<=k的边个数 题解: 离线询问,树链剖分后bit维护有贡献的位置即可 ...

  8. 帆软报表(finereport)使用row_number ()进行组内排序

    ROW_NUMBER()函数将针对SELECT语句返回的每一行,从1开始编号,赋予其连续的编号.在查询时应用了一个排序标准后,只有通过编号才能够保证其顺序是一致的,当使用ROW_NUMBER函数时,也 ...

  9. A - Alice's Print Service ZOJ - 3726 (二分)

    Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using h ...

  10. 详解MariaDB数据库的触发器

    1.什么是触发器 触发器是一种特殊的存储过程,它在插入,删除或修改特定表中的数据时触发执行 它比数据库本身标准的功能有更精细和更复杂的数据控制能力 2.触发器的作用: 2.1 安全性 可以基于数据库的 ...