Introduction

kube-state-metrics (KSM) is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects. It is focused on the health of the various objects inside, such as deployments, nodes and pods.

The metrics are exported on the HTTP endpoint /metrics on the listening port (default 8080). They are served as plaintext. They are designed to be consumed either by Prometheus itself or by a scraper that is compatible with scraping a Prometheus client endpoint.

Global Template

Assign following template to Microk8s Master or Microk8s integration resource under Infrastructure > Resources > Microk8s page.

Collector Type: Agent

Category: Application Monitors

G2 Monitor Name: Agent G2 - Linux - Kubernetes State

Global Template Name: Agent G2 - Linux - Kubernetes State

Collected Metrics

Metric NameDisplay NameDescriptionUnits
kubernetes_state.container.cpu_limitContainer Cpu LimitThe limit on CPU cores to be used by a container.cpu
kubernetes_state.container.cpu_requestedContainer Cpu RequestedThe number of requested cpu cores by a container.cpu
kubernetes_state.container.memory_limitContainer Memory LimitThe limit on memory to be used by a container.bytes
kubernetes_state.container.memory_requestedContainer Memory RequestedThe number of requested memory bytes by a container.
kubernetes_state.container.readyContainer ReadyDescribes whether the containers readiness check succeeded.
kubernetes_state.container.ready.totalTotal Containers ReadyTotal containers whose readiness check succeeded.
kubernetes_state.container.restartsContainer RestartsThe number of restarts per container.
kubernetes_state.container.restarts.totalTotal Containers Restarts CountTotal containers restarts count .
kubernetes_state.container.runningContainer RunningDescribes whether the container is currently in running state.
kubernetes_state.container.running.totalTotal Containers RunningTotal containers currently in running state.
kubernetes_state.container.terminatedContainer TerminatedDescribes whether the container is currently in terminated state.
kubernetes_state.container.terminated.totalTotal Containers TerminatedTotal containers currently in terminated state.
kubernetes_state.container.waitingContainer WaitingWhether the container is currently in waiting state.
kubernetes_state.container.waiting.totalTotal Containers WaitingTotal containers currently in waiting state.
kubernetes_state.daemonset.desiredDaemonset DesiredThe number of nodes that should be running the daemon pod.
kubernetes_state.daemonset.misscheduledDaemonset MisscheduledThe number of nodes running a daemon pod but are not supposed to.
kubernetes_state.daemonset.readyDaemonset ReadyThe number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready.
kubernetes_state.daemonset.scheduledDaemonset ScheduledThe number of nodes running at least one daemon pod and are supposed to.
kubernetes_state.deployment.pausedDeployment PausedWhether the deployment is paused and will not be processed by the deployment controller.
kubernetes_state.deployment.replicasDeployment ReplicasThe number of replicas per deployment.
kubernetes_state.deployment.replicas_availableDeployment Replicas AvailableThe number of available replicas per deployment.
kubernetes_state.deployment.replicas_desiredDeployment Replicas DesiredThe number of desired replicas per deployment wrong help in kube-state-metrics.cross check.
kubernetes_state.deployment.replicas_unavailableDeployment Replicas UnavailableThe number of unavailable replicas per deployment.
kubernetes_state.deployment.replicas_updatedDeployment Replicas UpdatedThe number of updated replicas per deployment.
kubernetes_state.deployment.rollingupdate.max_unavailableDeployment Rollingupdate Max UnavailableMaximum number of unavailable replicas during a rolling update of a deployment.
kubernetes_state.node.cpu_allocatableNode Cpu AllocatableThe CPU resources of a node that are available for scheduling.
kubernetes_state.node.cpu_capacityNode Cpu CapacityThe total CPU resources of the node.cpu
kubernetes_state.node.memory_allocatableNode Memory AllocatableThe memory resources of a node that are available for scheduling.bytes
kubernetes_state.node.memory_capacityNode Memory CapacityThe total memory resources of the node.bytes
kubernetes_state.node.pods_allocatableNode Pods AllocatableThe pod resources of a node that are available for scheduling.
kubernetes_state.node.pods_capacityNode Pods CapacityThe total pod resources of the node.
kubernetes_state.node.statusNode StatusThe condition of a cluster node.Sum this metric by either status to get the number of nodes in that status.
kubernetes_state.pod.readyPod ReadyDescribes whether the pod is ready to serve requests.In association with the `condition` tag, whether the pod is ready to serve requests, e.g. `condition:true` keeps the pods that are in a ready state.
kubernetes_state.pod.scheduledPod ScheduledDescribes the status of the scheduling process for the pod.
kubernetes_state.replicaset.fully_labeled_replicasReplicaset Fully Labeled ReplicasThe number of fully labeled replicas per ReplicaSet.
kubernetes_state.replicaset.replicasReplicaset ReplicasThe number of replicas per ReplicaSet.
kubernetes_state.replicaset.replicas_desiredReplicaset Replicas DesiredNumber of desired pods for a ReplicaSet.
kubernetes_state.replicaset.replicas_readyAuthentReplicaset Replicas ReadyThe number of ready replicas per ReplicaSet.
kubernetes_state.resourcequota.limits.cpu.limitResourcequota Limits Cpu LimitHard limit on the sum of CPU core limits for a resource quota.cpu
kubernetes_state.resourcequota.limits.cpu.usedResourcequota Limits Cpu UsedObserved sum of limits for CPU cores for a resource quota.cpu
kubernetes_state.resourcequota.limits.memory.limitResourcequota Limits Memory LimitHard limit on the sum of memory bytes limits for a resource quota.bytes
kubernetes_state.resourcequota.limits.memory.usedResourcequota Limits Memory UsedObserved sum of limits for memory bytes for a resource quota.bytes
kubernetes_state.resourcequota.persistentvolumeclaims.limitResourcequota Persistentvolumeclaims LimitHard limit of the number of PVC for a resource quota.
kubernetes_state.resourcequota.persistentvolumeclaims.usedResourcequota Persistentvolumeclaims UsedObserved number of persistent volume claims used for a resource quota.
kubernetes_state.resourcequota.pods.limitResourcequota Pods LimitHard limit of the number of pods for a resource quota.
kubernetes_state.resourcequota.pods.usedResourcequota Pods UsedObserved number of pods used for a resource quota.
kubernetes_state.resourcequota.requests.cpu.limitResourcequota Requests Cpu LimitHard limit on the total of CPU core requested for a resource quota.cpu
kubernetes_state.resourcequota.requests.cpu.usedResourcequota Requests Cpu UsedObserved sum of CPU cores requested for a resource quota.cpu
kubernetes_state.resourcequota.requests.memory.limitResourcequota Requests Memory LimitHard limit on the total of memory bytes requested for a resource quota.bytes
kubernetes_state.resourcequota.requests.memory.usedResourcequota Requests Memory UsedObserved sum of memory bytes requested for a resource quota.bytes
kubernetes_state.resourcequota.requests.storage.limitResourcequota Requests Storage LimitHard limit on the total of storage bytes requested for a resource quota.bytes
kubernetes_state.resourcequota.requests.storage.usedResourcequota Requests Storage UsedObserved sum of storage bytes requested for a resource quota.bytes
kubernetes_state.resourcequota.services.limitResourcequota Services LimitHard limit of the number of services for a resource quota.
kubernetes_state.resourcequota.services.loadbalancers.limitResourcequota Services Loadbalancers LimitHard limit of the number of loadbalancers for a resource quota.
kubernetes_state.resourcequota.services.loadbalancers.usedResourcequota Services Loadbalancers UsedObserved number of loadbalancers used for a resource quota.
kubernetes_state.resourcequota.services.nodeports.limitResourcequota Services Nodeports LimitHard limit of the number of node ports for a resource quota.
kubernetes_state.resourcequota.services.nodeports.usedResourcequota Services Nodeports UsedObserved number of node ports used for a resource quota.
kubernetes_state.resourcequota.services.usedResourcequota Services UsedObserved number of services used for a resource quota.

Validate

Navigate to Infrastructure > Resources tab to check if your resources are onboarded and the metrics are collected.