tutorial

Monitoring Kubecost: A Practical Guide for FinOps Engineers

Kubecost is the go-to platform for Kubernetes cost allocation, providing granular visibility into spend across namespaces, deployments, labels, and cloud pro...

Kubecost is the go-to platform for Kubernetes cost allocation, providing granular visibility into spend across namespaces, deployments, labels, and cloud providers. When Kubecost itself goes dark — whether its ETL pipeline stalls, Prometheus scrapes lag, or the UI becomes unavailable — your cost attribution data becomes stale and unreliable. This guide walks through monitoring Kubecost's critical components and integrating Vigilmon for end-to-end uptime coverage.

Why Monitoring Kubecost Matters

FinOps teams rely on Kubecost to make budget decisions, chargeback allocations, and right-sizing recommendations. A silent failure in Kubecost's data pipeline can lead to:

  • Cost anomalies going undetected for hours or days
  • Stale allocation data corrupting monthly chargeback reports
  • ETL pipeline backlogs that take hours to catch up
  • Silent Prometheus scrape failures causing metric gaps

Unlike application monitoring, Kubecost monitoring is often an afterthought. The result: you discover the platform was broken when you need the data most — at month-end or during a budget review.

Core Components to Monitor

1. Cost Allocation API Health

The /model/allocation endpoint is Kubecost's primary API surface. A healthy response confirms the aggregation pipeline is processing data:

# Basic health probe
curl -sf "http://kubecost-cost-analyzer.kubecost.svc.cluster.local:9090/model/allocation?window=1d&aggregate=namespace" | \
  jq '.status'

Expected output: "success". If you get "error" or a non-2xx HTTP status, the aggregation engine is failing.

For a more targeted check, query the allocation summary and validate the response contains your expected namespaces:

# Validate allocation data freshness
curl -sf "http://kubecost-cost-analyzer.kubecost.svc.cluster.local:9090/model/allocation?window=1h&aggregate=namespace" | \
  jq '.data[0] | keys | length'

A return value of 0 with a 200 status typically means the ETL pipeline is lagging behind.

2. Prometheus Metrics Freshness

Kubecost depends on Prometheus for its underlying metrics. Stale Prometheus data directly degrades cost accuracy:

# Check Prometheus scrape freshness via Kubecost's built-in endpoint
curl -sf "http://kubecost-cost-analyzer.kubecost.svc.cluster.local:9090/prometheusQuery?query=up" | \
  jq '.data.result | length'

You can also query Prometheus directly for Kubecost-specific metrics:

# Check if Kubecost metrics are being scraped
up{job="kubecost"}

# Monitor metric staleness
(time() - timestamp(container_cpu_usage_seconds_total)) > 300

If container_cpu_usage_seconds_total is more than 5 minutes stale, Kubecost's cost calculations will be incorrect.

3. ETL Pipeline Status

The ETL (Extract, Transform, Load) pipeline processes raw Prometheus data into cost allocation records. Monitor its health directly:

# Query ETL pipeline status
curl -sf "http://kubecost-cost-analyzer.kubecost.svc.cluster.local:9090/model/etl/asset/status" | \
  jq '.data.resolution'

Watch for coverage drops — if coverage falls below your expected window, the pipeline is not keeping up:

# Check coverage percentage
curl -sf "http://kubecost-cost-analyzer.kubecost.svc.cluster.local:9090/model/etl/asset/status" | \
  jq '.data.progress'

A Kubernetes CronJob can alert when the ETL falls behind:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: kubecost-etl-health-check
  namespace: kubecost
spec:
  schedule: "*/15 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: checker
            image: curlimages/curl:latest
            command:
            - /bin/sh
            - -c
            - |
              STATUS=$(curl -sf http://kubecost-cost-analyzer:9090/model/etl/asset/status | \
                jq -r '.data.progress // "0"')
              echo "ETL Progress: $STATUS"
              [ "$STATUS" = "1" ] || exit 1
          restartPolicy: Never

4. UI Availability

The Kubecost frontend is served on port 9090. A simple HTTP check confirms the UI is reachable:

curl -sf -o /dev/null -w "%{http_code}" \
  http://kubecost-cost-analyzer.kubecost.svc.cluster.local:9090/overview

If you expose Kubecost via an Ingress, check the public URL as well.

Prometheus Alerting Rules

Deploy these rules to catch Kubecost failures before they impact reporting:

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: kubecost-alerts
  namespace: kubecost
spec:
  groups:
  - name: kubecost
    rules:
    - alert: KubecostAPIDown
      expr: probe_success{job="kubecost-api"} == 0
      for: 5m
      labels:
        severity: critical
      annotations:
        summary: "Kubecost allocation API is unreachable"
        description: "The Kubecost /model/allocation endpoint has been failing for 5 minutes."

    - alert: KubecostMetricsStale
      expr: (time() - timestamp(container_cpu_usage_seconds_total)) > 600
      for: 10m
      labels:
        severity: warning
      annotations:
        summary: "Kubecost Prometheus metrics are stale"
        description: "Cost metrics are more than 10 minutes behind — allocation accuracy is degraded."

    - alert: KubecostPodNotReady
      expr: kube_pod_status_ready{namespace="kubecost", condition="true"} == 0
      for: 5m
      labels:
        severity: critical
      annotations:
        summary: "Kubecost pod is not ready"

Integrating Vigilmon for End-to-End Uptime Monitoring

Internal Kubernetes checks are great for catching infrastructure-level issues, but they don't tell you if Kubecost is reachable from outside the cluster — where your finance team, cloud FinOps dashboards, or CI cost-gate tools actually connect from.

Vigilmon provides HTTP/HTTPS uptime monitoring with alerting that works from outside your cluster:

  1. Log in to Vigilmon and navigate to Monitors → New Monitor.
  2. Add your Kubecost public endpoint — typically the Ingress or LoadBalancer URL you expose for the dashboard.
  3. Set check interval to 1 minute for fast detection of outages.
  4. Configure keyword assertion: add a keyword check for "Kubecost" or "200 OK" to validate the response body, not just HTTP status.
  5. Set up alerting: connect Slack, PagerDuty, or email so your FinOps team is paged immediately when Kubecost goes dark.

For teams exposing the API externally, add a second monitor targeting the allocation endpoint:

https://kubecost.yourdomain.com/model/allocation?window=1h&aggregate=namespace

Set a JSON keyword assertion to check for "status":"success" — this validates the full data pipeline, not just HTTP reachability.

Key Metrics Summary

| Component | What to Monitor | Alert Threshold | |-----------|----------------|-----------------| | Allocation API | HTTP 200 + valid JSON | Any failure for >5m | | ETL Pipeline | Coverage/progress | Progress < 1.0 for >15m | | Prometheus metrics | Data freshness | Staleness > 10m | | UI availability | HTTP 200 on /overview | Any failure for >5m | | Pod readiness | kube_pod_status_ready | 0 ready pods for >5m |

Conclusion

Kubecost is critical infrastructure for FinOps teams — when it fails silently, budget decisions are made on bad data. Layering internal Prometheus alerts with Vigilmon's external HTTP monitoring gives you complete coverage: internal failures get caught by alerting rules, while external reachability and full-pipeline validation is handled by Vigilmon's continuous uptime checks. Set it up once and you'll never be caught with stale cost data at month-end again.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →