使用Prometheus、Grafana监控Artifactory实践

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


这篇文章描述如何通过prometheus、grafana实现对Artifactory的基础系统及应用JVM监控。

[if !supportLists]一、 [endif]Prometheus Server端部署

[if !supportLists]· [endif]下载安装包并解压(以版本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


[if !supportLists]· [endif]添加为系统服务

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


[if !supportLists]· [endif]启动并加入开机自启

systemctl start prometheus-server

systemctl enable prometheus-server


[if !supportLists]· [endif]访问

http://ip:9090


[if !supportLists]二、 [endif]Prometheus Node端部署

[if !supportLists]· [endif]下载安装包并解压(以版本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


[if !supportLists]· [endif]添加为系统服务

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


[if !supportLists]· [endif]启动并加入开机自启

systemctl start prometheus-node

systemctl enable prometheus-node


[if !supportLists]三、 [endif]Grafana部署

[if !supportLists]· [endif]下载安装包并安装(以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

 

[if !supportLists]· [endif]启动

systemctl start/stop/restart/enable grafana-server

 

[if !supportLists]· [endif]访问

http://IP:3000

默认用户名/密码:admin/admin

 

[if !supportLists]四、 [endif]配置Artifactory节点系统监控

[if !supportLists]· [endif]配置prometheus

在Artifactory各个节点安装好Prometheus Node后,修改/opt/monitor/prometheus-2.11.1/prometheus.yml,添加:

- job_name: 'artifactory'

      static_configs:

            - targets: ['IP1:9100','IP2:9100']


[if !supportLists]· [endif]重启prometheus-server

systemctl restart prometheus-server

 

[if !supportLists]· [endif]查看监控状态及数据查询示例


 

[if !supportLists]· [endif]使用grafana展示,模板可参考

https://grafana.com/dashboards/1860

 

[if !supportLists]· [endif]监控状态如下图

[if !supportLists]五、 [endif]配置Artifactory节点JVM监控

[if !supportLists]· [endif]下载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

[if !supportLists]· [endif]添加配置文件

vim /opt/monitor/prometheus/jmx_config.yaml

---

lowercaseOutputLabelNames: true

lowercaseOutputName: true


rules:

- pattern: ".*"


[if !supportLists]· [endif]修改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"


[if !supportLists]· [endif]重启Artifactory

systemctl restart artifactory

 

[if !supportLists]· [endif]修改prometheus配置

修改/opt/monitor/prometheus/prometheus-2.11.1/prometheus.yml,添加:

- job_name: 'Artifactory-jmx'

      static_configs:

            - targets: ['IP1:30013','IP2:30013']


[if !supportLists]· [endif]重启Prometheus Server

 

[if !supportLists]· [endif]在Grafana上展示监控信息

可参考模板:https://grafana.com/dashboards/8563


[if !supportLists]· [endif]根据实际情况自定义修改模板配置

如:点击dashbord设置,修改$job的value为Artifactory-jmx



[if !supportLists]· [endif]Artifactory-JMX监控展示


 

你可能感兴趣的:(使用Prometheus、Grafana监控Artifactory实践)