pprofreceiver

package module
v0.156.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 1

README

Pprof Receiver

The Pprof Receiver collects profiles from files specified with a glob pattern, from a remote endpoint or the running collector.

Status
Stability alpha: profiles
Distributions contrib
Issues Open issues Closed issues
Code coverage codecov
Code Owners @MovieStoreGuy, @atoulme

Configuration

The receiver supports four independent ingestion modes that can be combined in a single receiver instance. At least one section must be configured.

  • remote: poll pprof from a remote HTTP endpoint
  • file: read pprof files matching a glob pattern
  • self: profile the running collector
  • server: accept pushed pprof data over HTTP at POST /v1/pprof

Each scraping section (remote, file, self) accepts its own collection_interval (default 10s) and initial_delay (default 1s).

remote

Accepts every field of confighttp.ClientConfig.

  • endpoint (required): the URL to fetch pprof data from.
file
  • include (required): glob pattern for pprof files to read.
self
server

Accepts every field of confighttp.ServerConfig. The server exposes a single endpoint:

POST /v1/pprof
Content-Type: application/octet-stream

The body is a serialized pprof profile.proto. Standard Content-Encoding values (e.g. gzip) are handled transparently by confighttp.

Pushing an existing pprof file

A profile.proto is already gzip-encoded on disk by the standard runtime/pprof package, so the file bytes can be sent as-is with Content-Encoding: gzip:

package main

import (
	"log"
	"net/http"
	"os"
)

func main() {
	f, err := os.Open("cpu.pprof")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	req, err := http.NewRequest(http.MethodPost, "http://localhost:4040/v1/pprof", f)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Content-Type", "application/octet-stream")
	req.Header.Set("Content-Encoding", "gzip")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusNoContent {
		log.Fatalf("unexpected status: %s", resp.Status)
	}
}
Example
receivers:
  pprof:
    remote:
      endpoint: http://my-svc:9090/debug/pprof/profile?seconds=1
      collection_interval: 30s
      initial_delay: 10s
    server:
      endpoint: 0.0.0.0:4040
      tls:
        cert_file: server.crt
        key_file: server.key
    file:
      include: /tmp/pprof/*
      collection_interval: 10s
      initial_delay: 20s
    self:
      collection_interval: 15s
      initial_delay: 1s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

Types

type Config

type Config struct {
	// Remote configures pulling pprof profiles from a remote HTTP endpoint.
	Remote configoptional.Optional[RemoteConfig] `mapstructure:"remote"`

	// File configures reading pprof profiles from files matching a glob pattern.
	File configoptional.Optional[FileConfig] `mapstructure:"file"`

	// Self configures profiling the running collector.
	Self configoptional.Optional[SelfConfig] `mapstructure:"self"`

	// Server configures an HTTP server that accepts pushed pprof profiles.
	Server configoptional.Optional[ServerConfig] `mapstructure:"server"`
	// contains filtered or unexported fields
}

Config defines the configuration for the pprof receiver.

func (*Config) Validate added in v0.148.0

func (c *Config) Validate() error

type FileConfig added in v0.153.0

type FileConfig struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`

	// Include is the glob pattern for pprof files to scrape.
	Include string `mapstructure:"include"`
	// contains filtered or unexported fields
}

FileConfig configures a scraper that reads pprof files matching a glob pattern.

type RemoteConfig added in v0.153.0

type RemoteConfig struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`
	confighttp.ClientConfig        `mapstructure:",squash"`
	// contains filtered or unexported fields
}

RemoteConfig configures a scraper that pulls pprof from a remote HTTP endpoint.

type SelfConfig added in v0.153.0

type SelfConfig struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`

	// Fraction of blocking events that are profiled. A value <= 0 disables
	// profiling. See https://golang.org/pkg/runtime/#SetBlockProfileRate for details.
	BlockProfileFraction int `mapstructure:"block_profile_fraction"`

	// Fraction of mutex contention events that are profiled. A value <= 0
	// disables profiling. See https://golang.org/pkg/runtime/#SetMutexProfileFraction
	// for details.
	MutexProfileFraction int `mapstructure:"mutex_profile_fraction"`
	// contains filtered or unexported fields
}

SelfConfig configures a scraper that profiles the running collector.

type ServerConfig added in v0.153.0

type ServerConfig struct {
	confighttp.ServerConfig `mapstructure:",squash"`
	// contains filtered or unexported fields
}

ServerConfig configures an HTTP server that accepts pushed pprof data.

Directories

Path Synopsis
metadata
Package metadata contains the autogenerated telemetry and build information for the receiver/pprof component.
Package metadata contains the autogenerated telemetry and build information for the receiver/pprof component.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL