Documentation ¶
Index ¶
- Variables
- type API
- type Alert
- type AlertDiscovery
- type AlertingRule
- type AlertmanagerDiscovery
- type AlertmanagerRetriever
- type AlertmanagerTarget
- type Codec
- type DroppedTarget
- type GlobalURLOptions
- type HeadStats
- type JSONCodec
- type MIMEType
- type PrometheusVersion
- type QueryData
- type QueryOpts
- type RecordingRule
- type Response
- type Rule
- type RuleDiscovery
- type RuleGroup
- type RulesRetriever
- type RuntimeInfo
- type ScrapePoolsDiscovery
- type ScrapePoolsRetriever
- type StatsRenderer
- type TSDBAdminStats
- type TSDBStat
- type TSDBStatus
- type Target
- type TargetDiscovery
- type TargetRetriever
Constants ¶
This section is empty.
Variables ¶
var ( // MinTime is the default timestamp used for the begin of optional time ranges. // Exposed to let downstream projects to reference it. MinTime = time.Unix(math.MinInt64/1000+62135596801, 0).UTC() // MaxTime is the default timestamp used for the end of optional time ranges. // Exposed to let downstream projects to reference it. MaxTime = time.Unix(math.MaxInt64/1000-62135596801, 999999999).UTC() )
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.QueryEngine ExemplarQueryable storage.ExemplarQueryable 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.QueryEngine, q storage.SampleAndChunkQueryable, ap storage.Appendable, eq storage.ExemplarQueryable, spsr func(context.Context) ScrapePoolsRetriever, 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, isAgent bool, corsOrigin *regexp.Regexp, runtimeInfo func() (RuntimeInfo, error), buildInfo *PrometheusVersion, gatherer prometheus.Gatherer, registerer prometheus.Registerer, statsRenderer StatsRenderer, rwEnabled bool, otlpEnabled bool, ) *API
NewAPI returns an initialized API type.
func (*API) ClearCodecs ¶
func (api *API) ClearCodecs()
ClearCodecs removes all available codecs from this API, including the default codec installed by NewAPI.
func (*API) InstallCodec ¶
InstallCodec adds codec to this API's available codecs. Codecs installed first take precedence over codecs installed later when evaluating wildcards in Accept headers. The first installed codec is used as a fallback when the Accept header cannot be satisfied or if there is no Accept header.
type Alert ¶
type Alert struct { Labels labels.Labels `json:"labels"` Annotations labels.Labels `json:"annotations"` State string `json:"state"` ActiveAt *time.Time `json:"activeAt,omitempty"` KeepFiringSince *time.Time `json:"keepFiringSince,omitempty"` Value string `json:"value"` }
Alert has info for an alert.
type AlertDiscovery ¶
type AlertDiscovery struct {
Alerts []*Alert `json:"alerts"`
}
AlertDiscovery has info for all active alerts.
type AlertingRule ¶
type AlertingRule struct { // State can be "pending", "firing", "inactive". State string `json:"state"` Name string `json:"name"` Query string `json:"query"` Duration float64 `json:"duration"` KeepFiringFor float64 `json:"keepFiringFor"` Labels labels.Labels `json:"labels"` Annotations labels.Labels `json:"annotations"` Alerts []*Alert `json:"alerts"` Health rules.RuleHealth `json:"health"` LastError string `json:"lastError,omitempty"` EvaluationTime float64 `json:"evaluationTime"` LastEvaluation time.Time `json:"lastEvaluation"` // Type of an alertingRule is always "alerting". Type string `json:"type"` }
type AlertmanagerDiscovery ¶
type AlertmanagerDiscovery struct { ActiveAlertmanagers []*AlertmanagerTarget `json:"activeAlertmanagers"` DroppedAlertmanagers []*AlertmanagerTarget `json:"droppedAlertmanagers"` }
AlertmanagerDiscovery has all the active Alertmanagers.
type AlertmanagerRetriever ¶
type AlertmanagerRetriever interface { Alertmanagers() []*url.URL DroppedAlertmanagers() []*url.URL }
AlertmanagerRetriever provides a list of all/dropped AlertManager URLs.
type AlertmanagerTarget ¶
type AlertmanagerTarget struct {
URL string `json:"url"`
}
AlertmanagerTarget has info on one AM.
type Codec ¶
type Codec interface { // ContentType returns the MIME time that this Codec emits. ContentType() MIMEType // CanEncode determines if this Codec can encode resp. CanEncode(resp *Response) bool // Encode encodes resp, ready for transmission to an API consumer. Encode(resp *Response) ([]byte, error) }
A Codec performs encoding of API responses.
type DroppedTarget ¶
type DroppedTarget struct { // Labels before any processing. DiscoveredLabels labels.Labels `json:"discoveredLabels"` }
DroppedTarget has the information for one target that was dropped during relabelling.
type GlobalURLOptions ¶
GlobalURLOptions contains fields used for deriving the global URL for local targets.
type HeadStats ¶
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 JSONCodec ¶
type JSONCodec struct{}
JSONCodec is a Codec that encodes API responses as JSON.
func (JSONCodec) ContentType ¶
type PrometheusVersion ¶
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 RecordingRule ¶
type RecordingRule struct { Name string `json:"name"` Query string `json:"query"` Labels labels.Labels `json:"labels,omitempty"` Health rules.RuleHealth `json:"health"` LastError string `json:"lastError,omitempty"` EvaluationTime float64 `json:"evaluationTime"` LastEvaluation time.Time `json:"lastEvaluation"` // Type of a recordingRule is always "recording". Type string `json:"type"` }
type Response ¶
type Response struct { Status status `json:"status"` Data interface{} `json:"data,omitempty"` ErrorType errorType `json:"errorType,omitempty"` Error string `json:"error,omitempty"` Warnings []string `json:"warnings,omitempty"` }
Response contains a response to a HTTP API request.
type RuleDiscovery ¶
type RuleDiscovery struct {
RuleGroups []*RuleGroup `json:"groups"`
}
RuleDiscovery has info for all rules.
type RuleGroup ¶
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"` Limit int `json:"limit"` EvaluationTime float64 `json:"evaluationTime"` LastEvaluation time.Time `json:"lastEvaluation"` }
RuleGroup has info for rules which are part of a group.
type RulesRetriever ¶
type RulesRetriever interface { RuleGroups() []*rules.Group AlertingRules() []*rules.AlertingRule }
RulesRetriever provides a list of active rules and alerts.
type RuntimeInfo ¶
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"` GOMEMLIMIT int64 `json:"GOMEMLIMIT"` GOGC string `json:"GOGC"` GODEBUG string `json:"GODEBUG"` StorageRetention string `json:"storageRetention"` }
RuntimeInfo contains runtime information about Prometheus.
type ScrapePoolsDiscovery ¶
type ScrapePoolsDiscovery struct {
ScrapePools []string `json:"scrapePools"`
}
type ScrapePoolsRetriever ¶
type ScrapePoolsRetriever interface {
ScrapePools() []string
}
ScrapePoolsRetriever provide the list of all scrape pools.
type StatsRenderer ¶
type StatsRenderer func(context.Context, *stats.Statistics, string) stats.QueryStats
type TSDBAdminStats ¶
type TSDBAdminStats interface { CleanTombstones() error Delete(ctx context.Context, mint, maxt int64, ms ...*labels.Matcher) error Snapshot(dir string, withHead bool) error Stats(statsByLabelName string, limit int) (*tsdb.Stats, error) WALReplayStatus() (tsdb.WALReplayStatus, error) }
TSDBAdminStats defines the tsdb interfaces used by the v1 API for admin operations as well as statistics.
type TSDBStat ¶
TSDBStat holds the information about individual cardinality.
func TSDBStatsFromIndexStats ¶
TSDBStatsFromIndexStats converts a index.Stat slice to a TSDBStat slice.
type TSDBStatus ¶
type TSDBStatus struct { HeadStats HeadStats `json:"headStats"` SeriesCountByMetricName []TSDBStat `json:"seriesCountByMetricName"` LabelValueCountByLabelName []TSDBStat `json:"labelValueCountByLabelName"` MemoryInBytesByLabelName []TSDBStat `json:"memoryInBytesByLabelName"` SeriesCountByLabelValuePair []TSDBStat `json:"seriesCountByLabelValuePair"` }
TSDBStatus has information of cardinality statistics from postings.
type Target ¶
type Target struct { // Labels before any processing. DiscoveredLabels labels.Labels `json:"discoveredLabels"` // Any labels that are added to this target and its metrics. Labels labels.Labels `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"` ScrapeInterval string `json:"scrapeInterval"` ScrapeTimeout string `json:"scrapeTimeout"` }
Target has the information for one target.
type TargetDiscovery ¶
type TargetDiscovery struct { ActiveTargets []*Target `json:"activeTargets"` DroppedTargets []*DroppedTarget `json:"droppedTargets"` DroppedTargetCounts map[string]int `json:"droppedTargetCounts"` }
TargetDiscovery has all the active targets.