prometheus+grafana替代Zabbix监控springboot

本文涉及的产品
可观测监控 Prometheus 版,每月50GB免费额度
可观测可视化 Grafana 版,10个用户账号 1个月
简介: prometheus+grafana替代Zabbix监控springboot


image.png

1.下载可视化模板

通过上文可知grafana为显示页面,所以本文提供一份监控springboot的json页面供大家下载。

链接:https://pan.baidu.com/s/1h5yrTsqUKj-Kq3GuHtNWow

提取码:ehbv

2.配置SpringBoot

1.修改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_prometheus</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>springboot2_prometheus</name>
  <description>springboot2_prometheus</description>
  <properties>
    <java.version>1.8</java.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <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>io.micrometer</groupId>
      <artifactId>micrometer-registry-prometheus</artifactId>
      <version>1.1.3</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

2.修改application.yml

management:
  endpoints:
    web:
      exposure:
        include: '*'
  metrics:
    tags:
      application: ${spring.application.name}
  health:
    redis:
      enabled: false

3.设置application

在启动问价中加入以下代码。

image.png

    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName) {
        return (registry) -> registry.config().commonTags("application", applicationName);
    }

SpringBoot项目到这里就配置完成了,启动项目,访问http://ip:8080/actuator/prometheus即可看到返回值,这些值就是spring boot返回在前台页面的信息。

image.png

3.Prometheus配置

在prometheus配置监控我们的SpringBoot应用,完整配置如下所示。找到配置文件替换即可。

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'springboot_system' #监控任务名称
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['localhost:8088']    #springboot端口号

启动Prometheus ,访问 ip:9090,然后按照下图操作,即可看到已经注册到Prometheus 的监控任务。

image.png

4.Grafana配置

输入ip:3000,可以进入grafana的可视化界面。

1.配置prometheus数据源 (ip:9090)

image.png

image.png

上图填写你prometheus地址,端口切记填写9090,点击save后,如果失败会有提示 。

2.导入可视化模板

然后导入上文下载好的可视化界面模板。

image.png

选择上文配置好的数据源,prometheus选项就是上文配置的数据源。

image.png

3.验证

image.png

出现以上画面 配置完成!


相关实践学习
通过可观测可视化Grafana版进行数据可视化展示与分析
使用可观测可视化Grafana版进行数据可视化展示与分析。
相关文章
|
2月前
|
存储 数据采集 Prometheus
Grafana Prometheus Altermanager 监控系统
Grafana、Prometheus 和 Alertmanager 是一套强大的开源监控系统组合。Prometheus 负责数据采集与存储,Alertmanager 处理告警通知,Grafana 提供可视化界面。本文简要介绍了这套系统的安装配置流程,包括各组件的下载、安装、服务配置及开机自启设置,并提供了访问地址和重启命令。适用于希望快速搭建高效监控平台的用户。
156 20
|
2月前
|
Prometheus 监控 Cloud Native
Prometheus+Grafana监控Linux主机
通过本文的步骤,我们成功地在 Linux 主机上使用 Prometheus 和 Grafana 进行了监控配置。具体包括安装 Prometheus 和 Node Exporter,配置 Grafana 数据源,并导入预设的仪表盘来展示监控数据。通过这种方式,可以轻松实现对 Linux 主机的系统指标监控,帮助及时发现和处理潜在问题。
202 7
|
2月前
|
Prometheus 监控 前端开发
Grafana 安装配置教程,让你的 Prometheus 监控数据变得更美观
《Grafana安装配置教程,让你的Prometheus监控数据变得更美观》简介: Grafana是一个开源的度量分析与可视化工具,支持多种数据源(如Prometheus),提供丰富的可视化功能和警报机制。本文详细介绍了Grafana的安装、汉化方法及模板使用,帮助用户轻松创建美观、灵活的数据面板,并实现数据的协作与共享。通过Docker镜像、配置文件修改或替换前端页面等方式实现汉化,让用户更便捷地使用中文界面。此外,还提供了导入JSON格式模板的具体步骤,方便快速搭建仪表盘。
96 2
|
2月前
|
Prometheus Cloud Native Linux
Prometheus+Grafana新手友好教程:从零开始搭建轻松掌握强大的警报系统
本文介绍了使用 Prometheus 和 Grafana 实现邮件报警的方案,包括三种主要方法:1) 使用 Prometheus 的 Alertmanager 组件;2) 使用 Grafana 的内置告警通知功能;3) 使用第三方告警组件如 OneAlert。同时,详细描述了环境准备、Grafana 安装配置及预警设置的步骤,确保用户能够成功搭建并测试邮件报警功能。通过这些配置,用户可以在系统或应用出现异常时及时收到邮件通知,保障系统的稳定运行。
168 1
|
3月前
|
Prometheus 运维 监控
智能运维实战:Prometheus与Grafana的监控与告警体系
【10月更文挑战第26天】Prometheus与Grafana是智能运维中的强大组合,前者是开源的系统监控和警报工具,后者是数据可视化平台。Prometheus具备时间序列数据库、多维数据模型、PromQL查询语言等特性,而Grafana支持多数据源、丰富的可视化选项和告警功能。两者结合可实现实时监控、灵活告警和高度定制化的仪表板,广泛应用于服务器、应用和数据库的监控。
426 3
|
6月前
|
Prometheus 监控 Cloud Native
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
【监控】prometheus传统环境监控告警常用配置
|
2月前
|
Prometheus 运维 监控
Prometheus+Grafana+NodeExporter:构建出色的Linux监控解决方案,让你的运维更轻松
本文介绍如何使用 Prometheus + Grafana + Node Exporter 搭建 Linux 主机监控系统。Prometheus 负责收集和存储指标数据,Grafana 用于可视化展示,Node Exporter 则采集主机的性能数据。通过 Docker 容器化部署,简化安装配置过程。完成安装后,配置 Prometheus 抓取节点数据,并在 Grafana 中添加数据源及导入仪表盘模板,实现对 Linux 主机的全面监控。整个过程简单易行,帮助运维人员轻松掌握系统状态。
289 3
|
2月前
|
Prometheus 监控 Cloud Native
无痛入门Prometheus:一个强大的开源监控和告警系统,如何快速安装和使用?
Prometheus 是一个完全开源的系统监控和告警工具包,受 Google 内部 BorgMon 系统启发,自2012年由前 Google 工程师在 SoundCloud 开发以来,已被众多公司采用。它拥有活跃的开发者和用户社区,现为独立开源项目,并于2016年加入云原生计算基金会(CNCF)。Prometheus 的主要特点包括多维数据模型、灵活的查询语言 PromQL、不依赖分布式存储、通过 HTTP 拉取时间序列数据等。其架构简单且功能强大,支持多种图形和仪表盘展示模式。安装和使用 Prometheus 非常简便,可以通过 Docker 快速部署,并与 Grafana 等可
444 2
|
3月前
|
存储 Prometheus 监控
监控堆外第三方监控工具Prometheus
监控堆外第三方监控工具Prometheus
78 3
|
3月前
|
存储 Prometheus 运维
在云原生环境中,阿里云ARMS与Prometheus的集成提供了强大的应用实时监控解决方案
在云原生环境中,阿里云ARMS与Prometheus的集成提供了强大的应用实时监控解决方案。该集成结合了ARMS的基础设施监控能力和Prometheus的灵活配置及社区支持,实现了全面、精准的系统状态、性能和错误监控,提升了应用的稳定性和管理效率。通过统一的数据视图和高级查询功能,帮助企业有效应对云原生挑战,促进业务的持续发展。
95 3