model

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeMergeFunc

func MakeMergeFunc[T any, PT merge.Mergeable[T]](errorType string,
	newInstance func() PT,
) merge.MergeFunc

MakeMergeFunc creates a MergeFunc for a specific type that implements Merge The returned function accepts a type conforming to Mergeable[T] and merges it into the accumulator

func MakeMergeFuncFromBytes

func MakeMergeFuncFromBytes[T any, PT merge.Mergeable[T]](errorType string,
	newInstance func() PT,
) func(*merge.Accumulator, []byte, int) error

MakeMergeFuncFromBytes creates a MergeFunc that accepts []byte and unmarshals it This is a convenience function for call sites that still have []byte

func MakeRespondFunc

func MakeRespondFunc[T any, PT merge.MarshallerPtr[T]](
	handleResult func(http.ResponseWriter, *http.Request, PT, int),
) merge.RespondFunc

MakeRespondFunc creates a RespondFunc for a specific type that implements MarshallerPtr

func MarshalTSOrVectorWriter

func MarshalTSOrVectorWriter(ts timeseries.Timeseries, _ *timeseries.RequestOptions,
	status int, w io.Writer, isVector bool,
) error

MarshalTSOrVectorWriter writes matrix and vector outputs to the provided io.Writer

func MarshalTimeseries

func MarshalTimeseries(ts timeseries.Timeseries, rlo *timeseries.RequestOptions, status int) ([]byte, error)

MarshalTimeseries converts a Timeseries into a JSON blob

func MarshalTimeseriesWriter

func MarshalTimeseriesWriter(ts timeseries.Timeseries, rlo *timeseries.RequestOptions, status int, w io.Writer) error

MarshalTimeseriesWriter converts a Timeseries into a JSON blob via an io.Writer

func MergeAndWriteAlertsMergeFunc

func MergeAndWriteAlertsMergeFunc() merge.MergeFunc

MergeAndWriteAlertsMergeFunc returns a MergeFunc for WFAlerts

func MergeAndWriteAlertsRespondFunc

func MergeAndWriteAlertsRespondFunc() merge.RespondFunc

MergeAndWriteAlertsRespondFunc returns a RespondFunc for WFAlerts

func MergeAndWriteLabelDataMergeFunc

func MergeAndWriteLabelDataMergeFunc() merge.MergeFunc

MergeAndWriteLabelDataMergeFunc returns a MergeFunc for WFLabelData

func MergeAndWriteLabelDataRespondFunc

func MergeAndWriteLabelDataRespondFunc() merge.RespondFunc

MergeAndWriteLabelDataRespondFunc returns a RespondFunc for WFLabelData

func MergeAndWriteSeriesMergeFunc

func MergeAndWriteSeriesMergeFunc() merge.MergeFunc

MergeAndWriteSeriesMergeFunc returns a MergeFunc for WFSeries

func MergeAndWriteSeriesRespondFunc

func MergeAndWriteSeriesRespondFunc() merge.RespondFunc

MergeAndWriteSeriesRespondFunc returns a RespondFunc for WFSeries

func MergeAndWriteVectorMergeFunc

func MergeAndWriteVectorMergeFunc(unmarshaler timeseries.UnmarshalerFunc) merge.MergeFunc

MergeAndWriteVectorMergeFunc returns a MergeFunc for Vector (timeseries)

func MergeAndWriteVectorRespondFunc

func MergeAndWriteVectorRespondFunc(marshaler timeseries.MarshalWriterFunc) merge.RespondFunc

MergeAndWriteVectorRespondFunc returns a RespondFunc for Vector (timeseries)

func NewModeler

func NewModeler() *timeseries.Modeler

NewModeler returns a collection of modeling functions for prometheus interoperability

func UnmarshalTimeseries

func UnmarshalTimeseries(data []byte, trq *timeseries.TimeRangeQuery) (timeseries.Timeseries, error)

UnmarshalTimeseries converts a JSON blob into a Timeseries

func UnmarshalTimeseriesReader

func UnmarshalTimeseriesReader(reader io.Reader, trq *timeseries.TimeRangeQuery) (timeseries.Timeseries, error)

UnmarshalTimeseriesReader converts a JSON blob into a Timeseries via io.Reader

Types

type Envelope

type Envelope struct {
	Status    string   `json:"status"`
	ErrorType string   `json:"errorType,omitempty"`
	Error     string   `json:"error,omitempty"`
	Warnings  []string `json:"warnings,omitempty"`
}

Envelope represents a Proemtheus Response Envelope Root Type

func (*Envelope) Merge

func (e *Envelope) Merge(e2 *Envelope)

Merge combines the passed envelope data with the subject data

func (*Envelope) StartMarshal

func (e *Envelope) StartMarshal(w io.Writer, httpStatus int)

