• dockercompose 部署jmeter+grafana+prometheus/influxdb,构建性能测试可视化实时监控(一)...


    docker-compose 部署grafana,prometheus

    从grafana和prometheus官网拿到docker-compose.yml(下面有链接,进入后直接搜docker-compose.yml 就可以找到),然后放一起,如下图,作为compose启动的配置文件docker-compose.yml

    [root@kpc]# cat docker-compose.yml 
    version: "3"
    services:
      grafana:
        image: grafana/grafana:5.1.0
        ports:
          - 3000:3000
        user: "104"
      prometheus:
        image: prom/prometheus:latest
        container_name: prometheus
        ports:
        - 9090:9090
        command:
        - --config.file=/etc/prometheus/prometheus.yml
        volumes:
        - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
        depends_on:
        - cadvisor
      cadvisor:
        image: gcr.io/cadvisor/cadvisor:latest
        container_name: cadvisor
        ports:
        - 8080:8080
        volumes:
        - /:/rootfs:ro
        - /var/run:/var/run:rw
        - /sys:/sys:ro
        - /var/lib/docker/:/var/lib/docker:ro
        depends_on:
        - redis
      redis:
        image: redis:latest
        container_name: redis
        ports:
        - 6380:6379

    https://grafana.com/docs/grafana/latest/installation/docker/

    https://prometheus.io/docs/guides/cadvisor/#prometheus-configuration

    只有docker-compose.yml还不够,启动会报错的,因为prometheus有个volumes配置

    volumes:
        - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro

    意思是把虚拟机当前目录下的prometheus.yml文件映射到prometheus服务容器里面的/etc/prometheus/prometheus.yml,所以,我们还要在当前目录建一个prometheus.yml,写入内容

    scrape_configs:
    - job_name: cadvisor
      scrape_interval: 5s
      static_configs:
      - targets:
        - cadvisor:8080

    现在就齐活了,看一下当前目录都有啥?嗯, 就这2个文件

    [root@kpc]# ls
    docker-compose.yml  prometheus.yml

    现在我们再up,发现报错了,看报错是拉取cadvisor时连接超时了,这是因为国外源的原因,马上换一下docker源,换成aliyun的,怎么替换docker源?

    sudo mkdir -p /etc/docker  # 如果没有就新建,有的话直接进去然后下一步
    sudo tee /etc/docker/daemon.json <<-'EOF'
    {
      "registry-mirrors": ["https://tjtr2dh5.mirror.aliyuncs.com"]
    }
    EOF
    sudo systemctl daemon-reload
    sudo systemctl restart docker

    OK,源也换了,理论上没问题了。

    docker-compose up启动,启动成功的日志太长就不贴了

    docker-compose ps查看一下,如图,State都是up说明都成功了

    [root@kpc]# docker-compose ps
           Name                     Command               State           Ports         
    ------------------------------------------------------------------------------------
    kpc_grafana_1        /run.sh                          Up      0.0.0.0:3000->3000/tcp
    cadvisor             /usr/bin/cadvisor                Up      0.0.0.0:8080->8080/tcp
    prometheus           /bin/prometheus --config.f ...   Up      0.0.0.0:9090->9090/tcp
    redis                docker-entrypoint.sh redis ...   Up      0.0.0.0:6380->6379/tcp

    打开浏览器访问看看

  • 相关阅读:
    python 获取Excel 的内容
    python 获取文件Excel 的行数与列数
    python 读取Excel 取出表头(列名)
    DRF的视图组件
    Redis
    Git的故事
    DRF的JWT用户认证
    DRF的三大认证组件
    DRF的序列化组件
    DRF的请求响应组件
  • 原文地址:https://www.cnblogs.com/kknote/p/16103474.html
Copyright © 2020-2023  润新知