From be488ec67eeecf7aaf52c600bd0a91ca0ec70850 Mon Sep 17 00:00:00 2001 From: huanggze Date: Mon, 1 Jul 2019 18:19:43 +0800 Subject: [PATCH] api: update tags & reference links Signed-off-by: huanggze --- pkg/apis/monitoring/v1alpha2/register.go | 73 ++++++++++++------------ pkg/constants/constants.go | 8 +++ tools/cmd/doc-gen/main.go | 5 ++ 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/pkg/apis/monitoring/v1alpha2/register.go b/pkg/apis/monitoring/v1alpha2/register.go index 893736fc..42df0283 100644 --- a/pkg/apis/monitoring/v1alpha2/register.go +++ b/pkg/apis/monitoring/v1alpha2/register.go @@ -23,6 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/apiserver/monitoring" "kubesphere.io/kubesphere/pkg/apiserver/runtime" + "kubesphere.io/kubesphere/pkg/constants" "kubesphere.io/kubesphere/pkg/models/metrics" "net/http" ) @@ -44,12 +45,12 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/cluster").To(monitoring.MonitorCluster). Doc("Get cluster-level metric data."). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both cluster CPU usage and disk usage: `cluster_cpu_usage|cluster_disk_size_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both cluster CPU usage and disk usage: `cluster_cpu_usage|cluster_disk_size_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "cluster"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.ClusterMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -57,7 +58,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/nodes").To(monitoring.MonitorAllNodes). Doc("Get node-level metric data of all nodes."). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both node CPU usage and disk usage: `node_cpu_usage|node_disk_size_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both node CPU usage and disk usage: `node_cpu_usage|node_disk_size_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The node filter consists of a regexp pattern. It specifies which node data to return. For example, the following filter matches both node i-caojnter and i-cmu82ogj: `i-caojnter|i-cmu82ogj`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -67,7 +68,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "node"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.NodeMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -76,12 +77,12 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/nodes/{node}").To(monitoring.MonitorSpecificNode). Doc("Get node-level metric data of a specific node."). Param(ws.PathParameter("node", "Specify the monitored node.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both node CPU usage and disk usage: `node_cpu_usage|node_disk_size_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both node CPU usage and disk usage: `node_cpu_usage|node_disk_size_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "node"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.NodeMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -89,7 +90,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/namespaces").To(monitoring.MonitorAllNamespaces). Doc("Get namespace-level metric data of all namespaces."). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both namespace CPU usage and memory usage: `namespace_cpu_usage|namespace_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both namespace CPU usage and memory usage: `namespace_cpu_usage|namespace_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The namespace filter consists of a regexp pattern. It specifies which namespace data to return. For example, the following filter matches both namespace test and kube-system: `test|kube-system`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -99,7 +100,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "namespace"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -108,12 +109,12 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/namespaces/{namespace}").To(monitoring.MonitorSpecificNamespace). Doc("Get namespace-level metric data of a specific namespace."). Param(ws.PathParameter("namespace", "Specify the monitored namespace.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both namespace CPU usage and memory usage: `namespace_cpu_usage|namespace_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both namespace CPU usage and memory usage: `namespace_cpu_usage|namespace_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "namespace"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -122,7 +123,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/namespaces/{namespace}/pods").To(monitoring.MonitorAllPodsOfSpecificNamespace). Doc("Get pod-level metric data of a specific namespace's pods."). Param(ws.PathParameter("namespace", "Specify the monitored namespace.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The pod filter consists of a regexp pattern. It specifies which pod data to return. For example, the following filter matches any pod whose name begins with redis: `redis.*`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -132,7 +133,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.PodMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -142,12 +143,12 @@ func addWebService(c *restful.Container) error { Doc("Get pod-level metric data of a specific pod. Navigate to the pod by the pod's namespace."). Param(ws.PathParameter("namespace", "The namespace of the pod.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the monitored pod.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.PodMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -156,7 +157,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/nodes/{node}/pods").To(monitoring.MonitorAllPodsOnSpecificNode). Doc("Get pod-level metric data of all pods on a specific node."). Param(ws.PathParameter("node", "Specify the monitored node.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The pod filter consists of a regexp pattern. It specifies which pod data to return. For example, the following filter matches any pod whose name begins with redis: `redis.*`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -166,7 +167,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.PodMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -176,12 +177,12 @@ func addWebService(c *restful.Container) error { Doc("Get pod-level metric data of a specific pod. Navigate to the pod by the node where it is scheduled."). Param(ws.PathParameter("node", "Node name.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the monitored pod.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.PodMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -191,7 +192,7 @@ func addWebService(c *restful.Container) error { Doc("Get container-level metric data of a specific pod's containers. Navigate to the pod by the node where it is scheduled."). Param(ws.PathParameter("node", "Node name.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specified the monitored pod.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both container CPU usage and memory usage: `container_cpu_usage|container_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both container CPU usage and memory usage: `container_cpu_usage|container_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The container filter consists of a regexp pattern. It specifies which container data to return. For example, the following filter matches container prometheus and prometheus-config-reloader: `prometheus|prometheus-config-reloader`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -201,7 +202,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.ContainerMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -211,7 +212,7 @@ func addWebService(c *restful.Container) error { Doc("Get container-level metric data of a specific pod's containers. Navigate to the pod by the pod's namespace."). Param(ws.PathParameter("namespace", "The namespace of the pod.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Specify the monitored pod.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both container CPU usage and memory usage: `container_cpu_usage|container_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both container CPU usage and memory usage: `container_cpu_usage|container_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The container filter consists of a regexp pattern. It specifies which container data to return. For example, the following filter matches container prometheus and prometheus-config-reloader: `prometheus|prometheus-config-reloader`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -221,7 +222,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.ContainerMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -232,12 +233,12 @@ func addWebService(c *restful.Container) error { Param(ws.PathParameter("namespace", "Namespace of the pod.").DataType("string").Required(true)). Param(ws.PathParameter("pod", "Pod name of the container.").DataType("string").Required(true)). Param(ws.PathParameter("container", "Specify the monitored container.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both container CPU usage and memory usage: `container_cpu_usage|container_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both container CPU usage and memory usage: `container_cpu_usage|container_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "container"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.ContainerMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -248,7 +249,7 @@ func addWebService(c *restful.Container) error { Param(ws.PathParameter("namespace", "Namespace of the workload.").DataType("string").Required(true)). Param(ws.PathParameter("kind", "Workload kind. One of deployment, daemonset, statefulset.").DataType("string").Required(true)). Param(ws.PathParameter("workload", "Specify the monitored workload.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both pod CPU usage and memory usage: `pod_cpu_usage|pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The pod filter consists of a regexp pattern. It specifies which pod data to return. For example, the following filter matches any pod whose name begins with redis: `redis.*`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -258,7 +259,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "pod"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.PodMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -268,7 +269,7 @@ func addWebService(c *restful.Container) error { Doc("Get workload-level metric data of all workloads which belongs to a specific kind."). Param(ws.PathParameter("namespace", "Namespace of workloads.").DataType("string").Required(true)). Param(ws.PathParameter("kind", "Specify the monitored workload kind. One of deployment, daemonset, statefulset.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workload CPU usage and memory usage: `workload_pod_cpu_usage|workload_pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workload CPU usage and memory usage: `workload_pod_cpu_usage|workload_pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The workload filter consists of a regexp pattern. It specifies which workload data to return. For example, the following filter matches any workload whose name begins with prometheus: `prometheus.*`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -278,7 +279,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.WorkloadMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -287,7 +288,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/namespaces/{namespace}/workloads").To(monitoring.MonitorAllWorkloadsOfSpecificNamespace). Doc("Get workload-level metric data of a specific namespace's workloads."). Param(ws.PathParameter("namespace", "Specify the monitored namespace.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workload CPU usage and memory usage: `workload_pod_cpu_usage|workload_pod_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workload CPU usage and memory usage: `workload_pod_cpu_usage|workload_pod_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The workload filter consists of a regexp pattern. It specifies which workload data to return. For example, the following filter matches any workload whose name begins with prometheus: `prometheus.*`.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -297,7 +298,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("sort_type", "Direction of the sort. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)). Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workload"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.WorkloadMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -307,13 +308,13 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/workspaces/{workspace}").To(monitoring.MonitorSpecificWorkspace). Doc("Get workspace-level metric data of a specific workspace."). Param(ws.PathParameter("workspace", "Specify the monitored workspace.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workspace CPU usage and memory usage: `workspace_cpu_usage|workspace_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workspace CPU usage and memory usage: `workspace_cpu_usage|workspace_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). Param(ws.QueryParameter("type", "Additional operations. Currently available types is statistics. It retrieves the total number of namespaces, devops projects, members and roles in this workspace at the moment.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workspace"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.WorkspaceMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -321,7 +322,7 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/workspaces").To(monitoring.MonitorAllWorkspaces). Doc("Get workspace-level metric data of all workspaces."). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workspace CPU usage and memory usage: `workspace_cpu_usage|workspace_memory_usage`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both workspace CPU usage and memory usage: `workspace_cpu_usage|workspace_memory_usage`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("resources_filter", "The workspace filter consists of a regexp pattern. It specifies which workspace data to return.").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). @@ -332,7 +333,7 @@ func addWebService(c *restful.Container) error { Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)). Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")). Param(ws.QueryParameter("type", "Additional operations. Currently available types is statistics. It retrieves the total number of workspaces, devops projects, namespaces, accounts in the cluster at the moment.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "workspace"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.WorkspaceMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). @@ -341,12 +342,12 @@ func addWebService(c *restful.Container) error { ws.Route(ws.GET("/components/{component}").To(monitoring.MonitorComponent). Doc("Get component-level metric data of a specific kubesphere core component."). Param(ws.PathParameter("component", "Specify the monitored kubesphere component. One of etcd, apiserver, scheduler, controller_manager, coredns, prometheus.").DataType("string").Required(true)). - Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both etcd server list and total size of the underlying database: `etcd_server_list|etcd_mvcc_db_size`. View available metrics at [kubesphere.io](https://kubesphere.io).").DataType("string").Required(false)). + Param(ws.QueryParameter("metrics_filter", "The metric name filter consists of a regexp pattern. It specifies which metric data to return. For example, the following filter matches both etcd server list and total size of the underlying database: `etcd_server_list|etcd_mvcc_db_size`. View available metrics at [kubesphere.io](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/monitoring-metrics/).").DataType("string").Required(false)). Param(ws.QueryParameter("start", "Start time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1559347200. ").DataType("string").Required(false)). Param(ws.QueryParameter("end", "End time of query. Use **start** and **end** to retrieve metric data over a time span. It is a string with Unix time format, eg. 1561939200. ").DataType("string").Required(false)). Param(ws.QueryParameter("step", "Time interval. Retrieve metric data at a fixed interval. It requires both **start** and **end** are provided. The format is [0-9]+[smhdwy]. Defaults to 10m (i.e. 10 min).").DataType("string").DefaultValue("10m").Required(false)). Param(ws.QueryParameter("time", "A timestamp in Unix time format. Retrieve metric data at a single time point. Defaults to now.").DataType("string").Required(false)). - Metadata(restfulspec.KeyOpenAPITags, []string{"Monitoring", "component"}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.ComponentMetricsTag}). Writes(metrics.FormatedLevelMetric{}). Returns(http.StatusOK, RespOK, metrics.FormatedLevelMetric{})). Consumes(restful.MIME_JSON, restful.MIME_XML). diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index f71619b0..0d3879b4 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -57,6 +57,14 @@ const ( ComponentStatusTag = "Component Status" VerificationTag = "Verification" UserResourcesTag = "User Resources" + ClusterMetricsTag = "Cluster Metrics" + NodeMetricsTag = "Node Metrics" + NamespaceMetricsTag = "Namespace Metrics" + PodMetricsTag = "Pod Metrics" + ContainerMetricsTag = "Container Metrics" + WorkloadMetricsTag = "Workload Metrics" + WorkspaceMetricsTag = "Workspace Metrics" + ComponentMetricsTag = "Component Metrics" ) var ( diff --git a/tools/cmd/doc-gen/main.go b/tools/cmd/doc-gen/main.go index 5b9a5f64..bcd6481b 100644 --- a/tools/cmd/doc-gen/main.go +++ b/tools/cmd/doc-gen/main.go @@ -88,6 +88,11 @@ func generateSwaggerJson() { Name: "Other", Tags: []string{constants.VerificationTag}, }, + { + Name: "Monitoring", + Tags: []string{constants.ClusterMetricsTag, constants.NodeMetricsTag, constants.NamespaceMetricsTag, constants.WorkloadMetricsTag, + constants.PodMetricsTag, constants.ContainerMetricsTag, constants.WorkspaceMetricsTag, constants.ComponentMetricsTag}, + }, }) data, _ := json.Marshal(swagger) -- GitLab