prometheus

package
v1.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataValueVec

func DataValueVec(name string, label []string) *prometheus.GaugeVec

DataValueVec implements a new prometheus metrics that includes label.

Types

type MatrixResult

type MatrixResult struct {
	Metric string `json:"metric"`
	//Labels []MetricLabel  `json:"labels"`
	Values []MetricValues `json:"values"`
}

MatrixResult obtains the matrix result y from the prometheus query.

type MetricLabel

type MetricLabel struct {
	Label string
	Value string
}

A MetricLabel is a prometheus metric label structure.

type MetricValues

type MetricValues struct {
	Timestamp int64
	Value     float64
}

MetricValues gets the metric value from the prometheus query.

type MetricsInterface

type MetricsInterface interface {
	Push(context.Context, PushMetrics, string) error
	QueryRange(context.Context, api.Client, string, v1.Range, ...Option) ([]MatrixResult, error)
}

MetricsInterface is the interface that implements prometheus push metrics and range queries.

type Option

type Option func(c *apiOptions)

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout can be used to provide an optional query evaluation timeout for Query and QueryRange. https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries

type PromMetrics

type PromMetrics struct {
	Values []string // values of metrics label
	Data   float64  // metrics value
}

PromMetrics is a prometheus metrics values.

type Prometheus

type Prometheus struct{}

Prometheus implements MetricsInterface.

func (*Prometheus) Push

func (p *Prometheus) Push(ctx context.Context, pm PushMetrics, addr string) error

Push implements a new prometheus metrics pushed to PushGateway.

func (*Prometheus) QueryRange

func (p *Prometheus) QueryRange(ctx context.Context, client api.Client, query string, r v1.Range, opts ...Option) (res []MatrixResult, err error)

QueryRange implements prometheus range query.

type PushMetrics

type PushMetrics struct {
	Name    string        // description of metrics name
	Label   []string      // description of metrics label
	Metrics []PromMetrics // values of metrics label and metrics value
}

PushMetrics implements a new Prometheus metrics.

type ResultT

type ResultT interface {
	MetricValues | []MatrixResult | []VectorResult
}

type RewriteAPI

type RewriteAPI interface {
	// QueryRange performs a query for the given range.
	QueryRange(ctx context.Context, query string, r v1.Range, opts ...Option) ([]byte, Warnings, error)
}

RewriteAPI provides bindings for refactoring the v1 API for Prometheus.

func NewAPI

func NewAPI(c api.Client) RewriteAPI

NewAPI returns a new API for the client.

It is safe to use the returned API from multiple goroutines.

type VectorResult

type VectorResult struct {
	Metric string       `json:"metric"`
	Values MetricValues `json:"values"`
}

type Warnings

type Warnings []string

Warnings is an array of non-critical errors

Jump to

Keyboard shortcuts

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