docker-compose安装node-exporter, prometheus, grafana

基础

exporter提供监控数据

prometheus拉取监控数据

grafana可视化监控数据

准备

全部操作在/root/mypromethus中执行

node_exporter

shell 复制代码
docker-compose -f node-exporter.yaml up -d
# web访问,查看node_exporter采集到的数据
http://192.168.1.102:9101/metrics/

node-exporter.yaml

yaml 复制代码
version: '3.8'
services:
  node_exporter:
    image: prom/node-exporter:v1.6.0
    container_name: node_exporter
    command:
    - '--path.rootfs=/host'
    pid: host
    restart: unless-stopped
    environment:
    - TZ=Asia/Shanghai
    ports:
    - 9101:9100
    volumes:
    - '/:/host:ro,rslave'

prometheus

shell 复制代码
docker-compose -f dcprometheus.yaml up -d
# web访问
http://192.168.1.102:9102
# 修改权限
chmod 777 prometheus_data

dcprometheus.yaml

yaml 复制代码
prometheus:
  image: prom/prometheus:v2.37.9
  restart: always
  container_name: prometheus
  hostname: prometheus
  environment:
  - TZ=Asia/Shanghai
  ports:
  - 9102:9090
  command:
    - '--config.file=/etc/prometheus/prometheus.yml'
    - '--storage.tsdb.path=/prometheus'
    - '--web.console.libraries=/usr/share/prometheus/console_libraries' 
    - '--web.console.templates=/usr/share/prometheus/consoles' 
    - '--storage.tsdb.retention.time=7d'
    - '--web.external-url=http://192.168.1.102:9090/'
  volumes:
  - /root/myprometheus/prometheus_cnf/prometheus.yml:/etc/prometheus/prometheus.yml
  - /root/myprometheus/prometheus_data:/prometheus

prometheus_cnf/prometheus.yml

yaml 复制代码
# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093#报警地址未使用

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'node-exporter'
    static_configs:
    - targets: ['192.168.1.102:9101']# 需要修改 node-exporter service
      labels:
        host: myhost01# 添加标签

grafana

shell 复制代码
docker-compose -f grafana.yaml up -d
# web访问
http://192.168.1.102:9103
admin/admin
# 修改权限
chomd 777 plugins
# 添加prometheus
http://192.168.1.102:9102
# 添加dashboard,import dashboard,在grafana官网找dashboard id
https://grafana.com/grafana/dashboards/

grafana.yaml

yaml 复制代码
grafana:
  image: grafana/grafana:10.1.0-ubuntu
  restart: always
  container_name: grafana
  hostname: grafana
  environment:
  - TZ=Asia/Shanghai
  volumes:
  #- /opt/grafana/defaults.ini:/etc/grafana/grafana.ini
  - /root/myprometheus/grafana_data/plugins:/var/lib/grafana/plugins
  ports:
  - 9103:3000

问题

  • prometheus和grafana目录权限问题

参考

相关推荐
AllenLeungX4 分钟前
firewall docker 冲突问题解决(亲测有效)
运维·docker·容器
来一杯龙舌兰25 分钟前
【Dockerfile】Dockerfile打包Tomcat及TongWeb应用镜像(工作实践踩坑教学)
docker·中间件·tomcat·国产化·dockerfile·tongweb·容器化部署
MY Daisy5 小时前
docker:制作镜像+上传镜像+拉取镜像
docker·容器
小Tomkk8 小时前
Docker 渡渡鸟镜像同步站 使用教程
docker·容器·eureka
Chase_Mos8 小时前
Docker 使用与部署(超详细)
运维·docker·容器
天堂的恶魔9469 小时前
Docker —— 技术架构的演进
docker·容器·架构
matlabgoodboy11 小时前
Haskell Drracket OCaml Prolog 逻辑式编程函数式编程代写代做
vscode·ci/cd·docker
czhc114007566318 小时前
Linux53 百度网盘运行(下载devtoolset11后仍提示stdc++3.0.29缺失 计划用docker容器隔离运行,计划后续再看)
运维·docker·容器
大G哥19 小时前
【微服务】SpringBoot制作Docker镜像接入SkyWalking详解
spring boot·docker·微服务·架构·skywalking
柚个朵朵19 小时前
Docker Compose:服务编排:批量管理多个容器
运维·docker·容器