Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
f79ae414
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
f79ae414
编写于
11月 21, 2018
作者:
Z
zryfish
提交者:
GitHub
11月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #210 from carmanzhang/monitor
changed promqls and fixed several monitoring bugs
上级
7f780bd3
982c4ac3
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
289 addition
and
183 deletion
+289
-183
pkg/apis/v1alpha/monitoring/monitor_handler.go
pkg/apis/v1alpha/monitoring/monitor_handler.go
+7
-6
pkg/models/metrics/metrics.go
pkg/models/metrics/metrics.go
+91
-28
pkg/models/metrics/metricsrule.go
pkg/models/metrics/metricsrule.go
+12
-2
pkg/models/metrics/metricsruleconst.go
pkg/models/metrics/metricsruleconst.go
+151
-146
pkg/models/metrics/util.go
pkg/models/metrics/util.go
+28
-1
未找到文件。
pkg/apis/v1alpha/monitoring/monitor_handler.go
浏览文件 @
f79ae414
...
...
@@ -73,12 +73,14 @@ func (u Monitor) monitorAllWorkspaces(request *restful.Request, response *restfu
requestParams
:=
client
.
ParseMonitoringRequestParams
(
request
)
if
requestParams
.
Tp
==
"_statistics"
{
tp
:=
requestParams
.
Tp
if
tp
==
"_statistics"
{
// merge multiple metric: all-devops, all-roles, all-projects...this api is designed for admin
res
:=
metrics
.
MonitorAllWorkspacesStatistics
()
response
.
WriteAsJson
(
res
)
}
else
{
}
else
if
tp
==
"rank"
{
rawMetrics
:=
metrics
.
MonitorAllWorkspaces
(
requestParams
)
// sorting
sortedMetrics
,
maxMetricCount
:=
metrics
.
Sort
(
requestParams
.
SortMetricName
,
requestParams
.
SortType
,
rawMetrics
,
metrics
.
MetricLevelWorkspace
)
...
...
@@ -86,6 +88,9 @@ func (u Monitor) monitorAllWorkspaces(request *restful.Request, response *restfu
pagedMetrics
:=
metrics
.
Page
(
requestParams
.
PageNum
,
requestParams
.
LimitNum
,
sortedMetrics
,
maxMetricCount
)
response
.
WriteAsJson
(
pagedMetrics
)
}
else
{
res
:=
metrics
.
MonitorAllMetrics
(
requestParams
,
metrics
.
MetricLevelWorkspace
)
response
.
WriteAsJson
(
res
)
}
}
...
...
@@ -145,10 +150,6 @@ func (u Monitor) monitorCluster(request *restful.Request, response *restful.Resp
queryType
,
params
:=
metrics
.
AssembleClusterMetricRequestInfo
(
requestParams
,
metricName
)
res
:=
metrics
.
GetMetric
(
queryType
,
params
,
metricName
)
if
metricName
==
metrics
.
MetricNameWorkspaceAllProjectCount
{
res
=
metrics
.
MonitorWorkspaceNamespaceHistory
(
res
)
}
response
.
WriteAsJson
(
res
)
}
else
{
// multiple
...
...
pkg/models/metrics/metrics.go
浏览文件 @
f79ae414
...
...
@@ -277,12 +277,28 @@ func AssembleNamespaceMetricRequestInfo(monitoringRequest *client.MonitoringRequ
return
queryType
,
params
}
func
AssembleWorkspaceMetricRequestInfo
(
monitoringRequest
*
client
.
MonitoringRequestParams
,
namespaceList
[]
string
,
metricName
string
)
(
string
,
string
)
{
func
AssembleSpecificWorkspaceMetricRequestInfo
(
monitoringRequest
*
client
.
MonitoringRequestParams
,
namespaceList
[]
string
,
metricName
string
)
(
string
,
string
)
{
nsFilter
:=
"^("
+
strings
.
Join
(
namespaceList
,
"|"
)
+
")$"
queryType
:=
monitoringRequest
.
QueryType
rule
:=
MakeWorkspacePromQL
(
metricName
,
nsFilter
)
rule
:=
MakeSpecificWorkspacePromQL
(
metricName
,
nsFilter
)
paramValues
:=
monitoringRequest
.
Params
params
:=
makeRequestParamString
(
rule
,
paramValues
)
return
queryType
,
params
}
func
AssembleAllWorkspaceMetricRequestInfo
(
monitoringRequest
*
client
.
MonitoringRequestParams
,
namespaceList
[]
string
,
metricName
string
)
(
string
,
string
)
{
var
nsFilter
=
"^()$"
if
namespaceList
!=
nil
{
nsFilter
=
"^("
+
strings
.
Join
(
namespaceList
,
"|"
)
+
")$"
}
queryType
:=
monitoringRequest
.
QueryType
rule
:=
MakeAllWorkspacesPromQL
(
metricName
,
nsFilter
)
paramValues
:=
monitoringRequest
.
Params
params
:=
makeRequestParamString
(
rule
,
paramValues
)
return
queryType
,
params
...
...
@@ -330,6 +346,9 @@ func MonitorAllWorkspaces(monitoringRequest *client.MonitoringRequestParams) *Fo
}
var
filterMetricsName
[]
string
for
_
,
metricName
:=
range
WorkspaceMetricsNames
{
if
metricName
==
MetricNameWorkspaceAllProjectCount
{
continue
}
bol
,
err
:=
regexp
.
MatchString
(
metricsFilter
,
metricName
)
if
err
==
nil
&&
bol
{
filterMetricsName
=
append
(
filterMetricsName
,
metricName
)
...
...
@@ -400,7 +419,7 @@ func collectWorkspaceMetric(monitoringRequest *client.MonitoringRequestParams, w
wg
.
Add
(
1
)
go
func
(
metricName
string
)
{
queryType
,
params
:=
AssembleWorkspaceMetricRequestInfo
(
monitoringRequest
,
namespaceArray
,
metricName
)
queryType
,
params
:=
Assemble
Specific
WorkspaceMetricRequestInfo
(
monitoringRequest
,
namespaceArray
,
metricName
)
ch
<-
GetMetric
(
queryType
,
params
,
metricName
)
wg
.
Done
()
...
...
@@ -448,11 +467,6 @@ func MonitorAllMetrics(monitoringRequest *client.MonitoringRequestParams, resour
queryType
,
params
:=
AssembleClusterMetricRequestInfo
(
monitoringRequest
,
metricName
)
clusterMetrics
:=
GetMetric
(
queryType
,
params
,
metricName
)
// for this special case, get namespace history which in a workspace by determining namespace label
if
metricName
==
MetricNameWorkspaceAllProjectCount
{
clusterMetrics
=
MonitorWorkspaceNamespaceHistory
(
clusterMetrics
)
}
ch
<-
clusterMetrics
wg
.
Done
()
...
...
@@ -476,6 +490,8 @@ func MonitorAllMetrics(monitoringRequest *client.MonitoringRequestParams, resour
}
case
MetricLevelWorkspace
:
{
// a specific workspace's metrics
if
monitoringRequest
.
WsName
!=
""
{
namespaceArray
,
err
:=
workspaces
.
WorkspaceNamespaces
(
monitoringRequest
.
WsName
)
if
err
!=
nil
{
glog
.
Errorln
(
err
.
Error
())
...
...
@@ -484,6 +500,10 @@ func MonitorAllMetrics(monitoringRequest *client.MonitoringRequestParams, resour
if
monitoringRequest
.
Tp
==
"rank"
{
for
_
,
metricName
:=
range
NamespaceMetricsNames
{
if
metricName
==
MetricNameWorkspaceAllProjectCount
{
continue
}
bol
,
err
:=
regexp
.
MatchString
(
metricsFilter
,
metricName
)
ns
:=
"^("
+
strings
.
Join
(
namespaceArray
,
"|"
)
+
")$"
monitoringRequest
.
NsFilter
=
ns
...
...
@@ -498,13 +518,56 @@ func MonitorAllMetrics(monitoringRequest *client.MonitoringRequestParams, resour
}
}
else
{
for
_
,
metricName
:=
range
WorkspaceMetricsNames
{
if
metricName
==
MetricNameWorkspaceAllProjectCount
{
continue
}
bol
,
err
:=
regexp
.
MatchString
(
metricsFilter
,
metricName
)
if
err
==
nil
&&
bol
{
wg
.
Add
(
1
)
go
func
(
metricName
string
)
{
queryType
,
params
:=
AssembleSpecificWorkspaceMetricRequestInfo
(
monitoringRequest
,
namespaceArray
,
metricName
)
ch
<-
GetMetric
(
queryType
,
params
,
metricName
)
wg
.
Done
()
}(
metricName
)
}
}
}
}
else
{
// sum all workspaces
_
,
namespaceWorkspaceMap
,
err
:=
workspaces
.
GetAllOrgAndProjList
()
if
err
!=
nil
{
glog
.
Errorln
(
err
.
Error
())
}
nsList
:=
make
([]
string
,
0
)
for
ns
:=
range
namespaceWorkspaceMap
{
if
namespaceWorkspaceMap
[
ns
]
==
""
{
nsList
=
append
(
nsList
,
ns
)
}
}
for
_
,
metricName
:=
range
WorkspaceMetricsNames
{
bol
,
err
:=
regexp
.
MatchString
(
metricsFilter
,
metricName
)
if
err
==
nil
&&
bol
{
wg
.
Add
(
1
)
go
func
(
metricName
string
)
{
queryType
,
params
:=
AssembleWorkspaceMetricRequestInfo
(
monitoringRequest
,
namespaceArray
,
metricName
)
queryType
,
params
:=
AssembleAllWorkspaceMetricRequestInfo
(
monitoringRequest
,
nil
,
metricName
)
if
metricName
==
MetricNameWorkspaceAllProjectCount
{
res
:=
GetMetric
(
queryType
,
params
,
metricName
)
res
=
MonitorWorkspaceNamespaceHistory
(
res
)
ch
<-
res
}
else
{
ch
<-
GetMetric
(
queryType
,
params
,
metricName
)
}
wg
.
Done
()
}(
metricName
)
}
...
...
pkg/models/metrics/metricsrule.go
浏览文件 @
f79ae414
...
...
@@ -57,8 +57,18 @@ func MakeWorkloadRule(wkKind, wkName, namespace string) string {
return
rule
}
func
MakeWorkspacePromQL
(
metricsName
string
,
nsFilter
string
)
string
{
promql
:=
RulePromQLTmplMap
[
metricsName
]
func
MakeAllWorkspacesPromQL
(
metricsName
,
nsFilter
string
)
string
{
var
promql
=
RulePromQLTmplMap
[
metricsName
]
nsFilter
=
"!~
\"
"
+
nsFilter
+
"
\"
"
promql
=
strings
.
Replace
(
promql
,
"$1"
,
nsFilter
,
-
1
)
return
promql
}
func
MakeSpecificWorkspacePromQL
(
metricsName
,
nsFilter
string
)
string
{
var
promql
=
RulePromQLTmplMap
[
metricsName
]
nsFilter
=
"=~
\"
"
+
nsFilter
+
"
\"
"
promql
=
strings
.
Replace
(
promql
,
"$1"
,
nsFilter
,
-
1
)
return
promql
}
...
...
pkg/models/metrics/metricsruleconst.go
浏览文件 @
f79ae414
...
...
@@ -89,9 +89,9 @@ var ClusterMetricsNames = []string{
"cluster_cpu_usage"
,
"cluster_cpu_total"
,
"cluster_memory_utilisation"
,
"cluster_memory_
bytes_
available"
,
"cluster_memory_
bytes_
total"
,
"cluster_memory_
bytes_usag
e"
,
"cluster_memory_available"
,
"cluster_memory_total"
,
"cluster_memory_
usage_wo_cach
e"
,
"cluster_net_utilisation"
,
"cluster_net_bytes_transmitted"
,
"cluster_net_bytes_received"
,
...
...
@@ -131,7 +131,6 @@ var ClusterMetricsNames = []string{
"cluster_secret_count"
,
"cluster_namespace_count"
,
"workspace_all_project_count"
,
"cluster_load1"
,
"cluster_load5"
,
...
...
@@ -142,9 +141,10 @@ var NodeMetricsNames = []string{
"node_cpu_total"
,
"node_cpu_usage"
,
"node_memory_utilisation"
,
"node_memory_bytes_usage"
,
"node_memory_bytes_available"
,
"node_memory_bytes_total"
,
"node_memory_usage_wo_cache"
,
"node_memory_available"
,
"node_memory_total"
,
"node_net_utilisation"
,
"node_net_bytes_transmitted"
,
"node_net_bytes_received"
,
...
...
@@ -195,6 +195,8 @@ var WorkspaceMetricsNames = []string{
"workspace_replicaset_count"
,
"workspace_service_count"
,
"workspace_secret_count"
,
"workspace_all_project_count"
,
}
var
NamespaceMetricsNames
=
[]
string
{
"namespace_cpu_usage"
,
...
...
@@ -284,9 +286,10 @@ var RulePromQLTmplMap = MetricMap{
"cluster_cpu_usage"
:
`:node_cpu_utilisation:avg1m * sum(node:node_num_cpu:sum)`
,
"cluster_cpu_total"
:
"sum(node:node_num_cpu:sum)"
,
"cluster_memory_utilisation"
:
":node_memory_utilisation:"
,
"cluster_memory_bytes_available"
:
"sum(node:node_memory_bytes_available:sum)"
,
"cluster_memory_bytes_total"
:
"sum(node:node_memory_bytes_total:sum)"
,
"cluster_memory_bytes_usage"
:
"sum(node:node_memory_bytes_total:sum) - sum(node:node_memory_bytes_available:sum)"
,
"cluster_memory_available"
:
"sum(node:node_memory_bytes_available:sum)"
,
"cluster_memory_total"
:
"sum(node:node_memory_bytes_total:sum)"
,
"cluster_memory_usage_wo_cache"
:
"sum(node:node_memory_bytes_total:sum) - sum(node:node_memory_bytes_available:sum)"
,
"cluster_net_utilisation"
:
":node_net_utilisation:sum_irate"
,
"cluster_net_bytes_transmitted"
:
"sum(node:node_net_bytes_transmitted:sum_irate)"
,
"cluster_net_bytes_received"
:
"sum(node:node_net_bytes_received:sum_irate)"
,
...
...
@@ -304,7 +307,6 @@ var RulePromQLTmplMap = MetricMap{
"cluster_disk_inode_utilisation"
:
`1 - sum(node:disk_inodes_free:) / sum(node:disk_inodes_total:)`
,
"cluster_namespace_count"
:
`count(kube_namespace_annotations)`
,
"workspace_all_project_count"
:
`count(kube_namespace_annotations)`
,
// cluster_pod_count = cluster_pod_running_count + cluster_pod_succeeded_count + cluster_pod_abnormal_count
"cluster_pod_count"
:
`sum(kube_pod_info unless on (node) (kube_node_status_condition{condition="Ready",status=~"unknown|false"} > 0))`
,
...
...
@@ -353,16 +355,18 @@ var RulePromQLTmplMap = MetricMap{
"cluster_secret_count"
:
`sum(kube_secret_info)`
,
"cluster_pv_count"
:
`sum(kube_persistentvolume_labels)`
,
"cluster_load1"
:
`sum(node_load1{job="node-exporter"})`
,
"cluster_load5"
:
`sum(node_load5{job="node-exporter"})`
,
"cluster_load15"
:
`sum(node_load15{job="node-exporter"})`
,
"cluster_load1"
:
`sum(node_load1{job="node-exporter"})
/ sum(node:node_num_cpu:sum)
`
,
"cluster_load5"
:
`sum(node_load5{job="node-exporter"})
/ sum(node:node_num_cpu:sum)
`
,
"cluster_load15"
:
`sum(node_load15{job="node-exporter"})
/ sum(node:node_num_cpu:sum)
`
,
//node
"node_cpu_utilisation"
:
"node:node_cpu_utilisation:avg1m"
,
"node_cpu_total"
:
"node:node_num_cpu:sum"
,
"node_memory_utilisation"
:
"node:node_memory_utilisation:"
,
"node_memory_bytes_available"
:
"node:node_memory_bytes_available:sum"
,
"node_memory_bytes_total"
:
"node:node_memory_bytes_total:sum"
,
"node_memory_available"
:
"node:node_memory_bytes_available:sum"
,
"node_memory_total"
:
"node:node_memory_bytes_total:sum"
,
"node_memory_usage_wo_cache"
:
"node:node_memory_bytes_total:sum$1 - node:node_memory_bytes_available:sum$1"
,
// Node network utilisation (bytes received + bytes transmitted per second)
"node_net_utilisation"
:
"node:node_net_utilisation:sum_irate"
,
// Node network bytes transmitted per second
...
...
@@ -397,76 +401,75 @@ var RulePromQLTmplMap = MetricMap{
// without log node: unless on(node) kube_node_labels{label_role="log"}
"node_cpu_usage"
:
`node:node_cpu_utilisation:avg1m$1 * node:node_num_cpu:sum$1`
,
"node_memory_bytes_usage"
:
"node:node_memory_bytes_total:sum$1 - node:node_memory_bytes_available:sum$1"
,
"node_load1"
:
`sum by (node) (node_load1{job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1)`
,
"node_load5"
:
`sum by (node) (node_load5{job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1)`
,
"node_load15"
:
`sum by (node) (node_load15{job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1)`
,
"node_load1"
:
`sum by (node) (node_load1{job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1)
/ node:node_num_cpu:sum
`
,
"node_load5"
:
`sum by (node) (node_load5{job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1)
/ node:node_num_cpu:sum
`
,
"node_load15"
:
`sum by (node) (node_load15{job="node-exporter"} * on (namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:$1)
/ node:node_num_cpu:sum
`
,
//namespace
"namespace_cpu_usage"
:
`namespace:container_cpu_usage_seconds_total:sum_rate{namespace=~"$1"}`
,
"namespace_memory_usage"
:
`namespace:container_memory_usage_bytes:sum{namespace=~"$1"}`
,
"namespace_memory_usage_wo_cache"
:
`namespace:container_memory_usage_bytes_wo_cache:sum{namespace=~"$1"}`
,
"namespace_net_bytes_transmitted"
:
`sum by (namespace) (irate(container_network_transmit_bytes_total{namespace=~"$1", pod_name!="", interface="eth0", job="kubelet"}[5m]))`
,
"namespace_net_bytes_received"
:
`sum by (namespace) (irate(container_network_receive_bytes_total{namespace=~"$1", pod_name!="", interface="eth0", job="kubelet"}[5m]))`
,
"namespace_pod_count"
:
`sum(kube_pod_status_phase{namespace=~"$1"}) by (namespace)`
,
"namespace_pod_running_count"
:
`sum(kube_pod_status_phase{phase="Running", namespace=~"$1"}) by (namespace)`
,
"namespace_pod_succeeded_count"
:
`sum(kube_pod_status_phase{phase="Succeeded", namespace=~"$1"}) by (namespace)`
,
"namespace_pod_abnormal_count"
:
`sum(kube_pod_status_phase{phase=~"Failed|Pending|Unknown", namespace=~"$1"}) by (namespace)`
,
"namespace_configmap_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/configmaps"}) by (namespace, resource, type)`
,
"namespace_jobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/jobs.batch"}) by (namespace, resource, type)`
,
"namespace_roles_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/roles.rbac.authorization.k8s.io"}) by (namespace, resource, type)`
,
"namespace_memory_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="limits.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_memory_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="requests.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_cronjobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/cronjobs.batch"}) by (namespace, resource, type)`
,
"namespace_ingresses_extensions_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/ingresses.extensions"}) by (namespace, resource, type)`
,
"namespace_cpu_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="limits.cpu"}) by (namespace, resource, type)`
,
"namespace_storage_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="requests.storage"}) by (namespace, resource, type)`
,
"namespace_deployment_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/deployments.apps"}) by (namespace, resource, type)`
,
"namespace_pod_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/pods"}) by (namespace, resource, type)`
,
"namespace_statefulset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/statefulsets.apps"}) by (namespace, resource, type)`
,
"namespace_daemonset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/daemonsets.apps"}) by (namespace, resource, type)`
,
"namespace_secret_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/secrets"}) by (namespace, resource, type)`
,
"namespace_service_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/services"}) by (namespace, resource, type)`
,
"namespace_cpu_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="requests.cpu"}) by (namespace, resource, type)`
,
"namespace_service_loadbalancer_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="services.loadbalancers"}) by (namespace, resource, type)`
,
"namespace_configmap_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/configmaps"}) by (namespace, resource, type)`
,
"namespace_jobs_batch_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/jobs.batch"}) by (namespace, resource, type)`
,
"namespace_roles_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/roles.rbac.authorization.k8s.io"}) by (namespace, resource, type)`
,
"namespace_memory_limit_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="limits.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_memory_request_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="requests.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_cronjobs_batch_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/cronjobs.batch"}) by (namespace, resource, type)`
,
"namespace_ingresses_extensions_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/ingresses.extensions"}) by (namespace, resource, type)`
,
"namespace_cpu_limit_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="limits.cpu"}) by (namespace, resource, type)`
,
"namespace_storage_request_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="requests.storage"}) by (namespace, resource, type)`
,
"namespace_deployment_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/deployments.apps"}) by (namespace, resource, type)`
,
"namespace_pod_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/pods"}) by (namespace, resource, type)`
,
"namespace_statefulset_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/statefulsets.apps"}) by (namespace, resource, type)`
,
"namespace_daemonset_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/daemonsets.apps"}) by (namespace, resource, type)`
,
"namespace_secret_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/secrets"}) by (namespace, resource, type)`
,
"namespace_service_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="count/services"}) by (namespace, resource, type)`
,
"namespace_cpu_request_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="requests.cpu"}) by (namespace, resource, type)`
,
"namespace_service_loadbalancer_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
resourcequota!="quota", type="hard
", namespace=~"$1", resource="services.loadbalancers"}) by (namespace, resource, type)`
,
"namespace_cronjob_count"
:
`sum(kube_cronjob_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_pvc_count"
:
`sum(kube_persistentvolumeclaim_info{namespace=~"$1"}) by (namespace)`
,
"namespace_daemonset_count"
:
`sum(kube_daemonset_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_deployment_count"
:
`sum(kube_deployment_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_endpoint_count"
:
`sum(kube_endpoint_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_hpa_count"
:
`sum(kube_hpa_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_job_count"
:
`sum(kube_job_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_statefulset_count"
:
`sum(kube_statefulset_labels{namespace=~"$1"}) by (namespace)`
,
"namespace_replicaset_count"
:
`count(kube_replicaset_created{namespace=~"$1"}) by (namespace)`
,
"namespace_service_count"
:
`sum(kube_service_info{namespace=~"$1"}) by (namespace)`
,
"namespace_secret_count"
:
`sum(kube_secret_info{namespace=~"$1"}) by (namespace)`
,
"namespace_ingresses_extensions_count"
:
`sum(kube_ingress_labels{namespace
=~"$1"}
)`
,
"namespace_cpu_usage"
:
`namespace:container_cpu_usage_seconds_total:sum_rate{namespace
!="", namespace
=~"$1"}`
,
"namespace_memory_usage"
:
`namespace:container_memory_usage_bytes:sum{namespace
!="", namespace
=~"$1"}`
,
"namespace_memory_usage_wo_cache"
:
`namespace:container_memory_usage_bytes_wo_cache:sum{namespace
!="", namespace
=~"$1"}`
,
"namespace_net_bytes_transmitted"
:
`sum by (namespace) (irate(container_network_transmit_bytes_total{namespace
!="", namespace
=~"$1", pod_name!="", interface="eth0", job="kubelet"}[5m]))`
,
"namespace_net_bytes_received"
:
`sum by (namespace) (irate(container_network_receive_bytes_total{namespace
!="", namespace
=~"$1", pod_name!="", interface="eth0", job="kubelet"}[5m]))`
,
"namespace_pod_count"
:
`sum(kube_pod_status_phase{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_pod_running_count"
:
`sum(kube_pod_status_phase{phase="Running", namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_pod_succeeded_count"
:
`sum(kube_pod_status_phase{phase="Succeeded", namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_pod_abnormal_count"
:
`sum(kube_pod_status_phase{phase=~"Failed|Pending|Unknown", namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_configmap_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/configmaps"}) by (namespace, resource, type)`
,
"namespace_jobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/jobs.batch"}) by (namespace, resource, type)`
,
"namespace_roles_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/roles.rbac.authorization.k8s.io"}) by (namespace, resource, type)`
,
"namespace_memory_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="limits.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_memory_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="requests.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_cronjobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/cronjobs.batch"}) by (namespace, resource, type)`
,
"namespace_ingresses_extensions_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/ingresses.extensions"}) by (namespace, resource, type)`
,
"namespace_cpu_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="limits.cpu"}) by (namespace, resource, type)`
,
"namespace_storage_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="requests.storage"}) by (namespace, resource, type)`
,
"namespace_deployment_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/deployments.apps"}) by (namespace, resource, type)`
,
"namespace_pod_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/pods"}) by (namespace, resource, type)`
,
"namespace_statefulset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/statefulsets.apps"}) by (namespace, resource, type)`
,
"namespace_daemonset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/daemonsets.apps"}) by (namespace, resource, type)`
,
"namespace_secret_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/secrets"}) by (namespace, resource, type)`
,
"namespace_service_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="count/services"}) by (namespace, resource, type)`
,
"namespace_cpu_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="requests.cpu"}) by (namespace, resource, type)`
,
"namespace_service_loadbalancer_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace
!="", namespace
=~"$1", resource="services.loadbalancers"}) by (namespace, resource, type)`
,
"namespace_configmap_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/configmaps"}) by (namespace, resource, type)`
,
"namespace_jobs_batch_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/jobs.batch"}) by (namespace, resource, type)`
,
"namespace_roles_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/roles.rbac.authorization.k8s.io"}) by (namespace, resource, type)`
,
"namespace_memory_limit_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="limits.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_memory_request_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="requests.memory"}) by (namespace, resource, type)`
,
"namespace_pvc_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/persistentvolumeclaims"}) by (namespace, resource, type)`
,
"namespace_cronjobs_batch_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/cronjobs.batch"}) by (namespace, resource, type)`
,
"namespace_ingresses_extensions_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/ingresses.extensions"}) by (namespace, resource, type)`
,
"namespace_cpu_limit_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="limits.cpu"}) by (namespace, resource, type)`
,
"namespace_storage_request_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="requests.storage"}) by (namespace, resource, type)`
,
"namespace_deployment_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/deployments.apps"}) by (namespace, resource, type)`
,
"namespace_pod_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/pods"}) by (namespace, resource, type)`
,
"namespace_statefulset_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/statefulsets.apps"}) by (namespace, resource, type)`
,
"namespace_daemonset_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/daemonsets.apps"}) by (namespace, resource, type)`
,
"namespace_secret_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/secrets"}) by (namespace, resource, type)`
,
"namespace_service_count_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="count/services"}) by (namespace, resource, type)`
,
"namespace_cpu_request_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="requests.cpu"}) by (namespace, resource, type)`
,
"namespace_service_loadbalancer_hard"
:
`sum(kube_resourcequota{resourcequota!="quota",
type="hard", namespace!="
", namespace=~"$1", resource="services.loadbalancers"}) by (namespace, resource, type)`
,
"namespace_cronjob_count"
:
`sum(kube_cronjob_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_pvc_count"
:
`sum(kube_persistentvolumeclaim_info{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_daemonset_count"
:
`sum(kube_daemonset_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_deployment_count"
:
`sum(kube_deployment_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_endpoint_count"
:
`sum(kube_endpoint_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_hpa_count"
:
`sum(kube_hpa_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_job_count"
:
`sum(kube_job_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_statefulset_count"
:
`sum(kube_statefulset_labels{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_replicaset_count"
:
`count(kube_replicaset_created{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_service_count"
:
`sum(kube_service_info{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_secret_count"
:
`sum(kube_secret_info{namespace
!="", namespace
=~"$1"}) by (namespace)`
,
"namespace_ingresses_extensions_count"
:
`sum(kube_ingress_labels{namespace
!="", namespace=~"$1"}) by (namespace
)`
,
// pod
"pod_cpu_usage"
:
`sum(irate(container_cpu_usage_seconds_total{job="kubelet", namespace="$1", pod_name="$2", image!=""}[5m])) by (namespace, pod_name)`
,
...
...
@@ -496,47 +499,49 @@ var RulePromQLTmplMap = MetricMap{
"container_memory_usage_all"
:
`container_memory_usage_bytes{namespace="$1", pod_name="$2", container_name=~"$3", container_name!="POD"}`
,
// workspace
"workspace_cpu_usage"
:
`sum(namespace:container_cpu_usage_seconds_total:sum_rate{namespace =~"$1"})`
,
"workspace_memory_usage"
:
`sum(namespace:container_memory_usage_bytes:sum{namespace =~"$1"})`
,
"workspace_memory_usage_wo_cache"
:
`sum(namespace:container_memory_usage_bytes_wo_cache:sum{namespace =~"$1"})`
,
"workspace_net_bytes_transmitted"
:
`sum(sum by (namespace) (irate(container_network_transmit_bytes_total{namespace=~"$1", pod_name!="", interface="eth0", job="kubelet"}[5m])))`
,
"workspace_net_bytes_received"
:
`sum(sum by (namespace) (irate(container_network_receive_bytes_total{namespace=~"$1", pod_name!="", interface="eth0", job="kubelet"}[5m])))`
,
"workspace_pod_count"
:
`sum(kube_pod_status_phase{namespace=~"$1"})`
,
"workspace_pod_running_count"
:
`sum(kube_pod_status_phase{phase="Running", namespace=~"$1"})`
,
"workspace_pod_succeeded_count"
:
`sum(kube_pod_status_phase{phase="Succeeded", namespace=~"$1"})`
,
"workspace_pod_abnormal_count"
:
`sum(kube_pod_status_phase{phase=~"Failed|Pending|Unknown", namespace=~"$1"})`
,
"workspace_configmap_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/configmaps"}) by (resource, type)`
,
"workspace_jobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/jobs.batch"}) by (resource, type)`
,
"workspace_roles_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/roles.rbac.authorization.k8s.io"}) by (resource, type)`
,
"workspace_memory_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="limits.memory"}) by (resource, type)`
,
"workspace_pvc_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="persistentvolumeclaims"}) by (resource, type)`
,
"workspace_memory_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="requests.memory"}) by (resource, type)`
,
"workspace_pvc_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/persistentvolumeclaims"}) by (resource, type)`
,
"workspace_cronjobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/cronjobs.batch"}) by (resource, type)`
,
"workspace_ingresses_extensions_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/ingresses.extensions"}) by (resource, type)`
,
"workspace_cpu_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="limits.cpu"}) by (resource, type)`
,
"workspace_storage_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="requests.storage"}) by (resource, type)`
,
"workspace_deployment_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/deployments.apps"}) by (resource, type)`
,
"workspace_pod_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/pods"}) by (resource, type)`
,
"workspace_statefulset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/statefulsets.apps"}) by (resource, type)`
,
"workspace_daemonset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/daemonsets.apps"}) by (resource, type)`
,
"workspace_secret_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/secrets"}) by (resource, type)`
,
"workspace_service_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="count/services"}) by (resource, type)`
,
"workspace_cpu_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="requests.cpu"}) by (resource, type)`
,
"workspace_service_loadbalancer_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace=~"$1", resource="services.loadbalancers"}) by (resource, type)`
,
"workspace_ingresses_extensions_count"
:
`sum(kube_ingress_labels{namespace=~"$1"})`
,
"workspace_cronjob_count"
:
`sum(kube_cronjob_labels{namespace=~"$1"})`
,
"workspace_pvc_count"
:
`sum(kube_persistentvolumeclaim_info{namespace=~"$1"})`
,
"workspace_daemonset_count"
:
`sum(kube_daemonset_labels{namespace=~"$1"})`
,
"workspace_deployment_count"
:
`sum(kube_deployment_labels{namespace=~"$1"})`
,
"workspace_endpoint_count"
:
`sum(kube_endpoint_labels{namespace=~"$1"})`
,
"workspace_hpa_count"
:
`sum(kube_hpa_labels{namespace=~"$1"})`
,
"workspace_job_count"
:
`sum(kube_job_labels{namespace=~"$1"})`
,
"workspace_statefulset_count"
:
`sum(kube_statefulset_labels{namespace=~"$1"})`
,
"workspace_replicaset_count"
:
`count(kube_replicaset_created{namespace=~"$1"})`
,
"workspace_service_count"
:
`sum(kube_service_info{namespace=~"$1"})`
,
"workspace_secret_count"
:
`sum(kube_secret_info{namespace=~"$1"})`
,
"workspace_cpu_usage"
:
`sum(namespace:container_cpu_usage_seconds_total:sum_rate{namespace!="", namespace$1})`
,
"workspace_memory_usage"
:
`sum(namespace:container_memory_usage_bytes:sum{namespace!="", namespace$1})`
,
"workspace_memory_usage_wo_cache"
:
`sum(namespace:container_memory_usage_bytes_wo_cache:sum{namespace!="", namespace$1})`
,
"workspace_net_bytes_transmitted"
:
`sum(sum by (namespace) (irate(container_network_transmit_bytes_total{namespace!="", namespace$1, pod_name!="", interface="eth0", job="kubelet"}[5m])))`
,
"workspace_net_bytes_received"
:
`sum(sum by (namespace) (irate(container_network_receive_bytes_total{namespace!="", namespace$1, pod_name!="", interface="eth0", job="kubelet"}[5m])))`
,
"workspace_pod_count"
:
`sum(kube_pod_status_phase{namespace!="", namespace$1})`
,
"workspace_pod_running_count"
:
`sum(kube_pod_status_phase{phase="Running", namespace!="", namespace$1})`
,
"workspace_pod_succeeded_count"
:
`sum(kube_pod_status_phase{phase="Succeeded", namespace!="", namespace$1})`
,
"workspace_pod_abnormal_count"
:
`sum(kube_pod_status_phase{phase=~"Failed|Pending|Unknown", namespace!="", namespace$1})`
,
"workspace_configmap_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/configmaps"}) by (resource, type)`
,
"workspace_jobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/jobs.batch"}) by (resource, type)`
,
"workspace_roles_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/roles.rbac.authorization.k8s.io"}) by (resource, type)`
,
"workspace_memory_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="limits.memory"}) by (resource, type)`
,
"workspace_pvc_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="persistentvolumeclaims"}) by (resource, type)`
,
"workspace_memory_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="requests.memory"}) by (resource, type)`
,
"workspace_pvc_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/persistentvolumeclaims"}) by (resource, type)`
,
"workspace_cronjobs_batch_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/cronjobs.batch"}) by (resource, type)`
,
"workspace_ingresses_extensions_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/ingresses.extensions"}) by (resource, type)`
,
"workspace_cpu_limit_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="limits.cpu"}) by (resource, type)`
,
"workspace_storage_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="requests.storage"}) by (resource, type)`
,
"workspace_deployment_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/deployments.apps"}) by (resource, type)`
,
"workspace_pod_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/pods"}) by (resource, type)`
,
"workspace_statefulset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/statefulsets.apps"}) by (resource, type)`
,
"workspace_daemonset_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/daemonsets.apps"}) by (resource, type)`
,
"workspace_secret_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/secrets"}) by (resource, type)`
,
"workspace_service_count_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="count/services"}) by (resource, type)`
,
"workspace_cpu_request_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="requests.cpu"}) by (resource, type)`
,
"workspace_service_loadbalancer_used"
:
`sum(kube_resourcequota{resourcequota!="quota", type="used", namespace!="", namespace$1, resource="services.loadbalancers"}) by (resource, type)`
,
"workspace_ingresses_extensions_count"
:
`sum(kube_ingress_labels{namespace!="", namespace$1})`
,
"workspace_cronjob_count"
:
`sum(kube_cronjob_labels{namespace!="", namespace$1})`
,
"workspace_pvc_count"
:
`sum(kube_persistentvolumeclaim_info{namespace!="", namespace$1})`
,
"workspace_daemonset_count"
:
`sum(kube_daemonset_labels{namespace!="", namespace$1})`
,
"workspace_deployment_count"
:
`sum(kube_deployment_labels{namespace!="", namespace$1})`
,
"workspace_endpoint_count"
:
`sum(kube_endpoint_labels{namespace!="", namespace$1})`
,
"workspace_hpa_count"
:
`sum(kube_hpa_labels{namespace!="", namespace$1})`
,
"workspace_job_count"
:
`sum(kube_job_labels{namespace!="", namespace$1})`
,
"workspace_statefulset_count"
:
`sum(kube_statefulset_labels{namespace!="", namespace$1})`
,
"workspace_replicaset_count"
:
`count(kube_replicaset_created{namespace!="", namespace$1})`
,
"workspace_service_count"
:
`sum(kube_service_info{namespace!="", namespace$1})`
,
"workspace_secret_count"
:
`sum(kube_secret_info{namespace!="", namespace$1})`
,
"workspace_all_project_count"
:
`count(kube_namespace_annotations)`
,
}
pkg/models/metrics/util.go
浏览文件 @
f79ae414
...
...
@@ -23,6 +23,8 @@ import (
"strconv"
"unicode"
"runtime/debug"
"github.com/golang/glog"
)
...
...
@@ -50,6 +52,12 @@ func (wrapper FormatedMetricDataWrapper) Swap(i, j int) {
// sorted metric by ascending or descending order
func
Sort
(
sortMetricName
string
,
sortType
string
,
fmtLevelMetric
*
FormatedLevelMetric
,
resourceType
string
)
(
*
FormatedLevelMetric
,
int
)
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
glog
.
Errorln
(
err
)
debug
.
PrintStack
()
}
}()
if
sortMetricName
==
""
{
return
fmtLevelMetric
,
-
1
...
...
@@ -75,6 +83,12 @@ func Sort(sortMetricName string, sortType string, fmtLevelMetric *FormatedLevelM
value2
:=
(
*
q
)[
ResultItemValue
]
.
([]
interface
{})
v1
,
_
:=
strconv
.
ParseFloat
(
value1
[
len
(
value1
)
-
1
]
.
(
string
),
64
)
v2
,
_
:=
strconv
.
ParseFloat
(
value2
[
len
(
value2
)
-
1
]
.
(
string
),
64
)
if
v1
==
v2
{
resourceName1
:=
(
*
p
)[
ResultItemMetric
]
.
(
map
[
string
]
interface
{})[
resourceType
]
resourceName2
:=
(
*
q
)[
ResultItemMetric
]
.
(
map
[
string
]
interface
{})[
resourceType
]
return
resourceName1
.
(
string
)
<
resourceName2
.
(
string
)
}
return
v1
<
v2
}})
}
else
{
...
...
@@ -84,6 +98,13 @@ func Sort(sortMetricName string, sortType string, fmtLevelMetric *FormatedLevelM
value2
:=
(
*
q
)[
ResultItemValue
]
.
([]
interface
{})
v1
,
_
:=
strconv
.
ParseFloat
(
value1
[
len
(
value1
)
-
1
]
.
(
string
),
64
)
v2
,
_
:=
strconv
.
ParseFloat
(
value2
[
len
(
value2
)
-
1
]
.
(
string
),
64
)
if
v1
==
v2
{
resourceName1
:=
(
*
p
)[
ResultItemMetric
]
.
(
map
[
string
]
interface
{})[
resourceType
]
resourceName2
:=
(
*
q
)[
ResultItemMetric
]
.
(
map
[
string
]
interface
{})[
resourceType
]
return
resourceName1
.
(
string
)
>
resourceName2
.
(
string
)
}
return
v1
>
v2
}})
}
...
...
@@ -110,7 +131,13 @@ func Sort(sortMetricName string, sortType string, fmtLevelMetric *FormatedLevelM
}
}
for
resource
,
_
:=
range
currentResourceMap
{
var
keys
[]
string
for
k
:=
range
currentResourceMap
{
keys
=
append
(
keys
,
k
)
}
sort
.
Strings
(
keys
)
for
_
,
resource
:=
range
keys
{
if
_
,
exist
:=
indexMap
[
resource
];
!
exist
{
indexMap
[
resource
]
=
i
i
=
i
+
1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录