scrape

package
v0.34.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProfilePath      = "__profile_path__"
	ProfileName      = "__name__"
	ProfileTraceType = "trace"
)

Variables

View Source
var DefaultArguments = NewDefaultArguments()
View Source
var DefaultProfilingConfig = ProfilingConfig{
	Memory: ProfilingTarget{
		Enabled: true,
		Path:    "/debug/pprof/allocs",
	},
	Block: ProfilingTarget{
		Enabled: true,
		Path:    "/debug/pprof/block",
	},
	Goroutine: ProfilingTarget{
		Enabled: true,
		Path:    "/debug/pprof/goroutine",
	},
	Mutex: ProfilingTarget{
		Enabled: true,
		Path:    "/debug/pprof/mutex",
	},
	ProcessCPU: ProfilingTarget{
		Enabled: true,
		Path:    "/debug/pprof/profile",
		Delta:   true,
	},
	FGProf: ProfilingTarget{
		Enabled: false,
		Path:    "/debug/fgprof",
		Delta:   true,
	},
}

Functions

func LabelsByProfiles

func LabelsByProfiles(lset labels.Labels, c *ProfilingConfig) []labels.Labels

LabelsByProfiles returns the labels for a given ProfilingConfig.

Types

type Arguments

type Arguments struct {
	Targets   []discovery.Target     `river:"targets,attr"`
	ForwardTo []pyroscope.Appendable `river:"forward_to,attr"`

	// The job name to override the job label with.
	JobName string `river:"job_name,attr,optional"`
	// A set of query parameters with which the target is scraped.
	Params url.Values `river:"params,attr,optional"`
	// How frequently to scrape the targets of this scrape config.
	ScrapeInterval time.Duration `river:"scrape_interval,attr,optional"`
	// The timeout for scraping targets of this config.
	ScrapeTimeout time.Duration `river:"scrape_timeout,attr,optional"`
	// The URL scheme with which to fetch metrics from targets.
	Scheme string `river:"scheme,attr,optional"`

	HTTPClientConfig component_config.HTTPClientConfig `river:",squash"`

	ProfilingConfig ProfilingConfig `river:"profiling_config,block,optional"`

	Clustering scrape.Clustering `river:"clustering,block,optional"`
}

Arguments holds values which are used to configure the pprof.scrape component.

func NewDefaultArguments

func NewDefaultArguments() Arguments

NewDefaultArguments create the default settings for a scrape job.

func (*Arguments) UnmarshalRiver

func (arg *Arguments) UnmarshalRiver(f func(interface{}) error) error

UnmarshalRiver implements river.Unmarshaler.

type Component

type Component struct {
	// contains filtered or unexported fields
}

Component implements the pprof.scrape component.

func New

func New(o component.Options, args Arguments) (*Component, error)

New creates a new pprof.scrape component.

func (*Component) ClusterUpdatesRegistration

func (c *Component) ClusterUpdatesRegistration() bool

ClusterUpdatesRegistration implements component.ClusterComponent.

func (*Component) DebugInfo

func (c *Component) DebugInfo() interface{}

DebugInfo implements component.DebugComponent.

func (*Component) Run

func (c *Component) Run(ctx context.Context) error

Run implements component.Component.

func (*Component) Update

func (c *Component) Update(args component.Arguments) error

Update implements component.Component.

type CustomProfilingTarget

