Skip to content

pyroscope.relabel don't work with labels in pprof #4689

@okhowang

Description

@okhowang

Component(s)

pyroscope.relabel

What's wrong?

I use pyroscope go sdk to push profile to alloy.
And I use pprof.Do to add some label to pprof.
It will be visualized by pyroscope.
but pyroscope.relabel in alloy can't handle label in pprof.
It may result by that alloy don't parse profile body, just use label in query.

Steps to reproduce

demo go app

// nolint
package main

import (
	"context"
	"net/http"
	"os"
	"os/exec"
	"runtime/pprof"
	"time"

	"github.com/grafana/pyroscope-go"
)
import _ "net/http/pprof"

func sleep() {
	pprof.Do(context.Background(), pprof.Labels("sleep", "1"), func(ctx context.Context) {
		time.Sleep(time.Hour)
	})
}

func cmdSleep() {
	pprof.Do(context.Background(), pprof.Labels("sleep", "2"), func(ctx context.Context) {
		_ = exec.CommandContext(ctx, "sleep", "3600").Run()
	})
}

func main() {
	pyroscope.Start(pyroscope.Config{
		ApplicationName: "simple.golang.app",

		// replace this with the address of pyroscope server
		ServerAddress: "http://localhost:4040",

		// you can disable logging by setting this to nil
		Logger: pyroscope.StandardLogger,

		// you can provide static tags via a map:
		Tags: map[string]string{"hostname": os.Getenv("HOSTNAME")},

		ProfileTypes: []pyroscope.ProfileType{
			// these profile types are enabled by default:
			pyroscope.ProfileCPU,
			pyroscope.ProfileAllocObjects,
			pyroscope.ProfileAllocSpace,
			pyroscope.ProfileInuseObjects,
			pyroscope.ProfileInuseSpace,

			// these profile types are optional:
			pyroscope.ProfileGoroutines,
			pyroscope.ProfileMutexCount,
			pyroscope.ProfileMutexDuration,
			pyroscope.ProfileBlockCount,
			pyroscope.ProfileBlockDuration,
		},
	})
	go http.ListenAndServe(":6060", nil)
	go sleep()
	go cmdSleep()

	select {
	case <-time.After(time.Hour):
	}
}

System information

No response

Software version

alloy v1.10.1

Configuration

pyroscope.receive_http "default" {
	http {
		listen_address = "0.0.0.0"
		listen_port    = 4040
	}
	forward_to = [pyroscope.relabel.default.receiver]
}
pyroscope.relabel "default" {
	forward_to = [pyroscope.write.default.receiver]

	rule {
		action = "labeldrop"
		regex  = "sleep"
	}
}
pyroscope.write "default" {
	endpoint {
		url = "http://pyroscope:9090"
	}
}

Logs


Tip

React with 👍 if this issue is important to you.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions