Skip to content

Commit

Permalink
Prometheu: add more metrics (#800)
Browse files Browse the repository at this point in the history
* feat(platform,monitor): add more metrics for k8s node

Signed-off-by: Feng Kun <[email protected]>

* feat(platform,monitor): add more k8s cluster metrics

Signed-off-by: Feng Kun <[email protected]>
  • Loading branch information
kevinfeng committed Oct 11, 2020
1 parent 2e08b9d commit ebab1d7
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/monitor/controller/prometheus/yamls.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,42 @@ groups:
- record: k8s_cluster_node_num
expr: count(kube_node_info)

- record: k8s_cluster_node_not_ready_num
expr: count(k8s_node_status_ready) - count(k8s_node_status_ready == 1)

- record: k8s_cluster_node_not_ready_rate
expr: k8s_cluster_node_not_ready_num / count(k8s_node_status_ready) * 100

- record: k8s_cluster_pod_status_phase_failed_num
expr: count(kube_pod_status_phase{phase="Failed"} == 1)

- record: k8s_cluster_pod_status_phase_failed_rate
expr: count(kube_pod_status_phase{phase="Failed"} == 1) / count(kube_pod_status_phase{phase="Failed"}) * 100

- record: k8s_cluster_pod_status_phase_pending_num
expr: count(kube_pod_status_phase{phase="Pending"} == 1)

- record: k8s_cluster_pod_status_phase_pending_rate
expr: count(kube_pod_status_phase{phase="Pending"} == 1) / count(kube_pod_status_phase{phase="Pending"}) * 100

- record: k8s_cluster_pod_status_phase_running_num
expr: count(kube_pod_status_phase{phase="Running"} == 1)

- record: k8s_cluster_pod_status_phase_running_rate
expr: count(kube_pod_status_phase{phase="Running"} == 1) / count(kube_pod_status_phase{phase="Running"}) * 100

- record: k8s_cluster_pod_status_phase_succeeded_num
expr: count(kube_pod_status_phase{phase="Succeeded"} == 1)

- record: k8s_cluster_pod_status_phase_succeeded_rate
expr: count(kube_pod_status_phase{phase="Succeeded"} == 1) / count(kube_pod_status_phase{phase="Succeeded"}) * 100

- record: k8s_cluster_pod_status_phase_unknown_num
expr: count(kube_pod_status_phase{phase="Unknown"} == 1)

- record: k8s_cluster_pod_status_phase_unknown_rate
expr: count(kube_pod_status_phase{phase="Unknown"} == 1) / count(kube_pod_status_phase{phase="Unknown"}) * 100

- record: k8s_cluster_pod_num
expr: sum(k8s_node_pod_num)

Expand Down
36 changes: 36 additions & 0 deletions pkg/platform/controller/addon/prometheus/yamls.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,42 @@ groups:
- record: k8s_cluster_node_num
expr: count(kube_node_info)

- record: k8s_cluster_node_not_ready_num
expr: count(k8s_node_status_ready) - count(k8s_node_status_ready == 1)

- record: k8s_cluster_node_not_ready_rate
expr: k8s_cluster_node_not_ready_num / count(k8s_node_status_ready) * 100

- record: k8s_cluster_pod_status_phase_failed_num
expr: count(kube_pod_status_phase{phase="Failed"} == 1)

- record: k8s_cluster_pod_status_phase_failed_rate
expr: count(kube_pod_status_phase{phase="Failed"} == 1) / count(kube_pod_status_phase{phase="Failed"}) * 100

- record: k8s_cluster_pod_status_phase_pending_num
expr: count(kube_pod_status_phase{phase="Pending"} == 1)

- record: k8s_cluster_pod_status_phase_pending_rate
expr: count(kube_pod_status_phase{phase="Pending"} == 1) / count(kube_pod_status_phase{phase="Pending"}) * 100

- record: k8s_cluster_pod_status_phase_running_num
expr: count(kube_pod_status_phase{phase="Running"} == 1)

- record: k8s_cluster_pod_status_phase_running_rate
expr: count(kube_pod_status_phase{phase="Running"} == 1) / count(kube_pod_status_phase{phase="Running"}) * 100

- record: k8s_cluster_pod_status_phase_succeeded_num
expr: count(kube_pod_status_phase{phase="Succeeded"} == 1)

- record: k8s_cluster_pod_status_phase_succeeded_rate
expr: count(kube_pod_status_phase{phase="Succeeded"} == 1) / count(kube_pod_status_phase{phase="Succeeded"}) * 100

- record: k8s_cluster_pod_status_phase_unknown_num
expr: count(kube_pod_status_phase{phase="Unknown"} == 1)

- record: k8s_cluster_pod_status_phase_unknown_rate
expr: count(kube_pod_status_phase{phase="Unknown"} == 1) / count(kube_pod_status_phase{phase="Unknown"}) * 100

- record: k8s_cluster_pod_num
expr: sum(k8s_node_pod_num)

Expand Down

0 comments on commit ebab1d7

Please sign in to comment.