Documentation
¶
Index ¶
- Variables
- func AddMetricFamilyToProtobuf(buffer *bytes.Buffer, metricFamily *dto.MetricFamily) error
- func ContextWithMetricMetadataStore(ctx context.Context, s MetricMetadataStore) context.Context
- func ContextWithTarget(ctx context.Context, t *Target) context.Context
- func GetDefaultGatherer() prometheus.Gatherer
- func GetDefaultGathererHandler() http.Handler
- func MetricFamilyToProtobuf(metricFamily *dto.MetricFamily) ([]byte, error)
- func NewScrapeMetrics(reg prometheus.Registerer) (*scrapeMetrics, error)
- func PopulateLabels(lb *labels.Builder, cfg *config.ScrapeConfig, noDefaultPort bool) (res, orig labels.Labels, err error)
- func SetDefaultGatherer(g prometheus.Gatherer)
- func SetDefaultGathererHandler(h http.Handler)
- type GathereLoop
- type Manager
- func (m *Manager) ApplyConfig(cfg *config.Config) error
- func (m *Manager) Run(tsets <-chan map[string][]*targetgroup.Group) error
- func (m *Manager) ScrapePools() []string
- func (m *Manager) Stop()
- func (m *Manager) TargetsActive() map[string][]*Target
- func (m *Manager) TargetsAll() map[string][]*Target
- func (m *Manager) TargetsDropped() map[string][]*Target
- func (m *Manager) TargetsDroppedCounts() map[string]int
- func (m *Manager) UnregisterMetrics()
- type MetadataMetricsCollector
- type MetricMetadata
- type MetricMetadataStore
- type Options
- type Target
- func (t *Target) DiscoveredLabels() labels.Labels
- func (t *Target) GetMetadata(metric string) (MetricMetadata, bool)
- func (t *Target) GetValue(name string) string
- func (t *Target) Health() TargetHealth
- func (t *Target) Labels(b *labels.ScratchBuilder) labels.Labels
- func (t *Target) LabelsRange(f func(l labels.Label))
- func (t *Target) LastError() error
- func (t *Target) LastScrape() time.Time
- func (t *Target) LastScrapeDuration() time.Duration
- func (t *Target) LengthMetadata() int
- func (t *Target) ListMetadata() []MetricMetadata
- func (t *Target) Report(start time.Time, dur time.Duration, err error)
- func (t *Target) SetDiscoveredLabels(l labels.Labels)
- func (t *Target) SetMetadataStore(s MetricMetadataStore)
- func (t *Target) SizeMetadata() int
- func (t *Target) String() string
- func (t *Target) URL() *url.URL
- type TargetHealth
- type Targets
- type TargetsGatherer
Constants ¶
This section is empty.
Variables ¶
var AlignScrapeTimestamps = true
AlignScrapeTimestamps enables the tolerance for scrape appends timestamps described above.
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/prometheus/prometheus/issues/7846
var UserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
Functions ¶
func AddMetricFamilyToProtobuf ¶
func AddMetricFamilyToProtobuf(buffer *bytes.Buffer, metricFamily *dto.MetricFamily) error
Append a MetricFamily protobuf representation to a buffer. This function is intended for testing scraping by providing protobuf serialized input.
func ContextWithMetricMetadataStore ¶
func ContextWithMetricMetadataStore(ctx context.Context, s MetricMetadataStore) context.Context
func GetDefaultGatherer ¶
func GetDefaultGatherer() prometheus.Gatherer
func MetricFamilyToProtobuf ¶
func MetricFamilyToProtobuf(metricFamily *dto.MetricFamily) ([]byte, error)
Write a MetricFamily into a protobuf. This function is intended for testing scraping by providing protobuf serialized input.
func NewScrapeMetrics ¶
func NewScrapeMetrics(reg prometheus.Registerer) (*scrapeMetrics, error)
func PopulateLabels ¶
func PopulateLabels(lb *labels.Builder, cfg *config.ScrapeConfig, noDefaultPort bool) (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.
func SetDefaultGatherer ¶
func SetDefaultGatherer(g prometheus.Gatherer)
func SetDefaultGathererHandler ¶
This enables scraper to read metrics from the handler directly without making HTTP request
Types ¶
type GathereLoop ¶
type GathereLoop struct {
// contains filtered or unexported fields
}
func NewGathererLoop ¶
func NewGathererLoop(ctx context.Context, logger log.Logger, app storage.Appendable, reg prometheus.Registerer, g prometheus.Gatherer, interval time.Duration) (*GathereLoop, error)
func (*GathereLoop) Run ¶
func (gl *GathereLoop) Run(errc chan<- error)
func (*GathereLoop) ScrapeAndReport ¶
func (*GathereLoop) Stop ¶
func (gl *GathereLoop) Stop()
func (*GathereLoop) UnregisterMetrics ¶
func (gl *GathereLoop) UnregisterMetrics()
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, registerer prometheus.Registerer) (*Manager, error)
NewManager is the Manager constructor.
func (*Manager) ApplyConfig ¶
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) ScrapePools ¶
ScrapePools returns the list of all scrape pool names.
func (*Manager) Stop ¶
func (m *Manager) Stop()
Stop cancels all running scrape pools and blocks until all have exited.
func (*Manager) TargetsActive ¶
TargetsActive returns the active targets currently being scraped.
func (*Manager) TargetsAll ¶
TargetsAll returns active and dropped targets grouped by job_name.
func (*Manager) TargetsDropped ¶
TargetsDropped returns the dropped targets during relabelling, subject to KeepDroppedTargets limit.
func (*Manager) TargetsDroppedCounts ¶
func (*Manager) UnregisterMetrics ¶
func (m *Manager) UnregisterMetrics()
UnregisterMetrics unregisters manager metrics.
type MetadataMetricsCollector ¶
type MetadataMetricsCollector struct {
CacheEntries *prometheus.Desc
CacheBytes *prometheus.Desc
TargetsGatherer TargetsGatherer
}
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 model.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
NoDefaultPort bool
// Option used by downstream scraper users like OpenTelemetry Collector
// to help lookup metric metadata. Should be false for Prometheus.
PassMetadataInContext bool
// Option to enable appending of scraped Metadata to the TSDB/other appenders. Individual appenders
// can decide what to do with metadata, but for practical purposes this flag exists so that metadata
// can be written to the WAL and thus read for remote write.
// TODO: implement some form of metadata storage
AppendMetadata bool
// Option to increase the interval used by scrape manager to throttle target groups updates.
DiscoveryReloadInterval model.Duration
// Option to enable the ingestion of the created timestamp as a synthetic zero sample.
// See: https://github.com/prometheus/proposals/blob/main/proposals/2023-06-13_created-timestamp.md
EnableCreatedTimestampZeroIngestion bool
// Option to enable the ingestion of native histograms.
EnableNativeHistogramsIngestion bool
// Optional HTTP client options to use when scraping.
HTTPClientOptions []config_util.HTTPClientOption
// contains filtered or unexported fields
}
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 TargetsFromGroup ¶
func TargetsFromGroup(tg *targetgroup.Group, cfg *config.ScrapeConfig, noDefaultPort bool, targets []*Target, lb *labels.Builder) ([]*Target, []error)
TargetsFromGroup builds targets based on the given TargetGroup and config.
func (*Target) DiscoveredLabels ¶
DiscoveredLabels returns a copy of the target's labels before any processing.
func (*Target) GetMetadata ¶
func (t *Target) GetMetadata(metric string) (MetricMetadata, bool)
GetMetadata returns type and help metadata for the given metric.
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(b *labels.ScratchBuilder) labels.Labels
Labels returns a copy of the set of all public labels of the target.
func (*Target) LabelsRange ¶
LabelsRange calls f on each public label of the target.
func (*Target) LastScrape ¶
LastScrape returns the time of the last scrape.
func (*Target) LastScrapeDuration ¶
LastScrapeDuration returns how long the last scrape of the target took.
func (*Target) LengthMetadata ¶
func (*Target) ListMetadata ¶
func (t *Target) ListMetadata() []MetricMetadata
func (*Target) SetDiscoveredLabels ¶
SetDiscoveredLabels sets new DiscoveredLabels.
func (*Target) SetMetadataStore ¶
func (t *Target) SetMetadataStore(s MetricMetadataStore)
func (*Target) SizeMetadata ¶
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.