Documentation
¶
Index ¶
- Constants
- Variables
- func CompareMetricTimeRanges(a, b MetricTimeRange) int
- func ExpandRangesEnd(src MetricTimeRanges, step time.Duration)
- func HasGapBetween(a, b time.Time, gaps []TimeRange) bool
- func IsQueryTooExpensive(err error) bool
- func IsUnavailableError(err error) bool
- func MetricToLabels(m model.Metric) labels.Labels
- func RegisterMetrics(reg *prometheus.Registry)
- type APIError
- type BuildInfoResult
- type ConfigResult
- type ConfigSectionGlobal
- type FailoverGroup
- func (fg *FailoverGroup) BuildInfo(ctx context.Context) *Request[*BuildInfoResult]
- func (fg *FailoverGroup) CleanCache()
- func (fg *FailoverGroup) Close(reg *prometheus.Registry)
- func (fg *FailoverGroup) Config(ctx context.Context, cacheTTL time.Duration) *Request[*ConfigResult]
- func (fg *FailoverGroup) DisableCheck(api, s string)
- func (fg *FailoverGroup) Exclude() []string
- func (fg *FailoverGroup) Flags(ctx context.Context) *Request[*FlagsResult]
- func (fg *FailoverGroup) GetDisabledChecks() map[string][]string
- func (fg *FailoverGroup) Include() []string
- func (fg *FailoverGroup) IsEnabledForPath(path string) bool
- func (fg *FailoverGroup) MergeUpstreams(src *FailoverGroup)
- func (fg *FailoverGroup) Metadata(ctx context.Context, metric string) *Request[*MetadataResult]
- func (fg *FailoverGroup) Name() string
- func (fg *FailoverGroup) Query(ctx context.Context, expr string) *Request[*QueryResult]
- func (fg *FailoverGroup) RangeQuery(ctx context.Context, expr string, params RangeQueryTimes) *Request[*RangeQueryResult]
- func (fg *FailoverGroup) ServerCount() int
- func (fg *FailoverGroup) StartWorkers(reg *prometheus.Registry)
- func (fg *FailoverGroup) Tags() []string
- func (fg *FailoverGroup) URI() string
- func (fg *FailoverGroup) UptimeMetric() string
- type FailoverGroupError
- type FlagsResult
- type MetadataResult
- type MetricTimeRange
- type MetricTimeRanges
- type Prometheus
- func (prom *Prometheus) BuildInfo(ctx context.Context) (*BuildInfoResult, error)
- func (prom *Prometheus) Config(ctx context.Context, cacheTTL time.Duration) (*ConfigResult, error)
- func (prom *Prometheus) Flags(ctx context.Context) (*FlagsResult, error)
- func (prom *Prometheus) Metadata(ctx context.Context, metric string) (*MetadataResult, error)
- func (prom *Prometheus) Query(ctx context.Context, expr string) (*QueryResult, error)
- func (prom *Prometheus) RangeQuery(ctx context.Context, expr string, params RangeQueryTimes) (*RangeQueryResult, error)
- func (prom *Prometheus) SafeURI() string
- func (prom *Prometheus) StartWorkers()
- type PrometheusBuildInfoResponse
- type PrometheusConfig
- type PrometheusConfigResponse
- type PrometheusContextKey
- type PrometheusFlagsResponse
- type PrometheusMetadataResponse
- type PrometheusQueryResponse
- type PrometheusQuerySample
- type PrometheusRangeQueryResponse
- type PrometheusRangeQuerySample
- type PrometheusResponse
- type QueryError
- type QueryResult
- type QuerySamples
- type QueryStats
- type QueryTimings
- type RangeQueryResult
- type RangeQueryTimes
- type RelativeRange
- type Request
- type Sample
- type SampleLabels
- type SampleTimestampValue
- type SeriesTimeRanges
- type TimeRange
Constants ¶
const ( ErrUnknown v1.ErrorType = "unknown" ErrJSONStream v1.ErrorType = "json_stream" ErrAPIUnsupported v1.ErrorType = "unsupported" )
const (
APIPathBuildInfo = "/api/v1/status/buildinfo"
)
const (
APIPathConfig = "/api/v1/status/config"
)
const (
APIPathFlags = "/api/v1/status/flags"
)
const (
APIPathMetadata = "/api/v1/metadata"
)
const (
APIPathQuery = "/api/v1/query"
)
const (
APIPathQueryRange = "/api/v1/query_range"
)
const (
AllPrometheusServers = PrometheusContextKey("allServers")
)
Variables ¶
var ErrUnsupported = errors.New("unsupported API")
Functions ¶
func CompareMetricTimeRanges ¶ added in v0.76.0
func CompareMetricTimeRanges(a, b MetricTimeRange) int
CompareMetricTimeRanges sorts by labels first, then by start time.
func ExpandRangesEnd ¶ added in v0.42.0
func ExpandRangesEnd(src MetricTimeRanges, step time.Duration)
ExpandRangesEnd extends each range's end by step-1s to cover the full sample interval.
func HasGapBetween ¶ added in v0.81.0
HasGapBetween returns true if any gap from FindGaps overlaps the interval [a, b].
func IsQueryTooExpensive ¶ added in v0.43.0
func IsUnavailableError ¶ added in v0.13.0
func MetricToLabels ¶ added in v0.31.0
MetricToLabels converts a Prometheus model.Metric to a labels.Labels.
func RegisterMetrics ¶ added in v0.11.0
func RegisterMetrics(reg *prometheus.Registry)
Types ¶
type APIError ¶ added in v0.15.2
type BuildInfoResult ¶ added in v0.80.0
type ConfigResult ¶ added in v0.14.0
type ConfigResult struct {
URI string
Config PrometheusConfig
}
type ConfigSectionGlobal ¶
type FailoverGroup ¶ added in v0.13.0
type FailoverGroup struct {
// contains filtered or unexported fields
}
func NewFailoverGroup ¶ added in v0.13.0
func NewFailoverGroup(name, uri string, servers []*Prometheus, strictErrors bool, uptimeMetric string, include, exclude []*regexp.Regexp, tags []string) *FailoverGroup
func (*FailoverGroup) BuildInfo ¶ added in v0.80.0
func (fg *FailoverGroup) BuildInfo( ctx context.Context, ) *Request[*BuildInfoResult]
func (*FailoverGroup) CleanCache ¶ added in v0.28.4
func (fg *FailoverGroup) CleanCache()
func (*FailoverGroup) Close ¶ added in v0.22.0
func (fg *FailoverGroup) Close(reg *prometheus.Registry)
func (*FailoverGroup) Config ¶ added in v0.13.0
func (fg *FailoverGroup) Config( ctx context.Context, cacheTTL time.Duration, ) *Request[*ConfigResult]
func (*FailoverGroup) DisableCheck ¶ added in v0.70.0
func (fg *FailoverGroup) DisableCheck(api, s string)
func (*FailoverGroup) Exclude ¶ added in v0.48.1
func (fg *FailoverGroup) Exclude() []string
func (*FailoverGroup) Flags ¶ added in v0.26.0
func (fg *FailoverGroup) Flags( ctx context.Context, ) *Request[*FlagsResult]
func (*FailoverGroup) GetDisabledChecks ¶ added in v0.70.0
func (fg *FailoverGroup) GetDisabledChecks() map[string][]string
func (*FailoverGroup) Include ¶ added in v0.48.1
func (fg *FailoverGroup) Include() []string
func (*FailoverGroup) IsEnabledForPath ¶ added in v0.34.0
func (fg *FailoverGroup) IsEnabledForPath(path string) bool
func (*FailoverGroup) MergeUpstreams ¶ added in v0.48.0
func (fg *FailoverGroup) MergeUpstreams(src *FailoverGroup)
func (*FailoverGroup) Metadata ¶ added in v0.21.0
func (fg *FailoverGroup) Metadata( ctx context.Context, metric string, ) *Request[*MetadataResult]
func (*FailoverGroup) Name ¶ added in v0.13.0
func (fg *FailoverGroup) Name() string
func (*FailoverGroup) Query ¶ added in v0.13.0
func (fg *FailoverGroup) Query( ctx context.Context, expr string, ) *Request[*QueryResult]
func (*FailoverGroup) RangeQuery ¶ added in v0.13.0
func (fg *FailoverGroup) RangeQuery( ctx context.Context, expr string, params RangeQueryTimes, ) *Request[*RangeQueryResult]
func (*FailoverGroup) ServerCount ¶ added in v0.48.0
func (fg *FailoverGroup) ServerCount() int
func (*FailoverGroup) StartWorkers ¶ added in v0.22.0
func (fg *FailoverGroup) StartWorkers(reg *prometheus.Registry)
func (*FailoverGroup) Tags ¶ added in v0.38.0
func (fg *FailoverGroup) Tags() []string
func (*FailoverGroup) URI ¶ added in v0.60.0
func (fg *FailoverGroup) URI() string
func (*FailoverGroup) UptimeMetric ¶ added in v0.33.0
func (fg *FailoverGroup) UptimeMetric() string
type FailoverGroupError ¶ added in v0.14.0
type FailoverGroupError struct {
// contains filtered or unexported fields
}
func (*FailoverGroupError) Error ¶ added in v0.14.0
func (e *FailoverGroupError) Error() string
func (*FailoverGroupError) IsStrict ¶ added in v0.14.0
func (e *FailoverGroupError) IsStrict() bool
func (*FailoverGroupError) URI ¶ added in v0.14.0
func (e *FailoverGroupError) URI() string
func (*FailoverGroupError) Unwrap ¶ added in v0.14.0
func (e *FailoverGroupError) Unwrap() error
type FlagsResult ¶ added in v0.26.0
type FlagsResult struct {
Flags v1.FlagsResult
URI string
}
type MetadataResult ¶ added in v0.21.0
type MetricTimeRange ¶ added in v0.31.0
type MetricTimeRanges ¶ added in v0.31.0
type MetricTimeRanges []MetricTimeRange
func AppendSampleToRanges ¶ added in v0.31.0
func AppendSampleToRanges(dst MetricTimeRanges, ls labels.Labels, vals []model.SamplePair, step time.Duration) MetricTimeRanges
AppendSampleToRanges adds sample timestamps to existing ranges or creates new ones. Samples within one step of an existing range extend it; otherwise a new range is created.
func MergeRanges ¶ added in v0.31.0
func MergeRanges(source MetricTimeRanges, step time.Duration) (MetricTimeRanges, bool)
MergeRanges merges overlapping or adjacent (within one step) ranges. Sorts the source slice as a side effect.
func MergeRangesWithoutGaps ¶ added in v0.81.0
func MergeRangesWithoutGaps( ranges MetricTimeRanges, gaps []TimeRange, ) MetricTimeRanges
MergeRangesWithoutGaps merges consecutive same-fingerprint ranges unless a gap (from FindGaps) separates them. Ranges separated only by periods where the source was down get merged because the condition might have been true.
func (MetricTimeRanges) String ¶ added in v0.43.0
func (mtr MetricTimeRanges) String() string
type Prometheus ¶ added in v0.7.0
type Prometheus struct {
// contains filtered or unexported fields
}
func NewPrometheus ¶ added in v0.7.0
func (*Prometheus) BuildInfo ¶ added in v0.80.0
func (prom *Prometheus) BuildInfo(ctx context.Context) (*BuildInfoResult, error)
func (*Prometheus) Config ¶ added in v0.7.0
func (prom *Prometheus) Config(ctx context.Context, cacheTTL time.Duration) (*ConfigResult, error)
func (*Prometheus) Flags ¶ added in v0.26.0
func (prom *Prometheus) Flags(ctx context.Context) (*FlagsResult, error)
func (*Prometheus) Metadata ¶ added in v0.21.0
func (prom *Prometheus) Metadata(ctx context.Context, metric string) (*MetadataResult, error)
func (*Prometheus) Query ¶ added in v0.7.0
func (prom *Prometheus) Query(ctx context.Context, expr string) (*QueryResult, error)
func (*Prometheus) RangeQuery ¶ added in v0.7.0
func (prom *Prometheus) RangeQuery(ctx context.Context, expr string, params RangeQueryTimes) (*RangeQueryResult, error)
func (*Prometheus) SafeURI ¶ added in v0.48.0
func (prom *Prometheus) SafeURI() string
func (*Prometheus) StartWorkers ¶ added in v0.22.0
func (prom *Prometheus) StartWorkers()
type PrometheusBuildInfoResponse ¶ added in v0.80.0
type PrometheusBuildInfoResponse struct {
Data v1.BuildinfoResult `json:"data"`
PrometheusResponse
}
type PrometheusConfig ¶
type PrometheusConfig struct {
RuleFiles []string `yaml:"rule_files"`
Global ConfigSectionGlobal `yaml:"global"`
}
type PrometheusConfigResponse ¶ added in v0.80.0
type PrometheusConfigResponse struct {
PrometheusResponse
Data v1.ConfigResult `json:"data"`
}
type PrometheusContextKey ¶ added in v0.49.0
type PrometheusContextKey string
type PrometheusFlagsResponse ¶ added in v0.80.0
type PrometheusFlagsResponse struct {
Data v1.FlagsResult `json:"data"`
PrometheusResponse
}
type PrometheusMetadataResponse ¶ added in v0.80.0
type PrometheusMetadataResponse struct {
Data map[string][]v1.Metadata `json:"data"`
PrometheusResponse
}
type PrometheusQueryResponse ¶ added in v0.80.0
type PrometheusQueryResponse struct {
PrometheusResponse
Data struct {
ResultType string `json:"resultType"`
Result []PrometheusQuerySample `json:"result"`
Stats QueryStats `json:"stats"`
} `json:"data"`
}
type PrometheusQuerySample ¶ added in v0.80.0
type PrometheusQuerySample struct {
Labels SampleLabels `json:"metric"`
Value SampleTimestampValue `json:"value"`
}
type PrometheusRangeQueryResponse ¶ added in v0.80.0
type PrometheusRangeQueryResponse struct {
PrometheusResponse
Data struct {
ResultType string `json:"resultType"`
Result []PrometheusRangeQuerySample `json:"result"`
Stats QueryStats `json:"stats"`
} `json:"data"`
}
type PrometheusRangeQuerySample ¶ added in v0.80.0
type PrometheusRangeQuerySample struct {
Labels map[string]string `json:"metric"`
Values []SampleTimestampValue `json:"values"`
}
type PrometheusResponse ¶ added in v0.80.0
type QueryError ¶ added in v0.22.0
type QueryError struct {
// contains filtered or unexported fields
}
func (QueryError) Error ¶ added in v0.22.0
func (qe QueryError) Error() string
func (QueryError) Unwrap ¶ added in v0.22.0
func (qe QueryError) Unwrap() error
type QueryResult ¶
type QueryResult struct {
URI string
Series []Sample
Stats QueryStats
}
type QuerySamples ¶ added in v0.45.0
type QueryStats ¶ added in v0.45.0
type QueryStats struct {
Timings QueryTimings `json:"timings"`
Samples QuerySamples `json:"samples"`
}
type QueryTimings ¶ added in v0.45.0
type QueryTimings struct {
EvalTotalTime float64 `json:"evalTotalTime"`
ResultSortTime float64 `json:"resultSortTime"`
QueryPreparationTime float64 `json:"queryPreparationTime"`
InnerEvalTime float64 `json:"innerEvalTime"`
ExecQueueTime float64 `json:"execQueueTime"`
ExecTotalTime float64 `json:"execTotalTime"`
}
type RangeQueryResult ¶
type RangeQueryResult struct {
URI string
Series SeriesTimeRanges
Stats QueryStats
}
type RangeQueryTimes ¶ added in v0.22.1
type RelativeRange ¶ added in v0.22.1
type RelativeRange struct {
// contains filtered or unexported fields
}
func NewRelativeRange ¶ added in v0.22.1
func NewRelativeRange(lookback, step time.Duration) RelativeRange
func (RelativeRange) Dur ¶ added in v0.22.1
func (rr RelativeRange) Dur() time.Duration
func (RelativeRange) End ¶ added in v0.22.1
func (rr RelativeRange) End() time.Time
func (RelativeRange) Start ¶ added in v0.22.1
func (rr RelativeRange) Start() time.Time
func (RelativeRange) Step ¶ added in v0.22.1
func (rr RelativeRange) Step() time.Duration
func (RelativeRange) String ¶ added in v0.22.1
func (rr RelativeRange) String() string
type Request ¶ added in v0.84.0
type Request[T any] struct { // contains filtered or unexported fields }
type SampleLabels ¶ added in v0.80.0
func (*SampleLabels) UnmarshalJSONFrom ¶ added in v0.80.0
func (s *SampleLabels) UnmarshalJSONFrom(dec *jsontext.Decoder) (err error)
type SampleTimestampValue ¶ added in v0.80.0
type SampleTimestampValue struct {
Timestamp model.Time
Value model.SampleValue
}
func (*SampleTimestampValue) UnmarshalJSONFrom ¶ added in v0.80.0
func (s *SampleTimestampValue) UnmarshalJSONFrom(dec *jsontext.Decoder) (err error)
type SeriesTimeRanges ¶ added in v0.31.0
type SeriesTimeRanges struct {
From time.Time
Until time.Time
Ranges MetricTimeRanges
Gaps []TimeRange
Step time.Duration
}
func (*SeriesTimeRanges) FindGaps ¶ added in v0.31.0
func (str *SeriesTimeRanges) FindGaps(baseline SeriesTimeRanges, from, until time.Time)
FindGaps records time periods where str has no data but baseline does. If baseline has data at a timestamp but str doesn't, the metric was genuinely absent. If baseline also has no data, the source was down and we can't tell.