持续调优的工具-Pyroscope

Pyroscope 是一个持续调优的工具,可以检查程序代码在运行时,检查 CPU 的使用率和内存内存的使用率,本文将介绍如何搭建和使用

安装

Pyroscope 的安装将在 k8s 上进行,并使用 helm 进行部署。分为 server 的安装和 agent 的安装:

server 的安装,命令如下:

kubectl create namespace pyroscope-test
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm -n pyroscope-test upgrade --install pyroscope grafana/pyroscope --set pyroscope.service.type=NodePort

agent 的安装,安装时需要将下面的 yaml 文件保存为 values.yaml 执行如下命令:

agent:
  mode: 'flow'
  configMap:
    create: true
    content: |
      discovery.kubernetes "local_pods" {
        selectors {
          field = "spec.nodeName=" + env("HOSTNAME")
          role = "pod"
        }
        role = "pod"
      }
      pyroscope.ebpf "instance" {
        forward_to = [pyroscope.write.endpoint.receiver]
        targets = discovery.kubernetes.local_pods.targets
      }
      pyroscope.write "endpoint" {
        endpoint {
          url = "http://pyroscope.pyroscope-test.svc.cluster.local.:4040/"
        }
      }

  securityContext:
    privileged: true
    runAsGroup: 0
    runAsUser: 0

controller:
  hostPID: true
helm install pyroscope-ebpf grafana/grafana-agent -f values.yaml

这个文档中使用的 agent 的模式为 ebpf ,这个模式要求内核要在 4.9 以上。

查看

安装完成之后,执行 kubectl port-forward -n pyroscope-test service/grafana 3000:80 即可在浏览器访问 http://127.0.0.1 查看调用信息。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

启明真纳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值