SpringBoot+actuator+prometheus+Consul+grafana監控系列(一)

由於單位項目,部分業務以及服務器需要做到實時監控,便找了行業較爲前沿流行的技術進行摸索,經過部署實踐,做以總結,將小小心得分享,也便於日後查看;
本文采取一鍵安裝,一鍵卸載,文中腳本可以直接使用,搭建環境如下:
Linux 麒麟OS + 紅蓮花瀏覽器 + 神通數據庫

sringboot項目搭建(略)

添加actuator,prometheus依賴

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>

編寫application文件

#應用端口
server.port=8081
#監控端口
management.server.port=8100
#設置上下文路徑
server.servlet.context-path=/monitor
management.server.servlet.context-path=${server.servlet.context-path}
#監控所包含的內容
management.endpoints.web.exposure.include=prometheus,info,health
#顯示詳情
management.endpoint.health.show-details=always
#應用名
spring.application.name=monitor

配置參考: https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/html/production-ready-endpoints.html

測試actuator,peoemtheus 顯示

# 健康檢查
http://localhost:8100/monitor/actuator
http://localhost:8100/monitor/actuator/health
#以prometheus 指標方式顯示數據
http://localhost:8100/monitor/actuator/prometheus

當出現類似以下信息,就說明actuator,prometheus配置好了. 第一步也就完成了.
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章