Documentation
¶
Index ¶
- Constants
- Variables
- func ParseTime(timestamp string) (time.Time, error)
- type ApplicationOption
- type ApplicationsOption
- type CSVPoint
- type ClusterOption
- type ComponentOption
- type ContainerOption
- type ControllerOption
- type DashboardEntity
- type ExportPoint
- type IngressOption
- type Interface
- type Level
- type Metadata
- type MeterOption
- type Meteroptions
- type Metric
- type MetricData
- type MetricValue
- type MetricValues
- type NamespaceOption
- type NodeOption
- type OpenpitrixsOption
- type PVCOption
- type PodOption
- type Point
- type Prometheus
- type QueryOption
- type QueryOptions
- type ServiceOption
- type ServicesOption
- type WorkloadOption
- type WorkspaceOption
Constants ¶
View Source
const ( StatefulSet = "StatefulSet" DaemonSet = "DaemonSet" Deployment = "Deployment" )
View Source
const ( LevelCluster = 1 << iota LevelNode LevelWorkspace LevelNamespace LevelApplication LevelOpenpitrix LevelController 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, "LevelController": LevelController, "LevelService": LevelService, "LevelPod": LevelPod, "LevelContainer": LevelContainer, "LevelPVC": LevelPVC, "LevelComponent": LevelComponent, }
Functions ¶
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 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 ControllerOption ¶ added in v0.1.13
func (ControllerOption) Apply ¶ added in v0.1.13
func (co ControllerOption) Apply(o *QueryOptions)
type DashboardEntity ¶
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
GetNamedMetricsByTime(metrics []string, start, end string, step time.Duration, opt QueryOption) []Metric
}
type MeterOption ¶
func (MeterOption) Apply ¶
func (mo MeterOption) Apply(o *QueryOptions)
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) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will be called when writing JSON to HTTP response Inspired by prometheus/client_golang
func (*Point) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. This is for unmarshaling test data.
type Prometheus ¶ added in v0.1.13
type Prometheus struct {
// contains filtered or unexported fields
}
func NewPrometheus ¶
func NewPrometheus(address string) (Prometheus, error)
NewPrometheus 初始化Prometheus客户端
func (Prometheus) GetNamedMetrics ¶ added in v0.1.13
func (p Prometheus) GetNamedMetrics(metrics []string, ts time.Time, o QueryOption) []Metric
func (Prometheus) GetNamedMetricsByTime ¶ added in v0.1.13
func (p Prometheus) GetNamedMetricsByTime(metrics []string, start, end string, step time.Duration, o QueryOption) []Metric
type QueryOption ¶
type QueryOption interface {
Apply(*QueryOptions)
}
type QueryOptions ¶
type QueryOptions struct {
Level Level
NamespacedResourcesFilter string
QueryType string
ResourceFilter string
NodeName string
WorkspaceName string
Namespace string
WorkloadKind string
WorkloadName string
OwnerName string
PodName string
PodsName 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 ¶
func (ServicesOption) Apply ¶
func (sso ServicesOption) Apply(o *QueryOptions)
type WorkloadOption ¶
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)
Click to show internal directories.
Click to hide internal directories.