加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Prometheus+Grafana实现主机和JVM监控

(2020-05-22 11:54:59)
标签:

prometheus

grafana

分类: 文档

1.安装Prometheus并运行
wget https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.darwin-amd64.tar.gz
tar -zxvf prometheus-2.18.1.darwin-amd64.tar.gz
cd prometheus-2.18.1.darwin-amd64
./prometheus

2.在监控节点安装node_exporter并运行
https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.1/node_exporter-1.0.0-rc.1.darwin-amd64.tar.gz
tar -zxvf node_exporter-1.0.0-rc.1.darwin-amd64.tar.gz
cd node_exporter-1.0.0-rc.1.darwin-amd64
./node_exporter

3.在监控节点安装jvm_exporter并运行
这里没有使用Prometheus提供的jvm_exporter,使用的是jmxagent
wget https://github.com/robert-guangzhou/jmxagent/blob/master/target/localjmx_prometheus_httpserver-0.10.0-jar-with-dependencies.jar

编辑jmx.yml
rules:
  - pattern: '.*'

运行
java -cp $JAVA_HOME/lib/tools.jar:./localjmx_prometheus_httpserver-0.10.0-jar-with-dependencies.jar io.prometheus.jmx.StartJmxLocal 0.0.0.0:8099 ./jmx.yml

4.修改Promethes.yml
scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: 'prometheus'
 
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
    - targets: ['192.168.136.169:9090']    
 
  - job_name: 'node'
    static_configs:
    - targets: ['192.168.136.109:9100','192.168.136.172:9100','192.168.136.175:9100','192.168.136.173:9100']
 
  - job_name: 'jmx'
    static_configs:
    - targets: ['192.168.136.109:8099','192.168.136.172:8099','192.168.136.175:8099','192.168.136.173:8099']

5.安装Grafana并运行
wget https://dl.grafana.com/oss/release/grafana-7.0.0.darwin-amd64.tar.gz
tar -zxvf grafana-7.0.0.darwin-amd64.tar.gz
cd grafana-7.0.0/bin
./grafana-server

6.在Grafana配置Prometheus 数据源

7.在Dashboards里导入一个仪表盘(从官网查询到喜欢的copy Id)

我导入的是
node_exporter 8919
jmx 3457

完工,接下来就可以欣赏狂拽酷炫的界面了。

0

阅读 收藏 喜欢 打印举报/Report
后一篇:巽寮湾
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有