微服务监控调研

前言

微服务概念已经非常流行,这影响了现在架构的思想潮流。
如今,使用spring cloud体系搭建微服务架构的公司越来越多,成本低,出线上产品快,模块全,开源等原因未来可能更加流行。
一般,我们需要一个监控系统来监控应用的数据,比如内存,磁盘,线程情况,数据库连接池,配置信息,jvm信息等等。

方案

spring cloud admin

github地址:https://github.com/codecentric/spring-boot-admin

如果本身是java技术栈,搭建非常快,新建监控server项目,在spring boot搭建的client项目上配置以下即可,具体直接看文档。

InfluxDB 组合方案1

我们可以通过 Jolokia + Telegraf + InfluxDB + Grafana 方案
Jolokia: Spring Boot 认可使用Jolokia来通过HTTP导出export JMX数据。你只需要在工程类路径中增加一些依赖项,一切都是开箱即用的。不需要任何额外的实现。
https://jolokia.org/reference/html/index.html

Telegraf: Telegraf支持通过整合Jolokia来集成JMX数据的收集。它有一个预制的输入插件,它是开箱即用的。不需要任何额外的实现。只需要做一些配置即可。

InfluxDB: InfluxDB通过 输出插件从Telegraf接收指标数据,它是开箱即用的,不需要任何额外的实现。

Grafana: Grafana通过连接InfluxDB作为数据源来渲染图标。它是开箱即用的,不需要额外的实现。

我们也可以使用InfluxDB官方的方案:

1, Spring boot 配置:

endpoints.jolokia.enabled=true
management.security.enabled=false
management.port=8088
management.context-path=/monitor

pom配置:

<dependency>
   <groupId>org.jolokia</groupId>
   <artifactId>jolokia-core</artifactId>
</dependency>

2,telegraf --config telegraf.conf
配置telegraf.conf
3,./influxd
启动influxdb
4,./chronograf
启动chronograf

Prometheus

Prometheus 也是用go开发的方案。

启动prometheus

./prometheus --config.file=prometheus.yml

prometheus.yml配置:

global:
  scrape_interval:     15s
  evaluation_interval: 15s

rule_files:
  # - "first.rules"
  # - "second.rules"

scrape_configs:
#  - job_name: prometheus
#    static_configs:
#      - targets: ['localhost:9090']
  - job_name: spring-boot
    scrape_interval: 5s
    scrape_timeout: 5s
    metrics_path: /monitor/prometheus
    scheme: http
    static_configs:
      - targets:
        - 127.0.0.1:8088  #此处填写 Spring Boot 应用的 IP + 端口号

应用启动代码:

@SpringBootApplication
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
public class Application {
    public static void main(String[] args) {
        SpringApplication app = new SpringApplicationBuilder(Application.class).web(true).application();
        app.run(args);
    }
}

pom依赖:

<dependency>
   <groupId>io.prometheus</groupId>
   <artifactId>simpleclient_spring_boot</artifactId>
   <version>0.4.0</version>
</dependency>

posted on   每当变幻时  阅读(1082)  评论(0编辑  收藏  举报

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示