gitwtfhub

wtf is kube-state-metrics?

metalmatze/kube-state-metrics — explained in plain English

Analysis updated 2026-07-18 · repo last pushed 2020-10-23

GoAudience · ops devopsComplexity · 3/5DormantSetup · moderate

TL;DR

A monitoring tool that watches a Kubernetes cluster's objects (pods, deployments, nodes) and exposes their state as metrics for Prometheus.

Mindmap

mindmap
  root((repo))
    What it does
      Tracks cluster object state
      Exposes Prometheus metrics
      Reads Kubernetes API
    Tech stack
      Go
      Kubernetes
      Prometheus
    Use cases
      Cluster health dashboards
      Deployment alerts
      Node status tracking
    Audience
      DevOps engineers
      SRE teams

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Build a Prometheus alert that fires when a deployment doesn't have its expected replica count.

REASON 2

Create a dashboard tracking how many Kubernetes nodes are in a 'not ready' state.

REASON 3

Get a raw, unfiltered inventory of every object in a large cluster for monitoring.

What's in the stack?

GoKubernetesPrometheus

How it stacks up

metalmatze/kube-state-metrics42wim/fabio42wim/go-xmpp
LanguageGoGoGo
Last pushed2020-10-232018-02-042020-01-24
MaintenanceDormantDormantDormant
Setup difficultymoderatemoderatemoderate
Complexity3/53/53/5
Audienceops devopsops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · moderate Time to first run · 30min

Needs a running Kubernetes cluster and a Prometheus-compatible scraper to be useful.

Wtf does this do

Kube-state-metrics is a monitoring tool that watches your Kubernetes cluster and reports what's happening to it. Instead of measuring CPU usage or response times, it focuses on tracking the state of things like deployments, pods, nodes, and other Kubernetes objects, whether they exist, how many replicas are running, what labels they have, and so on. Think of it as a detailed inventory system for everything in your cluster. The tool works by continuously connecting to your Kubernetes API server and reading the current state of all your cluster objects. It then converts this information into metrics, a standardized format that monitoring systems like Prometheus can understand and store. These metrics are exposed on a simple web endpoint that Prometheus (or any compatible monitoring tool) can scrape periodically, usually every 15-30 seconds. The key insight is that kube-state-metrics reports raw, unfiltered data directly from Kubernetes, without trying to interpret or summarize it the way the kubectl command-line tool does. Teams use this when they want to build alerts and dashboards around cluster health and resource management. For example, a DevOps engineer might use these metrics to alert when a deployment doesn't have the expected number of replicas running, or to track how many nodes are in a "not ready" state. It's particularly useful in large clusters where manual inspection is impractical, and it integrates naturally with existing Prometheus-based monitoring stacks. One practical consideration: as your cluster grows, kube-state-metrics consumes more memory and CPU to track all those objects. The README suggests starting with about 200MB of memory and 0.1 CPU cores for smaller clusters, then scaling up as needed. For very large clusters, you can run multiple copies of kube-state-metrics and shard the work among them, so each instance only tracks a subset of your objects.

Yoink these prompts

Prompt 1
Explain how kube-state-metrics turns Kubernetes API data into Prometheus metrics.
Prompt 2
Show me a Prometheus alert rule using kube-state-metrics to catch under-replicated deployments.
Prompt 3
Help me size the memory and CPU needed to run kube-state-metrics on my cluster.
Prompt 4
Walk me through sharding kube-state-metrics across multiple instances for a very large cluster.

Frequently asked questions

wtf is kube-state-metrics?

A monitoring tool that watches a Kubernetes cluster's objects (pods, deployments, nodes) and exposes their state as metrics for Prometheus.

What language is kube-state-metrics written in?

Mainly Go. The stack also includes Go, Kubernetes, Prometheus.

Is kube-state-metrics actively maintained?

Dormant — no commits in 2+ years (last push 2020-10-23).

How hard is kube-state-metrics to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is kube-state-metrics for?

Mainly ops devops.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.