美文网首页监控从容器到kubernetes
3分钟在linux服务器搭建一套prometheus+grafa

3分钟在linux服务器搭建一套prometheus+grafa

作者: 大鹏一怒乘风起 | 来源:发表于2021-03-29 14:37 被阅读0次

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

相关文章

网友评论

    本文标题:3分钟在linux服务器搭建一套prometheus+grafa

    本文链接:https://www.haomeiwen.com/subject/xzdbhltx.html