Kubernetes Cost Monitoring with Prometheus & Grafana

Screenshot of a Grafana dashboard to calculate costs

Setting Up Prometheus Operator

kubectl create namespace monitoring
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm search repo prometheus-community
Screenshot of the output listing possible Helm packages to install
helm install prometheus-stack --namespace monitoring prometheus-community/kube-prometheus-stack
kubectl get pod --namespace=monitoring
Output from the “kubectl get pods” command
  • prometheus-stack-grafana-* - the Grafana dashboard
  • prometheus-prometheus-kube-prometheus-prometheus-0 - the Prometheus instance
kubectl port-forward <prometheus-pod> 9090 --address=0.0.0.0
kubectl port-forward <grafana-pod> 3000 --address=0.0.0.0
Screenshot of the Prometheus TSDB status

Monitoring Your Cost

(sum(container_cpu_usage_seconds_total) / 60 / 60 ) * 0.0445
Screenshot of the results of that Prometheus query

Alternative Options

--

--

--

>> www.loft.sh << Build Your Internal Kubernetes Platform With Virtual Clusters, Namespace Self-Service & Secure Multi-Tenancy

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Overcoming Go’s summer-time localization issues

What is Difference between Ruby Blocks, Procs and Lambdas

Flash Stock Rom on Lava A48

11111

Observability in the realm of Chaos Engineering

Deep linking React Native — iOS and Android using Branch

branch.io — dashboard

« Give me anything to learn and I’m happy 😉 » Wazana.io’s founder interview: Valentin, 26.

A Declarative Java ORM Speaks Fluent SQL

The Rise Of Integrations

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Loft Labs

Loft Labs

>> www.loft.sh << Build Your Internal Kubernetes Platform With Virtual Clusters, Namespace Self-Service & Secure Multi-Tenancy

More from Medium

Terraform vs Kubernetes — Everything You Need To Know

Creating your own Template in Monokle

Will That Kubernetes v1.22 Upgrade Break My Application?

Streamlining your Kubernetes adoption with Helmfile / ArgoCD and GitOps

Photo of a playground