diff --git a/pkg/kapis/monitoring/v1alpha3/dashboard_template_test.sh b/pkg/kapis/monitoring/v1alpha3/dashboard_template_test.sh index d82823173..714d6b598 100644 --- a/pkg/kapis/monitoring/v1alpha3/dashboard_template_test.sh +++ b/pkg/kapis/monitoring/v1alpha3/dashboard_template_test.sh @@ -1,3 +1,3 @@ #! /bin/bash -curl -d '{"grafanaDashboardUrl":"https://grafana.com/api/dashboards/7362/revisions/5/download"}' -H "Content-Type: application/json" localhost:9090/kapis/monitoring.kubesphere.io/v1alpha3/clusterdashboard/test1/template \ No newline at end of file +curl -d '{"grafanaDashboardUrl":"https://grafana.com/api/dashboards/7362/revisions/5/download", "description":"this is a test dashboard."}' -H "Content-Type: application/json" localhost:9090/kapis/monitoring.kubesphere.io/v1alpha3/clusterdashboard/test1/template \ No newline at end of file diff --git a/pkg/kapis/monitoring/v1alpha3/handler.go b/pkg/kapis/monitoring/v1alpha3/handler.go index b3fa3f622..e0d94ef9c 100644 --- a/pkg/kapis/monitoring/v1alpha3/handler.go +++ b/pkg/kapis/monitoring/v1alpha3/handler.go @@ -383,13 +383,16 @@ func (h handler) handleGrafanaDashboardImport(req *restful.Request, resp *restfu return } + annotation := map[string]string{"kubesphere.io/description": entity.Description} + dashboard := monitoringdashboardv1alpha2.ClusterDashboard{ TypeMeta: v1.TypeMeta{ APIVersion: convertedDashboard.APIVersion, Kind: convertedDashboard.Kind, }, ObjectMeta: v1.ObjectMeta{ - Name: convertedDashboard.Metadata["name"], + Name: convertedDashboard.Metadata["name"], + Annotations: annotation, }, Spec: *convertedDashboard.Spec, } diff --git a/pkg/simple/client/monitoring/types.go b/pkg/simple/client/monitoring/types.go index 936666f59..255c2a273 100644 --- a/pkg/simple/client/monitoring/types.go +++ b/pkg/simple/client/monitoring/types.go @@ -52,6 +52,7 @@ type MetricData struct { type DashboardEntity struct { GrafanaDashboardUrl string `json:"grafanaDashboardUrl,omitempty"` GrafanaDashboardContent string `json:"grafanaDashboardContent,omitempty"` + Description string `json:"description,omitempty"` } // The first element is the timestamp, the second is the metric value.