0
点赞
收藏
分享

微信扫一扫

parca 简单试用

parca 支持多种模式的数据ingestion 以下测试下基于pull 模式的

数据ingestion 模式

参考图

parca 简单试用_github

 

 

环境准备

  • docker-compose.yaml

 

version: '3'

services:

app:

build: ./

ports:

- "3000:3000"

parca:

image: ghcr.io/parca-dev/parca:v0.12.1

command: /parca --config-path=/opt/parca.yaml

ports:

- "7070:7070"

volumes:

- "./parca.yaml:/opt/parca.yaml"

parca 配置

debug_info:

bucket:

type: "FILESYSTEM"

config:

directory: "./tmp"

cache:

type: "FILESYSTEM"

config:

directory: "./tmp"

 

scrape_configs:

- job_name: "default"

scrape_interval: "2s"

static_configs:

- targets: ["127.0.0.1:7070"]

- job_name: "myapp"

scrape_interval: "2s"

static_configs:

- targets: ["app:3000"]

  • app dockerfile

FROM golang:1.19-alpine3.16 AS build-env

WORKDIR /go/src/app

RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories

 

ENV  GO111MODULE=on

ENV  GOPROXY=https://goproxy.cn

COPY . .

RUN apk update && apk add git \

&& go build -o app

 

FROM alpine:latest

WORKDIR /app

RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories

RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*

COPY --from=build-env /go/src/app/app /app/app

EXPOSE 3000

CMD ["/app/app"]

app.go

package main

 

import (

"log"

"net/http"

"net/http/pprof"

)

 

func main() {

mux := http.NewServeMux()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

w.Header().Add("dalong", "app")

w.Write([]byte("dalongdemo"))

})

mux.HandleFunc("/debug/pprof/", pprof.Index)

mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)

mux.HandleFunc("/debug/pprof/profile", pprof.Profile)

mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)

mux.HandleFunc("/debug/pprof/trace", pprof.Trace)

log.Fatal(http.ListenAndServe("0.0.0.0:3000", mux))

}

运行&效果

  • 启动

docker-compose up -d

  • 效果

target

parca 简单试用_数据_02

 

 

查询

parca 简单试用_docker_03

 

 

调用链

parca 简单试用_docker_04

 

 

说明

以上是基于pull 模式的使用,实际上对于golang 应用我们是可以拿来即用的,还是比较方便的,后续深入研究下

参考资料

​​https://github.com/rongfengliang/parca-docker-compose-learning​​​
​​​https://www.parca.dev/docs/instrumenting-go​​​
​​​https://github.com/parca-dev/parca​​​
​​​https://github.com/parca-dev/parca-agent​​

举报

相关推荐

0 条评论