Help us shape the future of Go! Take the 2026 Go Developer Survey

v1

package
v1.25.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LocalhostRepresentations = []string{"127.0.0.1", "localhost", "::1"}
)

Functions

This section is empty.

Types

type API

type API struct {
	Queryable   storage.SampleAndChunkQueryable
	QueryEngine *promql.Engine

	CORSOrigin *regexp.Regexp
	// contains filtered or unexported fields
}

API can register a set of endpoints in a router and handle them using the provided storage and query engine.

func NewAPI

func NewAPI(
	qe *promql.Engine,
	s storage.Storage,
	tr func(context.Context) TargetRetriever,
	ar func(context.Context) AlertmanagerRetriever,
	configFunc func() config.Config,
	flagsMap map[string]string,
	globalURLOptions GlobalURLOptions,
	readyFunc func(http.HandlerFunc) http.HandlerFunc,
	db TSDBAdminStats,
	dbDir string,
	enableAdmin bool,
	logger log.Logger,
	rr func(context.Context) RulesRetriever,
	remoteReadSampleLimit int,
	remoteReadConcurrencyLimit int,
	remoteReadMaxBytesInFrame int,
	CORSOrigin *regexp.Regexp,
	runtimeInfo func() (RuntimeInfo, error),
	buildInfo *PrometheusVersion,
	gatherer prometheus.Gatherer,
	remoteWriteReceiver bool,
) *API

NewAPI returns an initialized API type.

func (*API) Register

func (api *API) Register(r *route.Router)

Register the API's endpoints in the given router.

type Alert added in v1.25.3

type Alert struct {
	Labels      labels.Labels `json:"labels"`
	Annotations labels.Labels `json:"annotations"`
	State       string        `json:"state"`
	ActiveAt    *time.Time    `json:"activeAt,omitempty"`
	Value       string        `json:"value"`
}

Alert has info for an alert.

type AlertDiscovery added in v1.25.3

type AlertDiscovery struct {
	Alerts []*Alert `json:"alerts"`
}

AlertDiscovery has info for all active alerts.

type AlertmanagerDiscovery added in v1.5.0

type AlertmanagerDiscovery struct {
	ActiveAlertmanagers  []*AlertmanagerTarget `json:"activeAlertmanagers"`
	DroppedAlertmanagers []*AlertmanagerTarget `json:"droppedAlertmanagers"`
}

AlertmanagerDiscovery has all the active Alertmanagers.

type AlertmanagerRetriever added in v1.25.3

type AlertmanagerRetriever interface {
	Alertmanagers() []*url.URL
	DroppedAlertmanagers() []*url.URL
}

AlertmanagerRetriever provides a list of all/dropped AlertManager URLs.

type AlertmanagerTarget added in v1.5.0

type AlertmanagerTarget struct {
	URL string `json:"url"`
}

AlertmanagerTarget has info on one AM.

type DroppedTarget added in v1.25.3

type DroppedTarget struct {
	// Labels before any processing.
	DiscoveredLabels map[string]string `json:"discoveredLabels"`
}

DroppedTarget has the information for one target that was dropped during relabelling.

type GlobalURLOptions added in v1.25.3

type GlobalURLOptions struct {
	ListenAddress string
	Host          string
	Scheme        string
}

GlobalURLOptions contains fields used for deriving the global URL for local targets.

type HeadStats added in v1.25.3

type HeadStats struct {
	NumSeries     uint64 `json:"numSeries"`
	NumLabelPairs int    `json:"numLabelPairs"`
	ChunkCount    int64  `json:"chunkCount"`
	MinTime       int64  `json:"minTime"`
	MaxTime       int64  `json:"maxTime"`
}

HeadStats has information about the TSDB head.

type PrometheusVersion added in v1.25.3

type PrometheusVersion struct {
	Version   string `json:"version"`
	Revision  string `json:"revision"`
	Branch    string `json:"branch"`
	BuildUser string `json:"buildUser"`
	BuildDate string `json:"buildDate"`
	GoVersion string `json:"goVersion"`
}

PrometheusVersion contains build information about Prometheus.

type RuleDiscovery added in v1.25.3

type RuleDiscovery struct {
	RuleGroups []*RuleGroup `json:"groups"`
}

RuleDiscovery has info for all rules

type RuleGroup added in v1.25.3

type RuleGroup struct {
	Name string `json:"name"`
	File string `json:"file"`
	// In order to preserve rule ordering, while exposing type (alerting or recording)
	// specific properties, both alerting and recording rules are exposed in the
	// same array.
	Rules          []rule    `json:"rules"`
	Interval       float64   `json:"interval"`
	EvaluationTime float64   `json:"evaluationTime"`
	LastEvaluation time.Time `json:"lastEvaluation"`
}

RuleGroup has info for rules which are part of a group

type RulesRetriever added in v1.25.3

type RulesRetriever interface {
	RuleGroups() []*rules.Group
	AlertingRules() []*rules.AlertingRule
}

RulesRetriever provides a list of active rules and alerts.

type RuntimeInfo added in v1.25.3

type RuntimeInfo struct {
	StartTime           time.Time `json:"startTime"`
	CWD                 string    `json:"CWD"`
	ReloadConfigSuccess bool      `json:"reloadConfigSuccess"`
	LastConfigTime      time.Time `json:"lastConfigTime"`
	CorruptionCount     int64     `json:"corruptionCount"`
	GoroutineCount      int       `json:"goroutineCount"`
	GOMAXPROCS          int       `json:"GOMAXPROCS"`
	GOGC                string    `json:"GOGC"`
	GODEBUG             string    `json:"GODEBUG"`
	StorageRetention    string    `json:"storageRetention"`
}

RuntimeInfo contains runtime information about Prometheus.

type TSDBAdminStats added in v1.25.3

type TSDBAdminStats interface {
	CleanTombstones() error
	Delete(mint, maxt int64, ms ...*labels.Matcher) error
	Snapshot(dir string, withHead bool) error

	Stats(statsByLabelName string) (*tsdb.Stats, error)
}

TSDBAdminStats defines the tsdb interfaces used by the v1 API for admin operations as well as statistics.

type Target added in v1.5.0

type Target struct {
	// Labels before any processing.
	DiscoveredLabels map[string]string `json:"discoveredLabels"`
	// Any labels that are added to this target and its metrics.
	Labels map[string]string `json:"labels"`

	ScrapePool string `json:"scrapePool"`
	ScrapeURL  string `json:"scrapeUrl"`
	GlobalURL  string `json:"globalUrl"`

	LastError          string              `json:"lastError"`
	LastScrape         time.Time           `json:"lastScrape"`
	LastScrapeDuration float64             `json:"lastScrapeDuration"`
	Health             scrape.TargetHealth `json:"health"`
}

Target has the information for one target.

type TargetDiscovery added in v1.5.0

type TargetDiscovery struct {
	ActiveTargets  []*Target        `json:"activeTargets"`
	DroppedTargets []*DroppedTarget `json:"droppedTargets"`
}

TargetDiscovery has all the active targets.

type TargetRetriever added in v1.25.3

type TargetRetriever interface {
	TargetsActive() map[string][]*scrape.Target
	TargetsDropped() map[string][]*scrape.Target
}

TargetRetriever provides the list of active/dropped targets to scrape or not.

Jump to

Keyboard shortcuts

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