3分钟在linux服务器搭建一套prometheus+grafana监控

1.服务器node执行,被监控端
docker run -d --name node-exporter --restart=always --net="host" --pid="host" -v "/:/host:ro,rslave" prom/node-exporter --path.rootfs=/host

docker run -v /:/rootfs:ro -v /var/run:/var/run:rw -v /sys:/sys:ro -v /var/lib/docker/:/var/lib/docker:ro -p 28080:8080 --detach=true --privileged=true --name=cadvisor --restart=always google/cadvisor:latest
2.直接再现有prometheus上配置
或者在服务器执行下面命令搭建一个
docker run -d -p 9090:9090 --restart=always --name=prometheus -v /data/prom/prometheus/config:/etc/prometheus prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.enable-lifecycle
配置主机
global:
scrape_interval: 35s
evaluation_interval: 35s

alerting:
alertmanagers:

  • static_configs:
    • targets:
      • alert.devops-test.mingyuanyun.com

rule_files:

  • "first_rules.yml"

- "second_rules.yml"

scrape_configs:

  • job_name: 'prometheus'
    static_configs:

    • targets: ['localhost:9090']
  • job_name: 测试环境win
    honor_timestamps: true
    scrape_interval: 50s
    scrape_timeout: 40s
    metrics_path: /metrics
    scheme: http
    static_configs:

    • targets:
      • xxxx:9182
  • job_name: 测试环境linux
    honor_timestamps: true
    scrape_interval: 50s
    scrape_timeout: 40s
    metrics_path: /metrics
    scheme: http
    static_configs:

    • targets:
      • 10.5.11.xxx:9100
  • job_name: 测试环境容器
    honor_timestamps: true
    scrape_interval: 50s
    scrape_timeout: 40s
    metrics_path: /metrics
    scheme: http
    static_configs:

    • targets:
      • 10.5.11.xxx:28080

搭建一个模板
docker run -d --restart=always -p 3001:3000 --name grafana grafana/grafana
导入 8919

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容