grafana phlare 试用

主要是简单试用下grafana phlare

环境准备

  • docker-compose 文件
version: '3'
services:
  phlare:
    image: grafana/phlare:latest
    ports:
      - "4100:4100"
    command: -config.file=/etc/phlare/config.yaml
    volumes:
      - ./phlare.yaml:/etc/phlare/config.yaml
      - data:/data
    networks:
      - phlare
 
  grafana:
    image: grafana/grafana:main
    ports:
      - "3000:3000"
    environment:
      - GF_FEATURE_TOGGLES_ENABLE=flameGraph
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_DIAGNOSTICS_PROFILING_ENABLED=true
      - GF_DIAGNOSTICS_PROFILING_ADDR=0.0.0.0
      - GF_DIAGNOSTICS_PROFILING_PORT=6060
    volumes:
      - ./datasource.yaml:/etc/grafana/provisioning/datasources/datasources.yml
    networks:
      - phlare
volumes:
  data:
networks:
  phlare:
  • 配置文件
    datasource.yaml
 
apiVersion: 1
datasources:
  - access: proxy
    basicAuth: false
    editable: true
    isDefault: true
    name: phlare
    type: phlare
    uid: phlare
    url: http://phlare:4100
    version: 1

phlare.yaml

scrape_configs:
  - job_name: "phlare"
    scrape_interval: "15s"
    static_configs:
      - targets: ["phlare:4100"]
  - job_name: "grafana"
    scrape_interval: "15s"
    static_configs:
      - targets: ["grafana:6060"]
  - job_name: "cp-java-springboot"
    scrape_interval: "15s"
    static_configs:
      - targets: ["docker.for.mac.host.internal:9999"]
    profiling_config:
      pprof_config:
        block: { enabled: false }
        goroutine: { enabled: false }
        memory: { enabled: false }
        mutex: { enabled: false }
 
java -jar jpprofappv2-0.0.1-SNAPSHOT.jar

运行&&效果

  • 启动
    需要springboot 应用以及docker-compose 服务
 
docker-compose up -d
java -jar jpprofappv2-0.0.1-SNAPSHOT.jar
  • 压测
ab -n 20000 -c 10 http://127.0.0.1:9999/demo
  • 效果

 

 

说明

grafana phlare 目前来说使用还是比较简单的,核心是我们的代码需要调整下,添加支持profile 的地址,使用上与prometheus 服务发现的机制是类似的,体验上还是不错的,配置管理上与parca 是类似的套路,后期可以关注下此项目的迭代,目前来说与grafana 比较好的集成是一个很大的亮点,同时系统的扩展性也是不错的(技术栈上复用了不少grafana 其他工具的公共能力)

参考资料

https://github.com/grafana/phlare/tree/main/tools/docker-compose
https://grafana.com/docs/phlare/latest/operators-guide/get-started/
https://github.com/parca-dev/parca
https://github.com/rongfengliang/jpprof-springboot-learning

posted on 2022-11-04 17:53  荣锋亮  阅读(317)  评论(0编辑  收藏  举报

导航