在企业的零碎平台上运行artifactory可能每天有上百万个制品在一直流转,随着研发团队不断扩大,用户缓缓增多,并发量也相应的逐步增大,在保障高可用的同时,咱们对artifactory所在零碎及应用服务进行监控会显得尤其重要。那么如何实现零碎及利用的监控呢?

这篇文章形容如何通过prometheus、grafana实现对Artifactory的根底零碎及利用JVM监控。
一、Prometheus Server端部署
下载安装包并解压(以版本2.11.1为例)
下载地址:https://prometheus.io/download/
mkdir /opt/monitor/prometheus;cd /opt/monitor/prometheus
unzip prometheus.zip ./
tar zxf prometheus-2.11.1.linux-amd64.tar.gz
mv prometheus-2.11.1.linux-amd64 prometheus-2.11.1

增加为零碎服务
vim /usr/lib/systemd/system/prometheus-server.service
[Unit]
Description=prometheus-server
After=network.target
 
[Service]
Type=simple
User=root
ExecStart=/opt/monitor/prometheus/prometheus-2.11.1/prometheus --config.file=/opt/monitor/prometheus/prometheus-2.11.1/prometheus.yml
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

启动并退出开机自启
systemctl start prometheus-server
systemctl enable prometheus-server

拜访
http://ip:9090

二、Prometheus Node端部署
下载安装包并解压(以版本0.18.1为例)
cd /opt/monitor/prometheus
unzip prometheus.zip ./
tar zxf node_exporter-0.18.1.linux-amd64.tar.gz
mv node_exporter-0.18.1.linux-amd64 node_exporter-0.18.1

增加为零碎服务
vim /usr/lib/systemd/system/prometheus-node.service
[Unit]
Description=prometheus-node
After=network.target

[Service]
Type=simple
User=root
ExecStart=/opt/monitor/prometheus/node_exporter-0.18.1/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target

启动并退出开机自启
systemctl start prometheus-node
systemctl enable prometheus-node

三、Grafana部署
下载安装包并装置(以6.2.5.1为例)
wget https://dl.grafana.com/oss/re...
yum localinstall grafana-6.2.5-1.x86_64.rpm -y

启动
systemctl start/stop/restart/enable grafana-server

拜访
http://IP:3000
默认用户名/明码:admin/admin

四、配置Artifactory节点系统监控
配置prometheus
在Artifactory各个节点装置好Prometheus Node后,批改/opt/monitor/prometheus-2.11.1/prometheus.yml,增加:

  • job_name: 'artifactory'
          static_configs:
                - targets: ['IP1:9100','IP2:9100']

重启prometheus-server
systemctl restart prometheus-server

查看监控状态及数据查问示例

应用grafana展现,模板可参考
https://grafana.com/dashboard...

监控状态如下图

五、配置Artifactory节点JVM监控
下载jmx_prometheus_javaagent-0.12.0.jar
下载地址参考:https://repo1.maven.org/maven...
Jar包门路:/opt/monitor/prometueus/jmx_prometheus_javaagent-0.12.0.jar
增加配置文件

vim /opt/monitor/prometheus/jmx_config.yaml

lowercaseOutputLabelNames: true
lowercaseOutputName: true
 
rules:

  • pattern: ".*"

批改Artifactory tomcat配置文件
vim $ARTIFACTORY_HOME/tomcat/bin/catalina.sh,增加:
JAVA_OPTS="$JAVA_OPTS -javaagent:/opt/monitor/prometheus/jmx_prometheus_javaagent-0.12.0.jar=30013:/opt/monitor/prometheus/jmx_config.yaml"

重启Artifactory
systemctl restart artifactory

批改prometheus配置
批改/opt/monitor/prometheus/prometheus-2.11.1/prometheus.yml,增加:

  • job_name: 'Artifactory-jmx'
          static_configs:
                - targets: ['IP1:30013','IP2:30013']

重启Prometheus Server

在Grafana上展现监控信息
可参考模板:https://grafana.com/dashboard...

依据理论状况自定义批改模板配置
如:点击dashbord设置,批改$job的value为Artifactory-jmx


Artifactory-JMX监控展现