promapi

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrUnknown    v1.ErrorType = "unknown"
	ErrJSONStream v1.ErrorType = "json_stream"
)
View Source
const (
	AllPrometheusServers = PrometheusContextKey("allServers")
)

Variables

This section is empty.

Functions

func ExpandRangesEnd added in v0.42.0

func ExpandRangesEnd(src MetricTimeRanges, step time.Duration)

func IsQueryTooExpensive added in v0.43.0

func IsQueryTooExpensive(err error) bool

func IsUnavailableError added in v0.13.0

func IsUnavailableError(err error) bool

func MetricToLabels added in v0.31.0

func MetricToLabels(m model.Metric) labels.Labels

func RegisterMetrics added in v0.11.0

func RegisterMetrics(reg *prometheus.Registry)

Types

type APIError added in v0.15.2

type APIError struct {
	Status    string       `json:"status"`
	ErrorType v1.ErrorType `json:"errorType"`
	Err       string       `json:"error"`
}

func (APIError) Error added in v0.15.2

func (e APIError) Error() string

type ConfigResult added in v0.14.0

type ConfigResult struct {
	URI       string
	PublicURI string
	Config    PrometheusConfig
}

type ConfigSectionGlobal

type ConfigSectionGlobal struct {
	ExternalLabels     map[string]string `yaml:"external_labels"`
	ScrapeInterval     time.Duration     `yaml:"scrape_interval"`
	ScrapeTimeout      time.Duration     `yaml:"scrape_timeout"`
	EvaluationInterval time.Duration     `yaml:"evaluation_interval"`
}

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, publicURI string, servers []*Prometheus, strictErrors bool, uptimeMetric string, include, exclude []*regexp.Regexp, tags []string) *FailoverGroup

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) (cfg *ConfigResult, err error)

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) (flags *FlagsResult, err error)

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) (metadata *MetadataResult, err error)

func (*FailoverGroup) Name added in v0.13.0

func (fg *FailoverGroup) Name() string

func (*FailoverGroup) PublicURI added in v0.49.0

func (fg *FailoverGroup) PublicURI() string

func (*FailoverGroup) Query added in v0.13.0

func (fg *FailoverGroup) Query(ctx context.Context, expr string) (qr *QueryResult, err error)

func (*FailoverGroup) RangeQuery added in v0.13.0

func (fg *FailoverGroup) RangeQuery(ctx context.Context, expr string, params RangeQueryTimes) (rqr *RangeQueryResult, err error)

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) 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
	PublicURI string
}

type MetadataResult added in v0.21.0

type MetadataResult struct {
	URI       string
	PublicURI string
	Metadata  []v1.Metadata
}

type MetricTimeRange added in v0.31.0

type MetricTimeRange struct {
	Start       time.Time
	End         time.Time
	Labels      labels.Labels
	Fingerprint uint64
}

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

func MergeRanges added in v0.31.0

func MergeRanges(source MetricTimeRanges, step time.Duration) (MetricTimeRanges, bool)

merge [t1:t2] [t2:t3] together.

func (MetricTimeRanges) Len added in v0.31.0

func (mtr MetricTimeRanges) Len() int

func (MetricTimeRanges) Less added in v0.31.0

func (mtr MetricTimeRanges) Less(i, j int) bool

func (MetricTimeRanges) String added in v0.43.0

func (mtr MetricTimeRanges) String() string

func (MetricTimeRanges) Swap added in v0.31.0

func (mtr MetricTimeRanges) Swap(i, j int)

type Prometheus added in v0.7.0

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

func NewPrometheus added in v0.7.0

func NewPrometheus(name, uri, publicURI string, headers map[string]string, timeout time.Duration, concurrency, rl int, tlsConf *tls.Config) *Prometheus

func (*Prometheus) Close added in v0.22.0

func (prom *Prometheus) Close()

func (*Prometheus) Config added in v0.7.0

func (p *Prometheus) Config(ctx context.Context, cacheTTL time.Duration) (*ConfigResult, error)

func (*Prometheus) Flags added in v0.26.0

func (p *Prometheus) Flags(ctx context.Context) (*FlagsResult, error)

func (*Prometheus) Metadata added in v0.21.0

func (p *Prometheus) Metadata(ctx context.Context, metric string) (*MetadataResult, error)

func (*Prometheus) Query added in v0.7.0

func (p *Prometheus) Query(ctx context.Context, expr string) (*QueryResult, error)

func (*Prometheus) RangeQuery added in v0.7.0

func (p *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 PrometheusConfig

type PrometheusConfig struct {
	RuleFiles []string            `yaml:"rule_files"`
	Global    ConfigSectionGlobal `yaml:"global"`
}

type PrometheusContextKey added in v0.49.0

type PrometheusContextKey string

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
	PublicURI string
	Series    []Sample
	Stats     QueryStats
}

type QuerySamples added in v0.45.0

type QuerySamples struct {
	TotalQueryableSamples int `json:"totalQueryableSamples"`
	PeakSamples           int `json:"peakSamples"`
}

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
	PublicURI string
	Series    SeriesTimeRanges
	Stats     QueryStats
}

type RangeQueryTimes added in v0.22.1

type RangeQueryTimes interface {
	Start() time.Time
	End() time.Time
	Dur() time.Duration
	Step() time.Duration
	String() string
}

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 Sample added in v0.33.0

type Sample struct {
	Labels labels.Labels
	Value  float64
}

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)

type TimeRange added in v0.31.0

type TimeRange struct {
	Start time.Time
	End   time.Time
}

func Overlaps added in v0.31.1

func Overlaps(a, b MetricTimeRange, step time.Duration) (c TimeRange, ok bool)

Jump to

Keyboard shortcuts

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