prometheus

package
v0.0.0-...-f0d3a47 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelCluster = 1 << iota
	LevelNode
	LevelWorkspace
	LevelNamespace
	LevelWorkload
	LevelPod
	LevelContainer
	LevelPVC
	LevelComponent
)
View Source
const (
	MetricTypeMatrix = "matrix"
	MetricTypeVector = "vector"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterOption

type ClusterOption struct{}

func (ClusterOption) Apply

func (_ ClusterOption) Apply(o *QueryOptions)

type ComponentOption

type ComponentOption struct{}

func (ComponentOption) Apply

func (_ ComponentOption) Apply(o *QueryOptions)

type ContainerOption

type ContainerOption struct {
	ResourceFilter string
	NamespaceName  string
	PodName        string
	ContainerName  string
}

func (ContainerOption) Apply

func (co ContainerOption) Apply(o *QueryOptions)

type Interface

type Interface interface {
	GetMetric(expr string, time time.Time) Metric
	GetMetricOverTime(expr string, start, end time.Time, step time.Duration) Metric
	GetMetadata(namespace string) []Metadata
	//TODO Query dimensions to be improved
	GetAppMetadata(namespace, appID string) []Metadata
	GetComponentMetadata(namespace, componentID string) []Metadata
	GetMetricLabelSet(expr string, start, end time.Time) []map[string]string
}

Interface monitor interface

func NewPrometheus

func NewPrometheus(options *Options) (Interface, error)

NewPrometheus new prometheus monitor

type Level

type Level int

Level -

type Metadata

type Metadata struct {
	Metric string `json:"metric,omitempty" description:"metric name"`
	Type   string `json:"type,omitempty" description:"metric type"`
	Help   string `json:"help,omitempty" description:"metric description"`
}

type Metric

type Metric struct {
	MetricName string `json:"metric_name,omitempty" description:"metric name, eg. scheduler_up_sum"`
	MetricData `json:"data,omitempty" description:"actual metric result"`
	Error      string `json:"error,omitempty"`
}

type MetricData

type MetricData struct {
	MetricType   string        `json:"resultType,omitempty" description:"result type, one of matrix, vector"`
	MetricValues []MetricValue `json:"result,omitempty" description:"metric data including labels, time series and values"`
}

type MetricValue

type MetricValue struct {
	Metadata map[string]string `json:"metric,omitempty" description:"time series labels"`
	// The type of Point is a float64 array with fixed length of 2.
	// So Point will always be initialized as [0, 0], rather than nil.
	// To allow empty Sample, we should declare Sample to type *Point
	Sample *Point  `json:"value,omitempty" description:"time series, values of vector type"`
	Series []Point `json:"values,omitempty" description:"time series, values of matrix type"`
}

type NamespaceOption

type NamespaceOption struct {
	ResourceFilter string
	WorkspaceName  string
	NamespaceName  string
}

func (NamespaceOption) Apply

func (no NamespaceOption) Apply(o *QueryOptions)

type NodeOption

type NodeOption struct {
	ResourceFilter string
	NodeName       string
}

func (NodeOption) Apply

func (no NodeOption) Apply(o *QueryOptions)

type Options

type Options struct {
	Endpoint string `json:"endpoint,omitempty" yaml:"endpoint"`
}

Options prometheus options

type PVCOption

type PVCOption struct {
	ResourceFilter            string
	NamespaceName             string
	StorageClassName          string
	PersistentVolumeClaimName string
}

func (PVCOption) Apply

func (po PVCOption) Apply(o *QueryOptions)

type PodOption

type PodOption struct {
	ResourceFilter string
	NodeName       string
	NamespaceName  string
	WorkloadKind   string
	WorkloadName   string
	PodName        string
}

func (PodOption) Apply

func (po PodOption) Apply(o *QueryOptions)

type Point

type Point [2]float64

The first element is the timestamp, the second is the metric value. eg, [1585658599.195, 0.528]

func (Point) MarshalJSON

func (p Point) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will be called when writing JSON to HTTP response Inspired by prometheus/client_golang

func (Point) Timestamp

func (p Point) Timestamp() float64

func (*Point) UnmarshalJSON

func (p *Point) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler. This is for unmarshaling test data.

func (Point) Value

func (p Point) Value() float64

type QueryOption

type QueryOption interface {
	Apply(*QueryOptions)
}

type QueryOptions

type QueryOptions struct {
	Level Level

	ResourceFilter            string
	NodeName                  string
	WorkspaceName             string
	NamespaceName             string
	WorkloadKind              string
	WorkloadName              string
	PodName                   string
	ContainerName             string
	StorageClassName          string
	PersistentVolumeClaimName string
}

func NewQueryOptions

func NewQueryOptions() *QueryOptions

type WorkloadOption

type WorkloadOption struct {
	ResourceFilter string
	NamespaceName  string
	WorkloadKind   string
}

func (WorkloadOption) Apply

func (wo WorkloadOption) Apply(o *QueryOptions)

type WorkspaceOption

type WorkspaceOption struct {
	ResourceFilter string
	WorkspaceName  string
}

func (WorkspaceOption) Apply

func (wo WorkspaceOption) Apply(o *QueryOptions)

Jump to

Keyboard shortcuts

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