mirror of
https://github.com/rancher/types.git
synced 2025-08-25 07:18:25 +00:00
Support Monitoring Graph
This commit is contained in:
parent
41b69d549b
commit
4eaac631fa
@ -10,11 +10,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
NamespaceBackedResource condition.Cond = "BackingNamespaceCreated"
|
||||
CreatorMadeOwner condition.Cond = "CreatorMadeOwner"
|
||||
DefaultNetworkPolicyCreated condition.Cond = "DefaultNetworkPolicyCreated"
|
||||
ProjectConditionInitialRolesPopulated condition.Cond = "InitialRolesPopulated"
|
||||
ProjectConditionMonitoringEnabled condition.Cond = "MonitoringEnabled"
|
||||
NamespaceBackedResource condition.Cond = "BackingNamespaceCreated"
|
||||
CreatorMadeOwner condition.Cond = "CreatorMadeOwner"
|
||||
DefaultNetworkPolicyCreated condition.Cond = "DefaultNetworkPolicyCreated"
|
||||
ProjectConditionInitialRolesPopulated condition.Cond = "InitialRolesPopulated"
|
||||
ProjectConditionMonitoringEnabled condition.Cond = "MonitoringEnabled"
|
||||
ProjectConditionMetricExpressionDeployed condition.Cond = "MetricExpressionDeployed"
|
||||
)
|
||||
|
||||
type Project struct {
|
||||
|
@ -2,7 +2,9 @@ package v3
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/condition"
|
||||
"github.com/rancher/norman/types"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
type MonitoringStatus struct {
|
||||
@ -33,3 +35,138 @@ const (
|
||||
MonitoringConditionKubeStateExporterDeployed condition.Cond = "KubeStateExporterDeployed"
|
||||
MonitoringConditionMetricExpressionDeployed condition.Cond = "MetricExpressionDeployed"
|
||||
)
|
||||
|
||||
type ClusterMonitorGraph struct {
|
||||
types.Namespaced
|
||||
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object’s metadata. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterMonitorGraphSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type ProjectMonitorGraph struct {
|
||||
types.Namespaced
|
||||
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object’s metadata. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ProjectMonitorGraphSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type ClusterMonitorGraphSpec struct {
|
||||
ClusterName string `json:"clusterName" norman:"type=reference[cluster]"`
|
||||
ResourceType string `json:"resourceType,omitempty" norman:"type=enum,options=node|cluster|etcd|apiserver|scheduler|controllermanager|fluentd"`
|
||||
DisplayResourceType string `json:"displayResourceType,omitempty" norman:"type=enum,options=node|cluster|etcd|kube-component|rancher-component"`
|
||||
CommonMonitorGraphSpec
|
||||
}
|
||||
|
||||
type ProjectMonitorGraphSpec struct {
|
||||
ProjectName string `json:"projectName" norman:"type=reference[project]"`
|
||||
ResourceType string `json:"resourceType,omitempty" norman:"type=enum,options=workload|pod|container"`
|
||||
DisplayResourceType string `json:"displayResourceType,omitempty" norman:"type=enum,options=workload|pod|container"`
|
||||
CommonMonitorGraphSpec
|
||||
}
|
||||
|
||||
type CommonMonitorGraphSpec struct {
|
||||
Description string `json:"description,omitempty"`
|
||||
MetricsSelector map[string]string `json:"metricsSelector,omitempty"`
|
||||
DetailsMetricsSelector map[string]string `json:"detailsMetricsSelector,omitempty"`
|
||||
YAxis YAxis `json:"yAxis,omitempty"`
|
||||
Priority int `json:"priority,omitempty"`
|
||||
GraphType string `json:"graphType,omitempty" norman:"type=enum,options=graph|singlestat"`
|
||||
}
|
||||
|
||||
type YAxis struct {
|
||||
Unit string `json:"unit,omitempty"`
|
||||
}
|
||||
|
||||
type MonitorMetric struct {
|
||||
types.Namespaced
|
||||
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object’s metadata. More info:
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec MonitorMetricSpec `json:"spec"`
|
||||
}
|
||||
|
||||
type MonitorMetricSpec struct {
|
||||
Expression string `json:"expression,omitempty" norman:"required"`
|
||||
LegendFormat string `json:"legendFormat,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type QueryGraphInput struct {
|
||||
From string `json:"from,omitempty"`
|
||||
To string `json:"to,omitempty"`
|
||||
Interval string `json:"interval,omitempty"`
|
||||
MetricParams map[string]string `json:"metricParams,omitempty"`
|
||||
Filters map[string]string `json:"filters,omitempty"`
|
||||
IsDetails bool `json:"isDetails,omitempty"`
|
||||
}
|
||||
|
||||
type QueryClusterGraphOutput struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Data []QueryClusterGraph `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type QueryClusterGraph struct {
|
||||
GraphName string `json:"graphID" norman:"type=reference[clusterMonitorGraph]"`
|
||||
Series []*TimeSeries `json:"series" norman:"type=array[reference[timeSeries]]"`
|
||||
}
|
||||
|
||||
type QueryProjectGraphOutput struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Data []QueryProjectGraph `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type QueryProjectGraph struct {
|
||||
GraphName string `json:"graphID" norman:"type=reference[projectMonitorGraph]"`
|
||||
Series []*TimeSeries `json:"series" norman:"type=array[reference[timeSeries]]"`
|
||||
}
|
||||
|
||||
type QueryClusterMetricInput struct {
|
||||
ClusterName string `json:"clusterId" norman:"type=reference[cluster]"`
|
||||
CommonQueryMetricInput
|
||||
}
|
||||
|
||||
type QueryProjectMetricInput struct {
|
||||
ProjectName string `json:"projectId" norman:"type=reference[project]"`
|
||||
CommonQueryMetricInput
|
||||
}
|
||||
|
||||
type CommonQueryMetricInput struct {
|
||||
From string `json:"from,omitempty"`
|
||||
To string `json:"to,omitempty"`
|
||||
Interval string `json:"interval,omitempty"`
|
||||
Expr string `json:"expr,omitempty" norman:"required"`
|
||||
}
|
||||
|
||||
type QueryMetricOutput struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Series []*TimeSeries `json:"series" norman:"type=array[reference[timeSeries]]"`
|
||||
}
|
||||
|
||||
type TimeSeries struct {
|
||||
Name string `json:"name"`
|
||||
Points [][]float64 `json:"points" norman:"type=array[array[float]]"`
|
||||
}
|
||||
|
||||
type MetricNamesOutput struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Names []string `json:"names" norman:"type=array[string]"`
|
||||
}
|
||||
|
||||
type ClusterMetricNamesInput struct {
|
||||
ClusterName string `json:"clusterId" norman:"type=reference[cluster]"`
|
||||
}
|
||||
|
||||
type ProjectMetricNamesInput struct {
|
||||
ProjectName string `json:"projectId" norman:"type=reference[project]"`
|
||||
}
|
||||
|
@ -38,7 +38,9 @@ var (
|
||||
Init(clusterCatalogTypes).
|
||||
Init(multiClusterAppTypes).
|
||||
Init(globalDNSTypes).
|
||||
Init(kontainerTypes)
|
||||
Init(kontainerTypes).
|
||||
Init(monitorTypes)
|
||||
|
||||
TokenSchemas = factory.Schemas(&Version).
|
||||
Init(tokens)
|
||||
)
|
||||
@ -638,3 +640,54 @@ func kontainerTypes(schemas *types.Schemas) *types.Schemas {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func monitorTypes(schemas *types.Schemas) *types.Schemas {
|
||||
return schemas.
|
||||
MustImport(&Version, v3.QueryGraphInput{}).
|
||||
MustImport(&Version, v3.QueryClusterGraphOutput{}).
|
||||
MustImport(&Version, v3.QueryProjectGraphOutput{}).
|
||||
MustImport(&Version, v3.QueryClusterMetricInput{}).
|
||||
MustImport(&Version, v3.QueryProjectMetricInput{}).
|
||||
MustImport(&Version, v3.QueryMetricOutput{}).
|
||||
MustImport(&Version, v3.ClusterMetricNamesInput{}).
|
||||
MustImport(&Version, v3.ProjectMetricNamesInput{}).
|
||||
MustImport(&Version, v3.MetricNamesOutput{}).
|
||||
MustImport(&Version, v3.TimeSeries{}).
|
||||
MustImportAndCustomize(&Version, v3.MonitorMetric{}, func(schema *types.Schema) {
|
||||
schema.CollectionActions = map[string]types.Action{
|
||||
"querycluster": {
|
||||
Input: "queryClusterMetricInput",
|
||||
Output: "queryMetricOutput",
|
||||
},
|
||||
"listclustermetricname": {
|
||||
Input: "clusterMetricNamesInput",
|
||||
Output: "metricNamesOutput",
|
||||
},
|
||||
"queryproject": {
|
||||
Input: "queryProjectMetricInput",
|
||||
Output: "queryMetricOutput",
|
||||
},
|
||||
"listprojectmetricname": {
|
||||
Input: "projectMetricNamesInput",
|
||||
Output: "metricNamesOutput",
|
||||
},
|
||||
}
|
||||
}).
|
||||
MustImportAndCustomize(&Version, v3.ClusterMonitorGraph{}, func(schema *types.Schema) {
|
||||
schema.CollectionActions = map[string]types.Action{
|
||||
"query": {
|
||||
Input: "queryGraphInput",
|
||||
Output: "queryClusterGraphOutput",
|
||||
},
|
||||
}
|
||||
}).
|
||||
MustImportAndCustomize(&Version, v3.ProjectMonitorGraph{}, func(schema *types.Schema) {
|
||||
schema.CollectionActions = map[string]types.Action{
|
||||
"query": {
|
||||
Input: "queryGraphInput",
|
||||
Output: "queryProjectGraphOutput",
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user