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

prometheus

package
v1.4.33 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package prometheus provides bounded, normalized reads over Prometheus.

Index

Constants

View Source
const (
	MaximumLimit  = 100
	MaximumOffset = 10_000
)

Variables

View Source
var (
	ErrInvalidArgument  = errors.New("prometheus: invalid argument")
	ErrInvalidConfig    = errors.New("prometheus: invalid configuration")
	ErrResponseTooLarge = errors.New("prometheus: response too large")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ScopeFilter string
	Policy      Policy
	Scrubber    core.Scrubber
	Secrets     []string
	Now         func() time.Time
}

type DiscoveryRequest

type DiscoveryRequest struct {
	Search string
	Offset int
	Limit  int
}

type DiscoveryResult

type DiscoveryResult struct {
	Metrics    []Metric `json:"metrics"`
	Count      int      `json:"count"`
	Offset     int      `json:"offset"`
	Limit      int      `json:"limit"`
	NextOffset int      `json:"next_offset,omitempty"`
	Truncated  bool     `json:"truncated"`
	Truncation []string `json:"truncation,omitempty"`
}

type Metric

type Metric struct {
	Name              string   `json:"name"`
	Type              string   `json:"type,omitempty"`
	Help              string   `json:"help,omitempty"`
	Unit              string   `json:"unit,omitempty"`
	ServiceLabel      string   `json:"service_label,omitempty"`
	Services          []string `json:"services,omitempty"`
	ServicesTruncated bool     `json:"services_truncated,omitempty"`
}

type Policy

type Policy struct {
	MaxLookback   time.Duration
	MinStep       time.Duration
	MaxStep       time.Duration
	MaxSeries     int
	MaxDatapoints int
	MaxBytes      int
	Timeout       time.Duration
}

func ToolPolicy

func ToolPolicy() Policy

type ReadRequest

type ReadRequest struct {
	MetricName string
	Service    string
	Lookback   time.Duration
	Step       time.Duration
}

type ReadResult

type ReadResult struct {
	Series     []Series `json:"series"`
	Count      int      `json:"count"`
	Datapoints int      `json:"datapoints"`
	Step       string   `json:"step"`
	Truncated  bool     `json:"truncated"`
	Truncation []string `json:"truncation,omitempty"`
}

type Reader

type Reader interface {
	MetadataFor(context.Context, string, time.Time, time.Time) (map[string]signalsources.MetricMeta, error)
	LabelValuesLimited(context.Context, string, time.Time, time.Time, int, ...string) ([]string, error)
	QueryRange(context.Context, string, time.Time, time.Time, time.Duration) ([]signalsources.MetricSeries, error)
}

type Sample

type Sample struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
}

type Series

type Series struct {
	Labels  map[string]string `json:"labels"`
	Samples []Sample          `json:"samples"`
}

type Service

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

func NewService

func NewService(reader Reader, config Config) (*Service, error)

func (*Service) Discover

func (service *Service) Discover(ctx context.Context, request DiscoveryRequest) (DiscoveryResult, error)

func (*Service) Read

func (service *Service) Read(ctx context.Context, request ReadRequest) (ReadResult, error)

Jump to

Keyboard shortcuts

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