prom

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Label

type Label struct {
	Name  string
	Value string
}

A Label is a Name and Value pair that provides additional information about the metric. It is metadata for the metric. For example, Kubernetes pod metrics always have 'namespace' label that represents which namespace the pod belongs to.

func (*Label) String

func (l *Label) String() string

type PrometheusQuery

type PrometheusQuery struct {
	Port   int
	Host   string
	Client *http.Client
}

PrometheusQuery represents parameters for querying Prometheus

func NewPrometheusQuery

func NewPrometheusQuery(host string, port int, client *http.Client) PrometheusQuery

NewPrometheusQuery create a NewPrometheusQuery

func (PrometheusQuery) Fetch

func (q PrometheusQuery) Fetch(query string) (*VectorQueryResponse, error)

Fetch queries aggregated stats

func (PrometheusQuery) Query

func (q PrometheusQuery) Query(query string, time time.Time) ([]*TimeSeries, error)

TODO(xieydd) Refactor PrometheusQuery Query queries Prometheus with given query string and time

type PrometheusQueryFetcher

type PrometheusQueryFetcher interface {
	Fetch(query string) (*VectorQueryResponse, error)
}

type Sample

type Sample struct {
	Value     float64
	Timestamp int64
}

Sample pairs a Value with a Timestamp.

func (*Sample) String

func (s *Sample) String() string

type TimeSeries

type TimeSeries struct {
	// A collection of Labels that are attached by monitoring system as metadata
	// for the metrics, which are known as dimensions.
	Labels []Label
	// A collection of Samples in chronological order.
	Samples []Sample
}

Ref: https://github.com/gocrane/crane/blob/9aaeb2aa9cf9f43a31842b4663e48bc47ac05f17/pkg/common/types.go TimeSeries is a stream of samples that belong to a metric with a set of labels

func NewTimeSeries

func NewTimeSeries() *TimeSeries

func (*TimeSeries) AppendLabel

func (ts *TimeSeries) AppendLabel(key, val string)

func (*TimeSeries) AppendSample

func (ts *TimeSeries) AppendSample(timestamp int64, val float64)

func (*TimeSeries) SetLabels

func (ts *TimeSeries) SetLabels(labels []Label)

func (*TimeSeries) SetSamples

func (ts *TimeSeries) SetSamples(samples []Sample)

func (*TimeSeries) SortSampleAsc

func (ts *TimeSeries) SortSampleAsc()

type VectorQueryResponse

type VectorQueryResponse struct {
	Data struct {
		Result []struct {
			Metric struct {
				InferenceName string `json:"inference_name"`
			}
			Value []interface{} `json:"value"`
		}
	}
}

Jump to

Keyboard shortcuts

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