Spring boot Actuator配合Jolokia,Telegraf,Influxdb,Grafana实现监控

Spring-boot-monitoring

Spring boot项目监控,作为一个示例项目,研究其可行性。使用Spring initializr生成一个可运行的简单Spring boot项目,开启Actuator和Jolokia支持,使用Telegraf采集项目运行信息,InfluxDB时序数据库存储数据,Grafana展示数据。

sample

开始

下面说明怎样运行此项目并看到效果。首先克隆此项目:

git clone https://github.com/dachengxi/spring-boot-monitoring.git

准备

需要安装的列表

  • influxdb
  • telegraf
  • grafana

安装

以上软件的安装步骤自行参考官方文档,这里不做重复。

配置

telegraf:

vi /etc/telegraf/telegraf.conf

打开或者添加以下配置

[[inputs.jolokia]]
	context = "/actuator/jolokia/read/"

[[inputs.jolokia.servers]]
     name = "spring-boot-monitoring"
     host = "127.0.0.1"
     port = "8080"

[[inputs.jolokia.metrics]]
     name = "heap_memory_usage"
     mbean  = "java.lang:type=Memory"
     attribute = "HeapMemoryUsage"

[[inputs.jolokia.metrics]]
     name = "thread_count"
     mbean  = "java.lang:type=Threading"
     attribute = "TotalStartedThreadCount,ThreadCount,DaemonThreadCount,PeakThreadCount"

[[inputs.jolokia.metrics]]
     name = "class_count"
     mbean  = "java.lang:type=ClassLoading"
     attribute = "LoadedClassCount,UnloadedClassCount,TotalLoadedClassCount"

[[inputs.jolokia.metrics]]
    name = "metrics"
    mbean  = "org.springframework.boot:name=metricsEndpoint,type=Endpoint"
    attribute = "Data"

[[inputs.jolokia.metrics]]
    name = "tomcat_max_threads"
    mbean  = "Tomcat:name=\"http-nio-8080\",type=ThreadPool"
    attribute = "maxThreads"

[[inputs.jolokia.metrics]]
    name = "tomcat_current_threads_busy"
    mbean  = "Tomcat:name=\"http-nio-8080\",type=ThreadPool"
    attribute = "currentThreadsBusy"

grafana:

运行grafana,访问http://localhost:3000 ,选择导入Dashboard,导入的文件是项目中的grafana/Spring Boot监控.json文件

运行

将Spring Boot项目导入到IDEA中,运行项目!

构建

贡献

暂无

作者

License

This project is licensed under the MIT License!

转载于:https://my.oschina.net/dachengxi/blog/1590075

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值