StartMarshal writes the opening envelope data to the wire; the caller must Close the envelope by writing "}" after writing the data block

type ResultType

type ResultType string
const (
	Scalar ResultType = "scalar"
	Vector ResultType = "vector"
	Matrix ResultType = "matrix"
)

type WFAlert

type WFAlert struct {
	ActiveAt    string            `json:"activeAt,omitempty"`
	Annotations map[string]string `json:"annotations"`
	Labels      map[string]string `json:"labels"`
	State       string            `json:"state"`
	Value       string            `json:"value,omitempty"`
}

WFAlert is the Wire Format Document for the alert object in /alerts responses

func (*WFAlert) CalculateHash

func (a *WFAlert) CalculateHash() uint64

CalculateHash sums the FNV64a hash for the Header and stores it to the Hash member

type WFAlertData

type WFAlertData struct {
	Alerts []WFAlert `json:"alerts"`
}

WFAlertData is the Wire Format Document for the alerts list in /alerts responses

type WFAlerts

type WFAlerts struct {
	*Envelope
	Data *WFAlertData `json:"data"`
}

WFAlerts is the Wire Format Document for the /alerts endpoint

func (*WFAlerts) Merge

func (a *WFAlerts) Merge(results ...*WFAlerts)

Merge merges the passed WFAlerts into the subject WFAlerts by preferring higher-severity states during de-duplication

type WFHistogram added in v2.0.2

type WFHistogram struct {
	Count          string            `json:"count"`
	Sum            string            `json:"sum"`
	Schema         int               `json:"schema"`
	ZeroThreshold  float64           `json:"zero_threshold"`
	ZeroCount      string            `json:"zero_count"`
	NegativeSpans  []WFHistogramSpan `json:"negative_spans,omitempty"`
	NegativeDeltas []int64           `json:"negative_deltas,omitempty"`
	NegativeCounts []string          `json:"negative_counts,omitempty"`
	PositiveSpans  []WFHistogramSpan `json:"positive_spans,omitempty"`
	PositiveDeltas []int64           `json:"positive_deltas,omitempty"`
	PositiveCounts []string          `json:"positive_counts,omitempty"`
	Buckets        [][]any           `json:"buckets,omitempty"`
	CustomValues   []float64         `json:"custom_values,omitempty"`
}

WFHistogram represents a Prometheus native histogram sample in the JSON wire format returned by the Prometheus HTTP API.

type WFHistogramSpan added in v2.0.2

type WFHistogramSpan struct {
	Offset int32  `json:"offset"`
	Length uint32 `json:"length"`
}

WFHistogramSpan represents a span in a native histogram bucket layout.

type WFLabelData

type WFLabelData struct {
	*Envelope
	Data []string `json:"data"`
}

WFLabelData is the Wire Format Document for the /labels and /label/<name>/values endpoints and will work for any other response where Data is a string slice

func (*WFLabelData) Merge

func (ld *WFLabelData) Merge(results ...*WFLabelData)

Merge merges the passed WFSeries into the subject WFSeries

type WFMatrixData

type WFMatrixData struct {
	ResultType    ResultType     `json:"resultType"`
	MatrixResults []*WFResult    `json:"-"`
	ScalarResult  WFResultScalar `json:"-"`
}

WFMatrixData is the data section of the WFD for timeseries responses

func (*WFMatrixData) UnmarshalJSON added in v2.0.2

func (d *WFMatrixData) UnmarshalJSON(data []byte) error

type WFMatrixDocument

type WFMatrixDocument struct {
	*Envelope
	Data WFMatrixData `json:"data"`
}

WFMatrixDocument is the Wire Format Document for prometheus range / timeseries

type WFResult

type WFResult struct {
	Metric     dataset.Tags `json:"metric"`
	Values     [][]any      `json:"values,omitempty"`
	Value      []any        `json:"value,omitempty"`
	Histograms [][]any      `json:"histograms,omitempty"`
	Histogram  []any        `json:"histogram,omitempty"`
}

WFResult is the Result section of the WFD (matrix and vector only)

type WFResultScalar

type WFResultScalar []any

WFResultScalar is the Result section of the WFD (scalar only)

type WFSeries

type WFSeries struct {
	*Envelope
	Data []WFSeriesData `json:"data"`
}

WFSeries is the Wire Format Document for the /series endpoint

func (*WFSeries) Merge

func (s *WFSeries) Merge(results ...*WFSeries)

Merge merges the passed WFSeries into the subject WFSeries

type WFSeriesData

type WFSeriesData map[string]string

WFSeriesData is a single label set as returned by Prometheus /api/v1/series. Prometheus series carry an arbitrary label set (e.g. shard, region, cluster), so a fixed struct would silently drop data on round-trip and collapse otherwise-distinct series during merge.

Jump to

Keyboard shortcuts

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