美文网首页
Docker 部署 Prometheus(普罗米修斯)

Docker 部署 Prometheus(普罗米修斯)

作者: tzktzk1 | 来源:发表于2023-11-23 01:08 被阅读0次
使用Prometheus和Grafana对Linux服务器进行监控

监控Linux服务器,只需要一个exporter
node_exporter – 用于机器系统数据收集,包括cpu,内存,磁盘,io等基本信息

安装 node-exporter:

启动后会在服务器上启动一个进程采集数据 ,prometheus 会每隔几秒通过接口获取服务器的 metrics 数据

docker pull prom/node-exporter

启动 node-exporter(安装linux指标采集器):

docker run -d --name node-exporter -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" --net="host" prom/node-exporter:latest

访问url,收集数据:

http://服务器ip:9100/metrics

安装 Prometheus(普罗米修斯):

docker pull prom/prometheus

配置 prometheus.yml:
新建目录prometheus,编辑配置文件prometheus.yml
mkdir /home/prometheus
cd /home/prometheus/
vim prometheus.yml

global:
  scrape_interval: 60s
  evaluation_interval: 60s
scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
  - job_name: linux
    static_configs:
      - targets: ['192.168.8.109:9100']
        labels:
          instance: localhost

注意:192.168.8.109:9100 是 服务器ip:9100
启动 Prometheus(普罗米修斯):

docker run -d --name prometheus -p 9090:9090 -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest

访问url:

http://192.168.8.109:9090/graph

访问targets:

http://192.168.8.109:9090/targets

Prometheus+Grafana生成监控信息:
1.grafana数据源选择prometheus
2.配置数据源信息
    Name:prometheus 
    URL:http://192.168.8.109:9090
    Access:Server(default)
3.导入模板
    ID 导入: 12633
4.选择对应的数据源
    Name:Prometheus
    VictoriaMetrics:Prometheus  (选择上面配置好的数据源)
5.点击导入,生成图表信息

相关文章

网友评论

      本文标题:Docker 部署 Prometheus(普罗米修斯)

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