---
title: "Building a Custom Metrics Exporter for Kubernetes"
description: "A Prometheus metrics exporter is a small HTTP server exposing application state on /metrics, letting Kubernetes workloads surface signals like queue depth or job latency beyond CPU and memory."
url: "https://swe.quest/articles/building-a-custom-metrics-exporter-for-kubernetes-7836d8b667c498c8"
canonical: "https://kubernetes.io/blog/2026/07/14/custom-metrics-exporter-kubernetes/"
source: "Kubernetes Blog"
published: "2026-07-14"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["observability","kubernetes","go","containers"]
---

# Building a Custom Metrics Exporter for Kubernetes

A post on [Kubernetes Blog](https://swe.quest/sources/kubernetes.md), published 2026-07-14, 8 min read, How-to. Original: [https://kubernetes.io/blog/2026/07/14/custom-metrics-exporter-kubernetes/](https://kubernetes.io/blog/2026/07/14/custom-metrics-exporter-kubernetes/)

## Summary

A Prometheus metrics exporter is a small HTTP server exposing application state on /metrics, letting Kubernetes workloads surface signals like queue depth or job latency beyond CPU and memory. A Go exporter built with client\_golang registers a counter, gauge and histogram named \<namespace\>\_\<name\>\_\<unit\>, refreshes them in a polling loop shorter than the 15s scrape interval, and serves a separate /healthz probe. The setup ships as a multi-stage distroless image, runs as a Deployment plus a named-port Service, and is scraped via a ServiceMonitor whose release label must match the Prometheus selector, or via annotation-based discovery. Prometheus Adapter is the next step for feeding these metrics to the HorizontalPodAutoscaler.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)

## Prerequisites

- Kubernetes Deployments and Services ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- Prometheus basics
- Go basics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- Docker images ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))

## Keywords

Prometheus, client\_golang, Prometheus Operator, ServiceMonitor, kube-prometheus-stack, HorizontalPodAutoscaler, Prometheus Adapter, distroless

## Related posts

- [Enhanced ClickHouse Cloud Monitoring with Prometheus](https://swe.quest/articles/enhanced-clickhouse-cloud-monitoring-with-prometheus-685ab688b94dfba3.md): ClickHouse · 2024-07-16 · Medium · 7 min read · Observability, Analytics & OLAP, Cloud platforms
  ClickHouse Cloud now exposes a Prometheus metrics endpoint through its Cloud API, authenticated with organization-level Developer API keys.
- [Kubernetes v1.37: Native Histograms Graduates to Beta](https://swe.quest/articles/kubernetes-v1-37-native-histograms-graduates-to-beta-7573f3677609dcf5.md): Kubernetes Blog · 2026-09-11 · Medium · 5 min read · Observability, Kubernetes
  Kubernetes v1.37 promotes native histogram support (KEP-5808) to Beta, on by default, so control plane and node components expose Prometheus Native Histograms with exponential buckets alongside classic ones.
- [Kubernetes v1.37: Metrics API graduates to stable](https://swe.quest/articles/kubernetes-v1-37-metrics-api-graduates-to-stable-9cf296727e7fc487.md): Kubernetes Blog · 2026-08-27 · Medium · 2 min read · Kubernetes, Observability, API design
  Kubernetes v1.37 graduates the metrics.k8s.io resource Metrics API, which supplies node and Pod CPU and memory usage to kubectl top and the HorizontalPodAutoscaler, to stable v1.
- [Monitor your ClickHouse Cloud services with the new Prometheus/Grafana Mix-in](https://swe.quest/articles/monitor-your-clickhouse-cloud-services-with-the-new-prometheus-grafana-mix-in-d5de8c9f127ab682.md): ClickHouse · 2025-05-12 · Medium · 3 min read · Observability, Analytics & OLAP, Cloud platforms
  ClickHouse Cloud now offers a Prometheus/Grafana mix-in: a pre-built Grafana dashboard, nearly identical to ClickHouse's internal one, fed by the cloud API's Prometheus endpoint.
- [Kubernetes v1.37: Scale Workloads to Zero with HorizontalPodAutoscaler](https://swe.quest/articles/kubernetes-v1-37-scale-workloads-to-zero-with-horizontalpodautoscaler-d8e25c817e5e1444.md): Kubernetes Blog · 2026-09-02 · Medium · 5 min read · Kubernetes, Capacity planning, Cost optimization
  Kubernetes v1.37 promotes HPA scale-to-zero to Beta and enables it by default, so a HorizontalPodAutoscaler with minReplicas: 0 can scale workloads to zero and back based on object or external metrics such as queue length.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
