美文网首页
服务监控

服务监控

作者: 一腔诗意换酒钱 | 来源:发表于2020-03-09 17:17 被阅读0次

微服务项目由于服务数量较多,所以相对于单体项目而言出错的可能性较大,因此为了运维工作更加方便,需要对各个服务进行监控。早期Spring Cloud中服务监控主语是由Hystrix Dashboard,集群数据库监控使用Turbine

Micrometer是Spring Cloud Greenwich版本后官方推荐使用的监控工具,Micrometer的作用有:

1.提供了度量指标,例如timers、counters

2.提供了一系列开箱即用的解决方案:如缓存、类加载器、垃圾收集等

使用

新建Spring Boot模块micrometer,添加Actuator依赖。项目创建成功后在application.properties中添加配置,开启所有监控端点,就可以在浏览器中查看各个项目的运行数据,但这些数据都是Json格式

image

因此还需要添加可视化管理界面,这里使用Prometheus。

官网下载Prometheus

下载二进制包:prometheus-2.6.1.linux-amd64.tar.gz

在Linux子系统中解压缩:tar xvzf prometheus-2.6.1.linux-amd64.tar.gz

解压后进入到安装目录中cd prometheus-2.6.1.linux-amd64

输入vi prometheus.yml在vim中对prometheus配置文件作如下修改

image

保存并退出vim。

在spring boot项目中添加prometheus的依赖

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

并在配置文件中开启prometheus

management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoints.metrics.enable=true

配置完成后,在linux子系统中启动prometheus./prometheus --config.file=promet

启动micrometer模块,访问localhost:9090即可进入prometheus的界面


image

相关文章

网友评论

      本文标题:服务监控

      本文链接:https://www.haomeiwen.com/subject/eknpdhtx.html