02 单个变量的预分析

[2021.7]猿人学 | 爬虫攻防大赛 | 第一题

  返回  

grafana部署监控tomcat

2021/7/20 15:07:43 浏览:

grafana,prometheus的安装见上一篇博客

1.下载tomcat

wget https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-10/v10.0.8/bin/apache-tomcat-10.0.8.tar.gz

2.解压tomcat到/opt/aspire/product/并把文件夹重命名为tomcat

tar zxvf apache-tomcat-10.0.8.tar.gz -C /opt/aspire/product/

mv apache-tomcat-10.0.8 tomcat

3.创建config.yaml文件,内容如下

cd /opt/aspire/product/tomcat/bin

vim config.yaml

---
lowercaseOutputLabelNames: true
lowercaseOutputName: true
whitelistObjectNames: ["java.lang:type=OperatingSystem"]
blacklistObjectNames: []
rules:
  - pattern: 'java.lang<type=OperatingSystem><>(committed_virtual_memory|free_physical_memory|free_swap_space|total_physical_memory|total_swap_space)_size:'
    name: os_$1_bytes
    type: GAUGE
    attrNameSnakeCase: true
  - pattern: 'java.lang<type=OperatingSystem><>((?!process_cpu_time)\w+):'
    name: os_$1
    type: GAUGE
    attrNameSnakeCase: true

4.启动tomcat

cd /opt/aspire/product/tomcat/bin

./startup.sh

5.下载jmx_prometheus_javaagent,并将文件移动到/opt/aspire/product/tomcat/bin/

wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.14.0/jmx_prometheus_javaagent-0.14.0.jar

mv jmx_prometheus_javaagent-0.14.0.jar /opt/aspire/product/tomcat/bin/

6.修改bin目录下的catalina.sh文件,并重启tomcat

cd /opt/aspire/product/tomcat/bin/

vim catalina.sh

注释264行代码,并追加JAVA_OPTS="-javaagent:/opt/aspire/product/tomcat/bin/jmx_prometheus_javaagent-0.14.0.jar=30018:/opt/aspire/product/tomcat/bin/config.yaml"

 7.检查tomcat_exporter是否成功,有返回数据说明成功

curl -v http://localhost:30018

8.修改prometheus配置文件,把地址'localhost:30018'追加进去

cd /opt/aspire/product/prometheus

vim prometheus.yml

 9.重启prometheus

pkill prometheus

nohup ./prometheus &

 10.下载tomcat对应的grafana模板

地址:https://grafana.com/api/dashboards/8563/revisions/17/download

11.将json文件导入到grafana,下面步骤见截图

 

 

 

 

 

 

 

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号