type CustomProfilingTarget struct {
	Enabled bool   `river:"enabled,attr"`
	Path    string `river:"path,attr"`
	Delta   bool   `river:"delta,attr,optional"`
	Name    string `river:",label"`
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(appendable pyroscope.Appendable, logger log.Logger) *Manager

func (*Manager) ApplyConfig

func (m *Manager) ApplyConfig(cfg Arguments) error

ApplyConfig resets the manager's target providers and job configurations as defined by the new cfg.

func (*Manager) Run

func (m *Manager) Run(tsets <-chan map[string][]*targetgroup.Group)

Run receives and saves target set updates and triggers the scraping loops reloading. Reloading happens in the background so that it doesn't block receiving targets updates.

func (*Manager) Stop

func (m *Manager) Stop()

func (*Manager) TargetsActive

func (m *Manager) TargetsActive() map[string][]*Target

TargetsActive returns the active targets currently being scraped.

func (*Manager) TargetsAll

func (m *Manager) TargetsAll() map[string][]*Target

TargetsAll returns active and dropped targets grouped by job_name.

func (*Manager) TargetsDropped

func (m *Manager) TargetsDropped() map[string][]*Target

TargetsDropped returns the dropped targets during relabelling.

type ProfilingConfig

type ProfilingConfig struct {
	Memory     ProfilingTarget         `river:"profile.memory,block,optional"`
	Block      ProfilingTarget         `river:"profile.block,block,optional"`
	Goroutine  ProfilingTarget         `river:"profile.goroutine,block,optional"`
	Mutex      ProfilingTarget         `river:"profile.mutex,block,optional"`
	ProcessCPU ProfilingTarget         `river:"profile.process_cpu,block,optional"`
	FGProf     ProfilingTarget         `river:"profile.fgprof,block,optional"`
	Custom     []CustomProfilingTarget `river:"profile.custom,block,optional"`

	PprofPrefix string `river:"path_prefix,attr,optional"`
}

func (ProfilingConfig) AllTargets

func (cfg ProfilingConfig) AllTargets() map[string]ProfilingTarget

AllTargets returns the set of all standard and custom profiling targets, regardless of whether they're enabled. The key in the map indicates the name of the target.

func (*ProfilingConfig) UnmarshalRiver

func (cfg *ProfilingConfig) UnmarshalRiver(f func(interface{}) error) error

UnmarshalRiver implements river.Unmarshaler and applies defaults before unmarshaling.

type ProfilingTarget

type ProfilingTarget struct {
	Enabled bool   `river:"enabled,attr,optional"`
	Path    string `river:"path,attr,optional"`
	Delta   bool   `river:"delta,attr,optional"`
}

type Target

type Target struct {
	// contains filtered or unexported fields
}

Target refers to a singular HTTP or HTTPS endpoint.

func NewTarget

func NewTarget(labels, discoveredLabels labels.Labels, params url.Values) *Target

NewTarget creates a reasonably configured target for querying.

func (*Target) Clone

func (t *Target) Clone() *Target

Clone returns a clone of the target.

func (*Target) DiscoveredLabels

func (t *Target) DiscoveredLabels() labels.Labels

DiscoveredLabels returns a copy of the target's labels before any processing.

func (*Target) Health

func (t *Target) Health() TargetHealth

Health returns the last known health state of the target.

func (*Target) Labels

func (t *Target) Labels() labels.Labels

Labels returns a copy of the set of all public labels of the target.

func (*Target) LastError

func (t *Target) LastError() error

LastError returns the error encountered during the last scrape.

func (*Target) LastScrape

func (t *Target) LastScrape() time.Time

LastScrape returns the time of the last scrape.

func (*Target) LastScrapeDuration

func (t *Target) LastScrapeDuration() time.Duration

LastScrapeDuration returns how long the last scrape of the target took.

func (*Target) Params

func (t *Target) Params() url.Values

Params returns a copy of the set of all public params of the target.

func (*Target) SetDiscoveredLabels

func (t *Target) SetDiscoveredLabels(l labels.Labels)

SetDiscoveredLabels sets new DiscoveredLabels.

func (*Target) String

func (t *Target) String() string

func (*Target) URL

func (t *Target) URL() *url.URL

URL returns a copy of the target's URL.

type TargetHealth

type TargetHealth string

TargetHealth describes the health state of a target.

const (
	HealthUnknown TargetHealth = "unknown"
	HealthGood    TargetHealth = "up"
	HealthBad     TargetHealth = "down"
)

The possible health states of a target based on the last performed scrape.

type Targets

type Targets []*Target

Targets is a sortable list of targets.

func (Targets) Len

func (ts Targets) Len() int

func (Targets) Less

func (ts Targets) Less(i, j int) bool

func (Targets) Swap

func (ts Targets) Swap(i, j int)

Jump to

Keyboard shortcuts

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