Prometheus系统监控-部署笔记

Prometheus系统监控-部署笔记


Prometheus
prometheus可以实现服务器监控
下载
https://prometheus.io/download/
解压

tar xvfz prometheus-*.tar.gz

下载exporter
exporter相当于插件,比如要监控java相关的服务需要jmx-exporter
jmx-exporter
https://github.com/prometheus/jmx_exporter
对于需要监控的服务,启动时增加命令
指定一个javaagent,对应的启动端口,配置文件

-javaagent:/root/jmx_prometheus_javaagent-0.3.1.jar=9001:/root/java.yml

例子

nohup java -javaagent:/root/jmx_prometheus_javaagent-0.3.1.jar=9001:/root/java.yml -jar hrss-cz-nk-monitor-app.jar --server.port=8090 >app.log 2>&1 &

nohup ./startWebLogic.sh -javaagent:/tar/jmx_prometheus_javaagent-0.3.1.jar=9903:/tar/weblogic_config.yml >>log.out 2>&1 &

weblogic_config.yml


username: weblogic 
password: weblogic123 
lowercaseOutputName: false 
lowercaseOutputLabelNames: false 
whitelistObjectNames: 
  - "com.bea:ServerRuntime=*,Type=ApplicationRuntime,*" 
  - "com.bea:Type=WebAppComponentRuntime,*" 
  - "com.bea:Type=ServletRuntime,*" 
 
rules: 
  - pattern: "^com.bea<ServerRuntime=.+, Name=(.+), ApplicationRuntime=(.+), Type=ServletRuntime, WebAppComponentRuntime=(.+)><>(.+): (.+)" 
    attrNameSnakeCase: true 
    name: weblogic_servlet_ 
    value:  
    labels: 
      name:  
      app:  
      servletName:  
 
  - pattern: "^com.bea<ServerRuntime=(.+), Name=(.+), ApplicationRuntime=(.+), Type=WebAppComponentRuntime><>(.+): (.+)$" 
    attrNameSnakeCase: true 
    name: webapp_config_ 
    value:  
    labels: 
      app:  
      name: 

在prometheus中配置任务job

   - job_name: 'jmx-expoter'

    static_configs:
    - targets: ['localhost:9001']

启动服务

nohup ./prometheus --config.file=prometheus.yml > prometheus.log 2>&1 &

访问9090端口
http://www.jsong.wiki:9090

查看prometheus的target ,包含所有任务
http://www.jsong.wiki:9090/targets

监控图形界面可以结合grafana使用,更加好看
grafana是一个开源的可视化工具,可以自己开发插件,文档很全,可以选择很多数据源,包括prometheus
grafana下载

安装

sudo yum localinstall grafana-5.4.0-1.x86_64.rpm

sudo rpm -Uvh grafana-5.4.0-1.x86_64.rpm

启服务

sudo /bin/systemctl start grafana-server.service

停服务

sudo /bin/systemctl stop grafana-server.service

发布了83 篇原创文章 · 获赞 21 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/JsongNeu/article/details/99705384