-
Run
kubectl create namespace monitoringto create amonitoringnamespace. -
Run
kubectl create -f ./ -Rto get kube-state-metrics, Grafana, and Prometheus resources in place. -
Visit http://localhost:30000 to view Prometheus.
-
Click on Graph. Select a metric from the drop-down (next to the Execute button) and then click Execute. You can switch between the Graph view and Console view.
-
Visit http://localhost:32000 to view the Grafana dashboard.
-
Login with
adminandadminfor the username and password. You can reset the password on the next screen or clickSkip. -
On the
Welcome to Grafanapage clickNew dashboard. -
Click the drop-down item named
Homein the upper-left corner of the screen. -
Select
Import dashboardfrom the available options. -
Enter an ID value of
10000into theGrafana.com Dashboardtextbox and clickLoad. This will load theCluster Monitoring for Kubernetesdashboard.Note: You can find a list of pre-configured dashboards at https://grafana.com/grafana/dashboards. Each one will have an id you can copy into the Grafana
Import dashboardscreen. -
On the next screen you'll see a
Select a Prometheus data sourcedrop-down. Selectprometheusfrom the list and clickImport. Your dashboard will now load. -
Click on the
Cluster Monitoring for Kubernetesdrop-down in the uppper-left corner of the screen. Go back through the steps to import a dashboard but this time enter an ID of8588. This will load theKubernetes Deployment Statefulset Daemonset metricsdashboard. -
If you click on the dashboard name drop-down in the upper-left corner of the screen you'll see both of your dashboards listed and can now switch between them.
-
Import the dashboard with an ID of
10694. This dashboard is calledContainer Statistics. -
From here you can load other dashboards or create your own!
NOTE: The Metrics Server YAML has been modified to enable it to run in more simple Kubernetes scenarios like Docker Desktop. Details about the modifications made can be found at https://blog.codewithdan.com/enabling-metrics-server-for-kubernetes-on-docker-desktop. You'll want to remove the --kubelet-insecure-tls arg in metrics-server/kubernetes/metrics-server-deployment.yaml for more real-world scenarios.
To remove all of the monitoring resources run kubectl delete -f ./ -R.
Get more details on Prometheus at https://prometheus.io/docs/prometheus/latest/getting_started and https://devopscube.com/setup-prometheus-monitoring-on-kubernetes.
A list of Pod Metrics provided by kube-state-metrics can be found at https://github.com/kubernetes/kube-state-metrics/blob/master/docs/pod-metrics.md.
Another option for getting Prometheus going using only Docker Compose and Docker Swarm can be found at:
https://github.com/vegasbrianc/prometheus
The yaml files used here were originally created by Bibin Wilson (thanks for the great work Bibin!) and documented at: