SpringBoot 2.X 使用Actuator監(jiān)控

1.添加POM依賴
<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
二.添加配置文件
server:
  port: 8080
  servlet:
    context-path: /demo
# actuator 監(jiān)控配置
management:
  #actuator端口 如果不配置做默認使用上面8080端口
  server:
    port: 9090
  endpoints:
    web:
      exposure:
        #默認值訪問health,info端點  用*可以包含全部端點
        include: "*"
      #修改訪問路徑 2.0之前默認是/; 2.0默認是/actuator可以通過這個屬性值修改
      base-path: /actuator

配置完成啟動項目后就可以通過postman或者直接在預覽器輸入路徑等方式來查看應用的運行狀態(tài)了。
當項目啟動時,訪問http://127.0.0.1:9090/actuator地址

注意:如果沒有配置 actuator端口,采用默認訪問地址:http://127.0.0.1:8080/demo/actuator

如果看到類似下面的內(nèi)容透典,說明actuator已經(jīng)生效了

{
    "_links": {
        "self": {
            "href": "http://127.0.0.1:9090/actuator",
            "templated": false
        },
        "auditevents": {
            "href": "http://127.0.0.1:9090/actuator/auditevents",
            "templated": false
        },
        "beans": {
            "href": "http://127.0.0.1:9090/actuator/beans",
            "templated": false
        },
        "caches-cache": {
            "href": "http://127.0.0.1:9090/actuator/caches/{cache}",
            "templated": true
        },
        "caches": {
            "href": "http://127.0.0.1:9090/actuator/caches",
            "templated": false
        },
        "health": {
            "href": "http://127.0.0.1:9090/actuator/health",
            "templated": false
        },
        "health-component": {
            "href": "http://127.0.0.1:9090/actuator/health/{component}",
            "templated": true
        },
        "health-component-instance": {
            "href": "http://127.0.0.1:9090/actuator/health/{component}/{instance}",
            "templated": true
        },
        "conditions": {
            "href": "http://127.0.0.1:9090/actuator/conditions",
            "templated": false
        },
        "configprops": {
            "href": "http://127.0.0.1:9090/actuator/configprops",
            "templated": false
        },
        "env": {
            "href": "http://127.0.0.1:9090/actuator/env",
            "templated": false
        },
        "env-toMatch": {
            "href": "http://127.0.0.1:9090/actuator/env/{toMatch}",
            "templated": true
        },
        "info": {
            "href": "http://127.0.0.1:9090/actuator/info",
            "templated": false
        },
        "loggers": {
            "href": "http://127.0.0.1:9090/actuator/loggers",
            "templated": false
        },
        "loggers-name": {
            "href": "http://127.0.0.1:9090/actuator/loggers/{name}",
            "templated": true
        },
        "heapdump": {
            "href": "http://127.0.0.1:9090/actuator/heapdump",
            "templated": false
        },
        "threaddump": {
            "href": "http://127.0.0.1:9090/actuator/threaddump",
            "templated": false
        },
        "metrics-requiredMetricName": {
            "href": "http://127.0.0.1:9090/actuator/metrics/{requiredMetricName}",
            "templated": true
        },
        "metrics": {
            "href": "http://127.0.0.1:9090/actuator/metrics",
            "templated": false
        },
        "scheduledtasks": {
            "href": "http://127.0.0.1:9090/actuator/scheduledtasks",
            "templated": false
        },
        "httptrace": {
            "href": "http://127.0.0.1:9090/actuator/httptrace",
            "templated": false
        },
        "mappings": {
            "href": "http://127.0.0.1:9090/actuator/mappings",
            "templated": false
        }
    }
}

端點地址官網(wǎng)地址: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

springboot 2 配置屬性地址:https://docs.spring.io/spring-boot/docs/2.1.3.RELEASE/reference/html/common-application-properties.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子苫拍,更是在濱河造成了極大的恐慌,老刑警劉巖攒霹,帶你破解...
    沈念sama閱讀 216,744評論 6 502
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件怯疤,死亡現(xiàn)場離奇詭異,居然都是意外死亡催束,警方通過查閱死者的電腦和手機集峦,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,505評論 3 392
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來抠刺,“玉大人塔淤,你說我怎么就攤上這事∷傺” “怎么了高蜂?”我有些...
    開封第一講書人閱讀 163,105評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長罕容。 經(jīng)常有香客問我备恤,道長,這世上最難降的妖魔是什么锦秒? 我笑而不...
    開封第一講書人閱讀 58,242評論 1 292
  • 正文 為了忘掉前任露泊,我火速辦了婚禮,結(jié)果婚禮上旅择,老公的妹妹穿的比我還像新娘惭笑。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 67,269評論 6 389
  • 文/花漫 我一把揭開白布沉噩。 她就那樣靜靜地躺著捺宗,像睡著了一般。 火紅的嫁衣襯著肌膚如雪川蒙。 梳的紋絲不亂的頭發(fā)上蚜厉,一...
    開封第一講書人閱讀 51,215評論 1 299
  • 那天,我揣著相機與錄音派歌,去河邊找鬼弯囊。 笑死,一個胖子當著我的面吹牛胶果,可吹牛的內(nèi)容都是我干的匾嘱。 我是一名探鬼主播,決...
    沈念sama閱讀 40,096評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼早抠,長吁一口氣:“原來是場噩夢啊……” “哼霎烙!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起蕊连,我...
    開封第一講書人閱讀 38,939評論 0 274
  • 序言:老撾萬榮一對情侶失蹤悬垃,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后甘苍,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體尝蠕,經(jīng)...
    沈念sama閱讀 45,354評論 1 311
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,573評論 2 333
  • 正文 我和宋清朗相戀三年载庭,在試婚紗的時候發(fā)現(xiàn)自己被綠了看彼。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,745評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡囚聚,死狀恐怖靖榕,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情顽铸,我是刑警寧澤茁计,帶...
    沈念sama閱讀 35,448評論 5 344
  • 正文 年R本政府宣布,位于F島的核電站谓松,受9級特大地震影響星压,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜鬼譬,卻給世界環(huán)境...
    茶點故事閱讀 41,048評論 3 327
  • 文/蒙蒙 一娜膘、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧拧簸,春花似錦劲绪、人聲如沸男窟。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,683評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至牺六,卻和暖如春颤枪,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背淑际。 一陣腳步聲響...
    開封第一講書人閱讀 32,838評論 1 269
  • 我被黑心中介騙來泰國打工畏纲, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人春缕。 一個月前我還...
    沈念sama閱讀 47,776評論 2 369
  • 正文 我出身青樓盗胀,卻偏偏與公主長得像,于是被迫代替她去往敵國和親锄贼。 傳聞我的和親對象是個殘疾皇子票灰,可洞房花燭夜當晚...
    茶點故事閱讀 44,652評論 2 354

推薦閱讀更多精彩內(nèi)容