flamescope+s3-fuse 扩展动态分析能力

flamescope 是一个比较强大的火焰图查看工具,但是默认是基于本地文件系统的,但是很多时候我们为了方便查看信息需要使用共享文件系统
nfs 是一个不错的选择,但是不方便分发,s3 很不错,灵活而且我们可以灵活的进行perf 文件的分发,以下代码是集成

flamescope+s3-fuseDockerfile 集成

基于官方flamescope dockerfile 修改,因为有多个进程需要运行所以基于supervisord进行管理,实际可以选择顺手的工具

 
FROM python:3-alpine3.8
ENV MNT_POINT /var/s3
ENV S3_REGION ''
ARG S3FS_VERSION=v1.86
ADD app /app/app
ADD run.py /app
ADD requirements.txt /app
ADD passwd-s3fs /etc/passwd-s3fs
RUN apk add libmagic fuse alpine-sdk automake autoconf libxml2-dev fuse-dev curl-dev git bash && 
  cd /app && 
  pip3 install -r requirements.txt && 
  mkdir /profiles && 
  sed -i -e s/127.0.0.1/0.0.0.0/g -e s~examples~/profiles~g app/config.py && 
  git clone https://github.com/s3fs-fuse/s3fs-fuse.git; 
  cd s3fs-fuse; 
  git checkout tags/${S3FS_VERSION}; 
  ./autogen.sh; 
  ./configure --prefix=/usr; 
  make; 
  make install; 
  make clean; 
  rm -rf /var/cache/apk/*; 
  apk del git automake autoconf;
RUN mkdir -p "$MNT_POINT"
WORKDIR /app
EXPOSE 5000/tcp 9001
RUN chmod 600 /etc/passwd-s3fs
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
COPY supervisor.conf /etc/supervisor.conf
CMD ["/usr/local/bin/supervisord"]

集成使用

  • docker-compose 文件
version: "3"
services:
  minio:
    image: minio/minio
    environment:
      - "MINIO_ACCESS_KEY=minio"
      - "MINIO_SECRET_KEY=minio123"
      - "MINIO_BROWSER=off"
    command: server /data
    ports:
      - "80:9000"
  gateway:
    image: minio/minio
    command: gateway s3 http://minio:9000
    ports:
      - "9000:9000"
    environment:
      - "MINIO_ACCESS_KEY=minio"
      - "MINIO_SECRET_KEY=minio123"
  flamescope-s3-fuse:
     image: dalongrong/flamescope:s3-fuse
     privileged: true
     ports: 
     - "5000:5000"
     - "9001:9001"
     volumes: 
     - "./passwd-s3fs:/etc/passwd-s3fs"
     - "./supervisord.conf:/etc/supervisord.conf"
  app:
    image: dalongrong/s3-fs:1.86
    privileged: true
    environment:
      - "AWS_KEY=minio"
      - "AWS_SECRET_KEY=minio123"
      - "S3_REGION=us-east-1"
      - "S3_URL=http://minio:9000"
      - "S3_BUCKET=apps"
  • supervisord.conf 文件
[program:flamescope]
command = /usr/local/bin/python /app/run.py
stdout_logfile = flamescope.log, /dev/stdout
[program:s3-fuse]
command = /usr/bin/s3fs apps /profiles -f -o url=http://minio:9000,endpoint=us-east-1,allow_other,use_path_request_style,retries=5,connect_timeout=10
stdout_logfile = s3.log, /dev/stdout
[inet_http_server]
port = :9001
  • 启动
docker-compose up -d

启动之后,需要先创建数据桶bucket 同时上传一个perf 抓取的文件,同时再启动flamescope 服务

  • 效果

minio 效果


flamescope 效果

说明

以上是一个简单的集成使用,实际使用的话我们可以直接s3-fuse 运行在主机上,然后在挂载到容器里边,这样我们就扩展了flamescope 的分析能力
可以实现为一个比较通用的平台了,如果希望减少容器镜像的大小,可以基于docker 的multi stage 模式进行处理

参考资料

https://www.cnblogs.com/rongfengliang/p/12655303.html
https://github.com/Netflix/flamescope

原文地址:https://www.cnblogs.com/rongfengliang/p/13356432.html