Install kube-prometheus on AKS

In this post, I’m going to install kube-prometheus on AKS. The process is clearly documented at the kube-prometheus Github page. Here, I’m just going to use the ‘quickstart’ and later I plan to cover other topics such as ingress and customization.

Pre-requisites:

  • A Kubernetes cluster. In this example I’m using AKS, but similar steps could be done with other providers or with self-hosted Kubernetes.
  • kubectl

Helpful links:

Do this:

Clone the Github repo.

git clone https://github.com/prometheus-operator/kube-prometheus.git

Create the monitoring stack.

# Create the namespace and CRDs, and then wait for them to be available before creating the remaining resources
# Note that due to some CRD size we are using kubectl server-side apply feature which is generally available since kubernetes 1.22.
# If you are using previous kubernetes versions this feature may not be available and you would need to use kubectl create instead.
kubectl apply --server-side -f manifests/setup
kubectl wait \
	--for condition=Established \
	--all CustomResourceDefinition \
	--namespace=monitoring
kubectl apply -f manifests/

Confirm your pods are running.

❯ k get pod -n monitoring
NAME                                   READY   STATUS    RESTARTS   AGE
alertmanager-main-0                    2/2     Running   0          116m
alertmanager-main-1                    2/2     Running   0          116m
alertmanager-main-2                    2/2     Running   0          116m
blackbox-exporter-58c9c5ff8d-qpbpw     3/3     Running   0          116m
grafana-6b4547d9b8-hhf52               1/1     Running   0          116m
kube-state-metrics-6d454b6f84-jx4sv    3/3     Running   0          116m
node-exporter-98hvs                    2/2     Running   0          116m
node-exporter-mq2db                    2/2     Running   0          116m
node-exporter-qzfvn                    2/2     Running   0          116m
prometheus-adapter-678b454b8b-ldmht    1/1     Running   0          116m
prometheus-adapter-678b454b8b-npqwz    1/1     Running   0          116m
prometheus-k8s-0                       2/2     Running   0          116m
prometheus-k8s-1                       2/2     Running   0          116m
prometheus-operator-66d95b9b84-kwgbf   2/2     Running   0          116m

Connect to Grafana using a port-forward.

kubectl --namespace monitoring port-forward svc/grafana 3000

Access http://localhost:3000 with a browser. The default Grafana login is admin:admin and you’ll be prompted to change that upon first login.

There’s lots of great data surfaced in the Grafana dashboards; have a look around!

Leave a comment

Close Bitnami banner
Bitnami