monitoring

package
v0.0.0-...-e779149 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var MeteringLevelMap = map[string]int{
	"LevelCluster":     LevelCluster,
	"LevelNode":        LevelNode,
	"LevelWorkspace":   LevelWorkspace,
	"LevelNamespace":   LevelNamespace,
	"LevelApplication": LevelApplication,
	"LevelWorkload":    LevelWorkload,
	"LevelService":     LevelService,
	"LevelPod":         LevelPod,
	"LevelContainer":   LevelContainer,
	"LevelPVC":         LevelPVC,
	"LevelComponent":   LevelComponent,
}

Functions

This section is empty.

Types

type ApplicationOption

type ApplicationOption struct {
	NamespaceName         string
	Application           string
	ApplicationComponents []string
	StorageClassName      string
}

ApplicationsOption & OpenpitrixsOption share the same ApplicationOption struct

func (ApplicationOption) Apply

func (ao ApplicationOption) Apply(o *QueryOptions)

type ApplicationsOption

type ApplicationsOption struct {
	NamespaceName    string
	Applications     []string
	StorageClassName string
}

func (ApplicationsOption) Apply

func (aso ApplicationsOption) Apply(o *QueryOptions)

type CSVPoint

type CSVPoint struct {
	MetricName   string `csv:"metric_name"`
	Selector     string `csv:"selector"`
	Time         string `csv:"time"`
	Value        string `csv:"value"`
	ResourceUnit string `csv:"unit"`
}

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 DashboardEntity

type DashboardEntity struct {
	GrafanaDashboardUrl     string `json:"grafanaDashboardUrl,omitempty"`
	GrafanaDashboardContent string `json:"grafanaDashboardContent,omitempty"`
	Description             string `json:"description,omitempty"`
	Namespace               string `json:"namespace,omitempty"`
}

type ExportPoint

type ExportPoint [2]float64

func (ExportPoint) Format

func (p ExportPoint) Format() string

func (ExportPoint) Timestamp

func (p ExportPoint) Timestamp() string

func (ExportPoint) TransformToCSVPoint

func (p ExportPoint) TransformToCSVPoint(metricName string, selector string, resourceUnit string) CSVPoint

func (ExportPoint) Value

func (p ExportPoint) Value() float64

type IngressOption

type IngressOption struct {
	ResourceFilter string
	NamespaceName  string
	Ingress        string
	Job            string
	Pod            string
	Duration       *time.Duration
}

func (IngressOption) Apply

func (no IngressOption) 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
	GetNamedMetrics(metrics []string, time time.Time, opt QueryOption) []Metric
	GetNamedMetricsOverTime(metrics []string, start, end time.Time, step time.Duration, opt QueryOption) []Metric
	GetMetadata(namespace string) []Metadata
	GetMetricLabelSet(expr string, start, end time.Time) []map[string]string

	// meter
	GetNamedMeters(meters []string, time time.Time, opts []QueryOption) []Metric
	GetNamedMetersOverTime(metrics []string, start, end time.Time, step time.Duration, opts []QueryOption) []Metric
}

type Level

type Level int

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 MeterOption

type MeterOption struct {
	Start time.Time
	End   time.Time
	Step  time.Duration
}

func (MeterOption) Apply

func (mo MeterOption) Apply(o *QueryOptions)

type Meteroptions

type Meteroptions struct {
	Start time.Time
	End   time.Time
	Step  time.Duration
}

type Metric

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

type MetricData

type MetricData struct {
	MetricType   string `json:"resultType,omitempty" description:"result type, one of matrix, vector" csv:"metric_type"`
	MetricValues `json:"result,omitempty" description:"metric data including labels, time series and values" csv:"metric_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"`
	ExportSample   *ExportPoint  `json:"exported_value,omitempty" description:"exported time series, values of vector type"`
	ExportedSeries []ExportPoint `json:"exported_values,omitempty" description:"exported time series, values of matrix type"`

	MinValue     string `json:"min_value" description:"minimum value from monitor points"`
	MaxValue     string `json:"max_value" description:"maximum value from monitor points"`
	AvgValue     string `json:"avg_value" description:"average value from monitor points"`
	SumValue     string `json:"sum_value" description:"sum value from monitor points"`
	Fee          string `json:"fee" description:"resource fee"`
	ResourceUnit string `json:"resource_unit"`
	CurrencyUnit string `json:"currency_unit"`
}

func (*MetricValue) TransferToExportedMetricValue

func (mv *MetricValue) TransferToExportedMetricValue()

type MetricValues

type MetricValues []MetricValue

type NamespaceOption

type NamespaceOption struct {
	ResourceFilter   string
	WorkspaceName    string
	NamespaceName    string
	PVCFilter        string
	StorageClassName string
}

func (NamespaceOption) Apply

func (no NamespaceOption) Apply(o *QueryOptions)

type NodeOption

type NodeOption struct {
	ResourceFilter   string
	NodeName         string
	PVCFilter        string
	StorageClassName string
	QueryType        string
}

func (NodeOption) Apply

func (no NodeOption) Apply(o *QueryOptions)

type OpenpitrixsOption

type OpenpitrixsOption struct {
	Cluster          string
	NamespaceName    string
	Openpitrixs      []string
	StorageClassName string
}

func (OpenpitrixsOption) Apply

func (oso OpenpitrixsOption) Apply(o *QueryOptions)

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 {
	NamespacedResourcesFilter string
	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) Add

func (p Point) Add(other Point) Point

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

	NamespacedResourcesFilter string
	QueryType                 string
	ResourceFilter            string
	NodeName                  string
	WorkspaceName             string
	NamespaceName             string
	WorkloadKind              string
	WorkloadName              string
	PodName                   string
	ContainerName             string
	StorageClassName          string
	PersistentVolumeClaimName string
	PVCFilter                 string
	ApplicationName           string
	ServiceName               string
	Ingress                   string
	Job                       string
	Duration                  *time.Duration
	MeterOptions              *Meteroptions
}

func NewQueryOptions

func NewQueryOptions() *QueryOptions

type ServiceOption

type ServiceOption struct {
	ResourceFilter string
	NamespaceName  string
	ServiceName    string
	PodNames       []string
}

func (ServiceOption) Apply

func (so ServiceOption) Apply(o *QueryOptions)

type ServicesOption

type ServicesOption struct {
	NamespaceName string
	Services      []string
}

func (ServicesOption) Apply

func (sso ServicesOption) Apply(o *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
	PVCFilter        string
	StorageClassName string
}

func (WorkspaceOption) Apply

func (wo WorkspaceOption) Apply(o *QueryOptions)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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