prometheus

package
v0.5.1-0...-faa3f61 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 12 Imported by: 122

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RequestLatencyBucketsSeconds represents latency buckets to record (seconds)
	RequestLatencyBucketsSeconds = append(append(append(
		prometheus.LinearBuckets(0.01, 0.01, 5),
		prometheus.LinearBuckets(0.1, 0.1, 5)...),
		prometheus.LinearBuckets(1, 1, 5)...),
		prometheus.LinearBuckets(10, 10, 5)...)

	// ResponseSizeBuckets represents response size buckets (bytes)
	ResponseSizeBuckets = append(append(append(
		prometheus.LinearBuckets(100, 100, 5),
		prometheus.LinearBuckets(1000, 1000, 5)...),
		prometheus.LinearBuckets(10000, 10000, 5)...),
		prometheus.LinearBuckets(1000000, 1000000, 5)...)
)

Functions

func ClientWithTelemetry

func ClientWithTelemetry(name string, wt func(http.RoundTripper) http.RoundTripper) func(http.RoundTripper) http.RoundTripper

ClientWithTelemetry instruments the HTTP client with prometheus

func InstrumentErrorCounter

func InstrumentErrorCounter(counter *prometheus.CounterVec, next http.RoundTripper) promhttp.RoundTripperFunc

func NewGrpcServer

func NewGrpcServer(opt ...grpc.ServerOption) *grpc.Server

NewGrpcServer returns a grpc server pre-configured with prometheus interceptors and oc-grpc handler

func SetClientBurst

func SetClientBurst(name string, burst int)

func SetClientQPS

func SetClientQPS(name string, qps float32)

func WithTelemetry

func WithTelemetry(handler http.Handler) http.Handler

WithTelemetry instruments the HTTP server with prometheus and oc-http handler

Types

type MockProm

type MockProm struct {
	Res             model.Value
	QueriesExecuted []string // expose the queries our Mock Prometheus receives, to test query generation
	// contains filtered or unexported fields
}

MockProm satisfies the promv1.API interface for testing. TODO: move this into something shared under /controller, or into /pkg

func (*MockProm) AlertManagers

func (m *MockProm) AlertManagers(ctx context.Context) (promv1.AlertManagersResult, error)

AlertManagers returns an overview of the current state of the Prometheus alert manager discovery.

func (*MockProm) Alerts

func (m *MockProm) Alerts(ctx context.Context) (promv1.AlertsResult, error)

Alerts returns a list of all active alerts.

func (*MockProm) Buildinfo

func (m *MockProm) Buildinfo(ctx context.Context) (promv1.BuildinfoResult, error)

Buildinfo returns various build information properties about the Prometheus server

func (*MockProm) CleanTombstones

func (m *MockProm) CleanTombstones(ctx context.Context) error

CleanTombstones removes the deleted data from disk and cleans up the existing tombstones.

func (*MockProm) Config

func (m *MockProm) Config(ctx context.Context) (promv1.ConfigResult, error)

Config returns the current Prometheus configuration.

func (*MockProm) DeleteSeries

func (m *MockProm) DeleteSeries(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) error

DeleteSeries deletes data for a selection of series in a time range.

func (*MockProm) Flags

func (m *MockProm) Flags(ctx context.Context) (promv1.FlagsResult, error)

Flags returns the flag values that Prometheus was launched with.

func (*MockProm) LabelNames

func (m *MockProm) LabelNames(ctx context.Context, matches []string, startTime time.Time, endTime time.Time, opts ...promv1.Option) ([]string, promv1.Warnings, error)

LabelNames returns the unique label names present in the block in sorted order by given time range and matchers.

func (*MockProm) LabelValues

func (m *MockProm) LabelValues(ctx context.Context, label string, matches []string, startTime time.Time, endTime time.Time, opts ...promv1.Option) (model.LabelValues, promv1.Warnings, error)

LabelValues performs a query for the values of the given label, time range and matchers.

func (*MockProm) Metadata

func (m *MockProm) Metadata(ctx context.Context, metric string, limit string) (map[string][]promv1.Metadata, error)

Metadata returns the metadata of the specified metric

func (*MockProm) Query

func (m *MockProm) Query(ctx context.Context, query string, ts time.Time, opts ...promv1.Option) (model.Value, promv1.Warnings, error)

Query performs a query for the given time.

func (*MockProm) QueryExemplars

func (m *MockProm) QueryExemplars(ctx context.Context, query string, startTime time.Time, endTime time.Time) ([]promv1.ExemplarQueryResult, error)

QueryExemplars performs a query for exemplars by the given query and time range.

func (*MockProm) QueryRange

func (m *MockProm) QueryRange(ctx context.Context, query string, r promv1.Range, opts ...promv1.Option) (model.Value, promv1.Warnings, error)

QueryRange performs a query for the given range.

func (*MockProm) Rules

func (m *MockProm) Rules(ctx context.Context) (promv1.RulesResult, error)

Rules returns a list of alerting and recording rules that are currently loaded.

func (*MockProm) Runtimeinfo

func (m *MockProm) Runtimeinfo(ctx context.Context) (promv1.RuntimeinfoResult, error)

Runtimeinfo returns the runtime info about Prometheus

func (*MockProm) Series

func (m *MockProm) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time, opts ...promv1.Option) ([]model.LabelSet, promv1.Warnings, error)

Series finds series by label matchers.

func (*MockProm) Snapshot

func (m *MockProm) Snapshot(ctx context.Context, skipHead bool) (promv1.SnapshotResult, error)

Snapshot creates a snapshot of all current data into snapshots/<datetime>-<rand> under the TSDB's data directory and returns the directory as response.

func (*MockProm) TSDB

func (m *MockProm) TSDB(ctx context.Context, opts ...promv1.Option) (promv1.TSDBResult, error)

TSDB returns the cardinality statistics.

func (*MockProm) Targets

func (m *MockProm) Targets(ctx context.Context) (promv1.TargetsResult, error)

Targets returns an overview of the current state of the Prometheus target discovery.

func (*MockProm) TargetsMetadata

func (m *MockProm) TargetsMetadata(ctx context.Context, matchTarget string, metric string, limit string) ([]promv1.MetricMetadata, error)

TargetsMetadata returns metadata about metrics currently scraped by the target.

func (*MockProm) WalReplay

func (m *MockProm) WalReplay(ctx context.Context) (promv1.WalReplayStatus, error)

WalReplay returns the current replay status of the wal.

Jump to

Keyboard shortcuts

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