This section will walk you through the process of installing Prometheus, Grafana, and AlertManager using the Prometheus Operator. Follow these steps to set up the monitoring stack on your Kubernetes cluster.
To begin, clone the Prometheus Operator repository and change your current directory to the installation directory:
git clone https://github.com/prometheus-operator/kube-prometheus.git && cd kube-prometheus
Execute the following commands to create the necessary namespace and Custom Resource Definitions (CRDs) for Prometheus Operator:
# Create the namespace and CRDs, then wait for them to become available before proceeding.
kubectl create -f manifests/setup
# Wait until the "servicemonitors" CRD is created. A message of "No resources found" indicates success.
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
# Create the remaining resources.
kubectl create -f manifests/
Wait until all pods have a running
status by running:
kubectl get po -A -w
In separate terminal windows, run the following commands to expose the services:
kubectl --namespace monitoring port-forward svc/prometheus-k8s 9090
kubectl --namespace monitoring port-forward svc/alertmanager-main 9093
kubectl --namespace monitoring port-forward svc/grafana 3000
After successfully exposing the services, you can access the following UIs in your web browser:
- Prometheus: http://localhost:9090
- AlertManager: http://localhost:9093
- Grafana: http://localhost:3000
That's it! You have now installed and configured Prometheus, Grafana, and AlertManager on your Kubernetes cluster using Prometheus Operator.
For more information visit the official Documentation