在企业的系统平台上运行artifactory可能每天有上百万个制品在不断流转,随着研发团队不断扩大,用户慢慢增多,并发量也相应的逐渐增大,在保证高可用的同时,我们对artifactory所在系统及应用服务进行监控会显得尤其重要。那么如何实现系统及应用的监控呢?
这篇文章描述如何通过prometheus、grafana实现对Artifactory的基础系统及应用JVM监控。
一、 Prometheus Server端部署
· 下载安装包并解压(以版本2.11.1为例)
下载地址:https://prometheus.io/download/
mkdir /opt/monitor/prometheus;cd /opt/monitor/prometheusunzip prometheus.zip ./tar zxf prometheus-2.11.1.linux-amd64.tar.gzmv prometheus-2.11.1.linux-amd64 prometheus-2.11.1 |
---|
· 添加为系统服务
vim /usr/lib/systemd/system/prometheus-server.service
[Unit]Description=prometheus-serverAfter=network.target [Service]Type=simpleUser=rootExecStart=/opt/monitor/prometheus/prometheus-2.11.1/prometheus --config.file=/opt/monitor/prometheus/prometheus-2.11.1/prometheus.ymlRestart=on-failure [Install]WantedBy=multi-user.target |
---|
· 启动并加入开机自启
systemctl start prometheus-serversystemctl enable prometheus-server |
---|
· 访问
http://ip:9090
二、 Prometheus Node端部署
· 下载安装包并解压(以版本0.18.1为例)
cd /opt/monitor/prometheusunzip prometheus.zip ./tar zxf node_exporter-0.18.1.linux-amd64.tar.gzmv node_exporter-0.18.1.linux-amd64 node_exporter-0.18.1 |
---|
· 添加为系统服务
vim /usr/lib/systemd/system/prometheus-node.service
[Unit]Description=prometheus-nodeAfter=network.target [Service]Type=simpleUser=rootExecStart=/opt/monitor/prometheus/node_exporter-0.18.1/node_exporterRestart=on-failure [Install]WantedBy=multi-user.target |
---|
· 启动并加入开机自启
systemctl start prometheus-nodesystemctl enable prometheus-node |
---|
三、 Grafana部署
· 下载安装包并安装(以6.2.5.1为例)
wget https://dl.grafana.com/oss/release/grafana-6.2.5-1.x86_64.rpm 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/dashboards/1860
· 监控状态如下图
五、 配置Artifactory节点JVM监控
· 下载jmx_prometheus_javaagent-0.12.0.jar
下载地址参考:https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.12.0/jmx_prometheus_javaagent-0.12.0.jar
Jar包路径:/opt/monitor/prometueus/jmx_prometheus_javaagent-0.12.0.jar
· 添加配置文件
vim /opt/monitor/prometheus/jmx_config.yaml
---lowercaseOutputLabelNames: truelowercaseOutputName: 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/dashboards/8563
· 根据实际情况自定义修改模板配置
如:点击dashbord设置,修改$job的value为Artifactory-jmx
· Artifactory-JMX监控展示