scrape

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlignScrapeTimestamps = true

AlignScrapeTimestamps enables the tolerance for scrape appends timestamps described above.

View Source
var ScrapeTimestampTolerance = 2 * time.Millisecond

ScrapeTimestampTolerance is the tolerance for scrape appends timestamps alignment, to enable better compression at the TSDB level. See https://github.com/BraeTroutman/prometheus/issues/7846

View Source
var UserAgent = fmt.Sprintf("Prometheus/%s", version.Version)

Functions

func ContextWithMetricMetadataStore

func ContextWithMetricMetadataStore(ctx context.Context, s MetricMetadataStore) context.Context

func ContextWithTarget

func ContextWithTarget(ctx context.Context, t *Target) context.Context

func PopulateLabels

func PopulateLabels(lset labels.Labels, cfg *config.ScrapeConfig) (res, orig labels.Labels, err error)

PopulateLabels builds a label set from the given label set and scrape configuration. It returns a label set before relabeling was applied as the second return value. Returns the original discovered label set found before relabelling was applied if the target is dropped during relabeling.

Types

type Manager

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

Manager maintains a set of scrape pools and manages start/stop cycles when receiving new target groups from the discovery manager.

func NewManager

func NewManager(o *Options, logger log.Logger, app storage.Appendable) *Manager

NewManager is the Manager constructor

func (*Manager) ApplyConfig

func (m *Manager) ApplyConfig(cfg *config.Config) 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) error

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()

Stop cancels all running scrape pools and blocks until all have exited.

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 MetadataMetricsCollector

type MetadataMetricsCollector struct {
	CacheEntries *prometheus.Desc
	CacheBytes   *prometheus.Desc
	// contains filtered or unexported fields
}

MetadataMetricsCollector is a Custom Collector for the metadata cache metrics.

func (*MetadataMetricsCollector) Collect

func (mc *MetadataMetricsCollector) Collect(ch chan<- prometheus.Metric)

Collect creates and sends the metrics for the metadata cache.

func (*MetadataMetricsCollector) Describe

func (mc *MetadataMetricsCollector) Describe(ch chan<- *prometheus.Desc)

Describe sends the metrics descriptions to the channel.

type MetricMetadata

type MetricMetadata struct {
	Metric string
	Type   textparse.MetricType
	Help   string
	Unit   string
}

MetricMetadata is a piece of metadata for a metric.

type MetricMetadataStore

type MetricMetadataStore interface {
	ListMetadata() []MetricMetadata
	GetMetadata(metric string) (MetricMetadata, bool)
	SizeMetadata() int
	LengthMetadata() int
}

MetricMetadataStore represents a storage for metadata.

func MetricMetadataStoreFromContext

func MetricMetadataStoreFromContext(ctx context.Context) (MetricMetadataStore, bool)

type Options

type Options struct {
	ExtraMetrics bool
	// Option used by downstream scraper users like OpenTelemetry Collector
	// to help lookup metric metadata. Should be false for Prometheus.
	PassMetadataInContext bool
	// Option to increase the interval used by scrape manager to throttle target groups updates.
	DiscoveryReloadInterval model.Duration

	// Optional HTTP client options to use when scraping.
	HTTPClientOptions []config_util.HTTPClientOption
}

Options are the configuration parameters to the scrape manager.

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 TargetFromContext

func TargetFromContext(ctx context.Context) (*Target, bool)

func TargetsFromGroup

func TargetsFromGroup(tg *targetgroup.Group, cfg *config.ScrapeConfig) ([]*Target, []error)

TargetsFromGroup builds targets based on the given TargetGroup and config.

func (*Target) DiscoveredLabels

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

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

func (*Target) GetValue

func (t *Target) GetValue(name string) string

GetValue gets a label value from the entire label set.

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) Metadata

func (t *Target) Metadata(metric string) (MetricMetadata, bool)

Metadata returns type and help metadata for the given metric.

func (*Target) MetadataLength

func (t *Target) MetadataLength() int

func (*Target) MetadataList

func (t *Target) MetadataList() []MetricMetadata

func (*Target) MetadataSize

func (t *Target) MetadataSize() int

func (*Target) Report

func (t *Target) Report(start time.Time, dur time.Duration, err error)

Report sets target data about the last scrape.

func (*Target) SetDiscoveredLabels

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

SetDiscoveredLabels sets new DiscoveredLabels

func (*Target) SetMetadataStore

func (t *Target) SetMetadataStore(s MetricMetadataStore)

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