日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

Promethues 監(jiān)控Tomcat 主要用的模塊

  • Promethus 負(fù)載抓取/存儲(chǔ)指標(biāo)信息、并提供查詢功能
  • grafana 數(shù)據(jù)可視化
  • JMX exporter 提供JMX中JVM相關(guān)的metrics

1、利用JMX exporter,在JAVA進(jìn)程內(nèi)啟動(dòng)一個(gè)小型的Http server

2、配置Prometheus抓取那個(gè)Http server提供的metrics。

3、配置Grafana連接Prometheus,配置Dashboard。

一、下載一個(gè)tomcat,下載jmx_exporter

  • 1、獲取jmx_exporter有2種方法,自己編譯獲取jar包,獲取現(xiàn)成的jar包
wget  https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.12.0/jmx_prometheus_javaagent-0.12.0.jar

或者編譯
git clone https://github.com/prometheus/jmx_exporter
cd jmx_exporter
mvn package
  • 2、安裝tomcat
wget http://mirrors.tuna.tsinghua.edu.cn/Apache/tomcat/tomcat-8/v8.5.51/bin/apache-tomcat-8.5.51.tar.gz
tar zxvf apache-tomcat-8.5.51.tar.gz
mv apache-tomcat-8.5.51 /usr/localt/tomcat_test
  • 3、配置文件下載
wget https://github.com/prometheus/jmxexporter/blob/master/exampleconfigs/tomcat.yml

tomcat.yml的內(nèi)容如下

---   
lowercaseoutputLabelNames: true
lowercaseOutputName: true
rules:
- pattern: 'Catalina<type=GlobalRequestProcessor, name="(w+-w+)-(d+)"><>(w+):'
  name: tomcat_$3_total
  labels:
    port: "$2"
    protocol: "$1"
  help: Tomcat global $3
  type: COUNTER
- pattern: 'Catalina<j2eeType=Servlet, WebModule=//([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]), name=([-a-zA-Z0-9+/$%~_-|!.]*), J2EEApplication=none, J2EEServer=none><>(requestCount|maxTime|processingTime|errorCount):'
  name: tomcat_servlet_$3_total
  labels:
    module: "$1"
    servlet: "$2"
  help: Tomcat servlet $3 total
  type: COUNTER
- pattern: 'Catalina<type=ThreadPool, name="(w+-w+)-(d+)"><>(currentThreadCount|currentThreadsBusy|keepAliveCount|pollerThreadCount|connectionCount):'
  name: tomcat_threadpool_$3
  labels:
    port: "$2"
    protocol: "$1"
  help: Tomcat threadpool $3
  type: GAUGE
- pattern: 'Catalina<type=Manager, host=([-a-zA-Z0-9+&@#/%?=~_|!:.,;]*[-a-zA-Z0-9+&@#/%=~_|]), context=([-a-zA-Z0-9+/$%~_-|!.]*)><>(processingTime|sessionCounter|rejectedSessions|expiredSessions):'
  name: tomcat_session_$3_total
  labels:
    context: "$2"
    host: "$1"
  help: Tomcat session $3 total
  type: COUNTER
  • 4、收集數(shù)據(jù)

4-1、Tomcat收集數(shù)據(jù)

mkdir /usr/local/tomcat_test/jmx/
cp jmx_prometheus_javaagent-0.12.0.jar  /usr/local/tomcat_test/jmx/
cp tomcat.yml  /usr/local/tomcat_test/jmx/

修改配置文件vim /usr/local/tomcat_test/bin/catalina.sh 
JAVA_OPTS="-javaagent:/usr/local/tomcat_test/jmx/jmx_prometheus_javaagent-0.12.0.jar=39081:/usr/local/tomcat_test/jmx/tomcat.yml"

4-2、JAR包運(yùn)行(案例,關(guān)鍵文件jmxprometheusjavaagent-0.3.0.jar和tomcat.yml)

java -javaagent:./jmx_prometheus_javaagent-0.3.0.jar=9151:tomcat.yaml -jar yourJar.jar
  • 5、 測(cè)試是否收集到數(shù)據(jù) curl -s http://localhost:39081/ | more
[root@Prometheus promethus]# curl -s http://localhost:39081/ | more 
# HELP jmx_exporter_build_info A metric with a constant '1' value labeled with the version of the JMX exporter.
# TYPE jmx_exporter_build_info gauge
jmx_exporter_build_info{version="0.12.0",name="jmx_prometheus_javaagent",} 1.0
# HELP jmx_config_reload_success_total Number of times configuration have successfully been reloaded.
# TYPE jmx_config_reload_success_total counter
jmx_config_reload_success_total 0.0
# HELP jmx_config_reload_failure_total Number of times configuration have failed to be reloaded.
# TYPE jmx_config_reload_failure_total counter
jmx_config_reload_failure_total 0.0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 3.99
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.582290765496E9
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 74.0
Promethues如何監(jiān)控Tomcat

 

二、配置promethus 采集數(shù)據(jù)

  • 1、文件引用 (本文采用) /usr/local/prometheus/prometheus.yml
- job_name: 'tomcat'
    file_sd_configs:
    - files: ['/usr/local/prometheus/conf/tomcat.yml']
      refresh_interval: 180s

/usr/local/prometheus/conf/tomcat.yml/tomcat.yml

- targets:
  - 114.67.116.119:39081
  labels:
    idc: test_idc
    service: tomcat_test
  • 2、直接配置
scrape_configs:
  - job_name: 'java'
    static_configs:
    - targets: ['114.67.116.119:39081']
  • 3、重載配置文件
kill -hup `ps -ef |grep prometheus|grep -v grep|awk '{print $2}'`
或者
kill -9 PID
/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
  • 4、查看promethus界面,tomcat的監(jiān)控是否發(fā)現(xiàn)
Promethues如何監(jiān)控Tomcat

 

三、grafana 數(shù)據(jù)可視化

導(dǎo)入模板 8563

Promethues如何監(jiān)控Tomcat

 


Promethues如何監(jiān)控Tomcat

 

名稱對(duì)應(yīng) promethus.yml的job名稱

Promethues如何監(jiān)控Tomcat

 

展示tomcat監(jiān)控大屏

Promethues如何監(jiān)控Tomcat

分享到:
標(biāo)簽:監(jiān)控 Tomcat
用戶無頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定