Skip to content

Commit

Permalink
update cpu/mem usage (labring#5008)
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyxjh authored and zjy365 committed Sep 3, 2024
1 parent e0159fc commit ff3d0dc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions service/pkg/api/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ type Stats struct {

var (
Mysql = map[string]string{
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"#\",pod=~\"@-mysql-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\",pod=~\"@-mysql-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-mysql-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\", pod=~\"@-mysql-\\\\d\"}) by (pod) * 100, 0.01)",
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"#\",pod=~\"@-mysql-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"#\",pod=~\"@-mysql-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-mysql-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"#\", pod=~\"@-mysql-\\\\d\"}) by (pod) * 100, 0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"}))",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mysql-\\\\d\"})) * 100, 0.01)",
Expand All @@ -88,8 +88,8 @@ var (
"table_locks": "sum(rate(mysql_global_status_table_locks_immediate{namespace=~\"#\", app_kubernetes_io_instance=~\"@\"}[1m])) by (namespace,app_kubernetes_io_instance,pod)",
}
Pgsql = map[string]string{
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"#\",pod=~\"@-postgresql-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\",pod=~\"@-postgresql-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-postgresql-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\", pod=~\"@-postgresql-\\\\d\"}) by (pod) * 100, 0.01)",
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"#\",pod=~\"@-postgresql-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"#\",pod=~\"@-postgresql-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-postgresql-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"#\", pod=~\"@-postgresql-\\\\d\"}) by (pod) * 100, 0.01)",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"})) * 100, 0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"}))",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-postgresql-\\\\d\"}))",
Expand All @@ -108,8 +108,8 @@ var (
}

Mongo = map[string]string{
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"#\",pod=~\"@-mongodb-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\",pod=~\"@-mongodb-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-mongodb-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\", pod=~\"@-mongodb-\\\\d\"}) by (pod) * 100, 0.01)",
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"#\",pod=~\"@-mongodb-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"#\",pod=~\"@-mongodb-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-mongodb-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"#\", pod=~\"@-mongodb-\\\\d\"}) by (pod) * 100, 0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"})) * 100, 0.01)",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-mongodb-\\\\d\"}))",
Expand All @@ -124,8 +124,8 @@ var (
}

Redis = map[string]string{
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"#\",pod=~\"@-redis-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\",pod=~\"@-redis-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-redis-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\", pod=~\"@-redis-\\\\d\"}) by (pod) * 100, 0.01)",
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"#\",pod=~\"@-redis-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"#\",pod=~\"@-redis-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-redis-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"#\", pod=~\"@-redis-\\\\d\"}) by (pod) * 100, 0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"})) * 100, 0.01)",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-redis-\\\\d\"}))",
Expand All @@ -149,8 +149,8 @@ var (
}

Kafka = map[string]string{
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster!=\"\", namespace=~\"#\",pod=~\"@-kafka-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\",pod=~\"@-kafka-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",cluster!=\"\", namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-kafka-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{cluster!=\"\", namespace=~\"#\", pod=~\"@-kafka-\\\\d\"}) by (pod) * 100, 0.01)",
"cpu": "round(sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{namespace=~\"#\",pod=~\"@-kafka-\\\\d\"}) by (pod) / sum(cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits{namespace=~\"#\",pod=~\"@-kafka-\\\\d\"}) by (pod)*100,0.01)",
"memory": "round(sum(container_memory_working_set_bytes{job=\"kubelet\", metrics_path=\"/metrics/cadvisor\",namespace=~\"#\",container!=\"\", image!=\"\",pod=~\"@-kafka-\\\\d\"}) by(pod) / sum(cluster:namespace:pod_memory:active:kube_pod_container_resource_limits{namespace=~\"#\", pod=~\"@-kafka-\\\\d\"}) by (pod) * 100, 0.01)",
"disk_capacity": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-(kafka-broker|kafka-server)-\\\\d\"}))",
"disk": "round((max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-(kafka-broker|kafka-server)-\\\\d\"})) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-(kafka-broker|kafka-server)-\\\\d\"})) * 100, 0.01)",
"disk_used": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes {namespace=~\"#\", persistentvolumeclaim=~\"data-@-(kafka-broker|kafka-server)-\\\\d\"}))",
Expand Down

0 comments on commit ff3d0dc

Please sign in to comment.