当前位置: 首页 > news >正文

佛山网站建设原创张家港建筑培训网

佛山网站建设原创,张家港建筑培训网,微信小程序开发注意事项,土巴兔装修贵吗文章目录 Spring Boot Prometheus 实现应用监控#xff08;基于 Actuator 和 Micrometer#xff09;环境准备示例结构启动和验证验证 Spring Boot 应用Prometheus 抓取配置#xff08;静态方式#xff09;Grafana 面板配置总结 Spring Boot Prometheus 实现应用监控… 文章目录 Spring Boot Prometheus 实现应用监控基于 Actuator 和 Micrometer环境准备示例结构启动和验证验证 Spring Boot 应用Prometheus 抓取配置静态方式Grafana 面板配置总结 Spring Boot Prometheus 实现应用监控基于 Actuator 和 Micrometer 在微服务架构中监控是保障系统稳定运行的关键组成部分。本文将介绍如何通过 Spring Boot 的 actuator 和 micrometer 组件将应用的运行指标暴露出来并使用 Prometheus 定时采集这些指标数据。 环境准备 JDK21Spring Boot3.2.5构建工具Maven监控工具Prometheus 2.53.4 安装参考面板工具Grafana v9.1.2 安装参考 示例结构 test/ ├── pom.xml # Maven 项目对象模型文件 ├── src │ └── main │ ├── java │ │ └── com │ │ └── example │ │ └── DemoMonitorApplication.java # 主类(示例控制器) │ └── resources │ └── application.yml # 应用配置文件pom.xml 文件内容如下 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersion!-- ✅ 加入 Spring Boot 官方 parent自动管理版本号 --parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.2.5/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.example/groupIdartifactIddemo-monitor/artifactIdversion1.0.0/versionpackagingjar/packagingnamedemo-monitor/namepropertiesjava.version21/java.version/propertiesdependencies!-- Web 服务 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!-- Actuator 监控端点 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency!-- Prometheus 指标导出 --dependencygroupIdio.micrometer/groupIdartifactIdmicrometer-registry-prometheus/artifactId/dependency/dependenciesbuildplugins!-- Spring Boot 插件 --plugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project模块用途spring-boot-starter-web提供 Web 支持spring-boot-starter-actuator暴露监控端点如 /actuator/healthmicrometer-registry-prometheus让 Prometheus 能采集指标spring-boot-maven-pluginMaven 构建可执行 jar 的插件 src/main/java/com/example/DemoMonitorApplication.java 内容如下 package com.example;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication public class DemoMonitorApplication {public static void main(String[] args) {SpringApplication.run(DemoMonitorApplication.class, args);} }src/main/resources/application.yml 内容如下 server:port: 8080management:endpoints:web:exposure:include: *endpoint:health:show-details: alwaysmetrics:export:prometheus:enabled: true说明 management.endpoints.web.exposure.include: 暴露的端点必须包含 prometheusmanagement.metrics.export.prometheus.enabled: 启用 Prometheus 导出默认 Prometheus 指标路径为 /actuator/prometheus注意上述依赖中未显式声明版本号是因为使用了 Spring Boot 的官方 parent 启动和验证 使用 Maven 启动项目 ./mvnw spring-boot:run或打包后运行 mvn clean package java -jar target/demo-monitor-1.0.0.jar然后就可以看到有个 8080 端口启动了 验证 Spring Boot 应用 启动应用后访问指标接口 http://localhost:8080/actuator/prometheus你可以看到形如以下格式的指标输出 Prometheus 抓取配置静态方式 Prometheus 配置示例prometheus.yml scrape_configs:- job_name: spring-boot-appmetrics_path: /actuator/prometheusstatic_configs:- targets: [localhost:8080]启动 Prometheus 后访问 http://localhost:9090 你就可以查询该 Spring Boot 应用的各类指标了如 Grafana 面板配置 表盘市场导入仪表盘:访问地址 ID:14370 总结 依赖配置简单通过引入 spring-boot-starter-actuator 和 micrometer-registry-prometheus即可在 Spring Boot 中集成监控能力。指标暴露统一所有 JVM、应用及自定义指标统一暴露在 /actuator/prometheus 接口上。Prometheus 易于集成通过 Prometheus 的 scrape_configs 采集配置即可定时拉取指标数据。适用于单体与微服务架构无论是本地部署还是容器化Spring Boot Prometheus 都是轻量而强大的监控方案。 若后续部署在 Kubernetes 集群中采集多实例指标。欢迎继续探讨
http://www.pierceye.com/news/681432/

相关文章:

  • 商家在携程旅游网站怎样做宣传ppt免费下载素材库
  • 下载建设银行官方网站下载网站模块介绍
  • 网站定制开发公司推荐网站续费问题
  • 专注七星彩网站开发出租云服务器上建网站
  • 天津做网站.都找津坤科技中国菲律宾历史战绩
  • 网站建设合同的效力网站建设公司需要交税么
  • 色弱可以做网站开发吗建网站的步骤及方法
  • 卖衣服的网站排名discuz分类信息模板
  • 广西网站开发公司招聘网页制作软件
  • 网站框架一般用什么做dede搭建网站教程
  • 郑州网站开发比较好的网络公司网络推广公司有多少家
  • 银川做网站服务免费word模板
  • 个人网站备案方法网站开发制作云盘
  • 培训做网站传奇手游发布网站
  • 中国保密在线网站培训系统手机购物平台
  • 厦门网站制作建设沐风 wordpress 主题
  • 网站选择城市怎么做北京招聘信息
  • 一个做搞笑类视频的网站取名手机端企业网站源码
  • 房地产网站模板网站建设论文范文
  • 任丘网站制作公司pc网站制作公司
  • 惠州城乡规划建设局网站工程公司经营范围
  • 淮南服装网站建设地址巴彦淖尔网站建设公司
  • 如何让自己的网站被百度收录wordpress 悬浮网易云
  • 天津展示型网站建设外包腾讯云wordpress镜像
  • python做网站点登入没反映wordpress母公司
  • 中国建设培训网站查询系统地产项目网站建设ppt
  • 温州高端网站建设网站开发实验心得
  • 设计参考网站有哪些陕西省西安市事业单位招聘网
  • 月编程做网站wordpress需要调用缩略图
  • 做一份网站动态图多少钱网站托管服务公司