Pre-requisites
Kubernetes Cluster:
- Have a running Kubernetes cluster. #### kubectl:
- Installed and configured to interact with your cluster. #### Helm:
- Installed, for easier package deployment.
Deployment
Step 1: Install Prometheus Operator
- Open your terminal and run:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus prometheus-community/kube-prometheus-stack
Step 2: Check Installation
- Confirm that Prometheus is running.
kubectl get pods -n default
Step 3: Configure Service Monitors
-
Create a
service-monitor.yaml
file and specify what you need.
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: sap-service-monitor
spec:
endpoints:
- port: http-metrics
selector:
matchLabels:
app: sap-service
- Apply the Service Monitor.
kubectl apply -f service-monitor.yaml
Step 4: Open Prometheus Dashboard
- Use port-forwarding to access the dashboard.
kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090
-
Open
http://localhost:9090/targets
. You should see your SAP service.
Usage
Step 1: Access Grafana
- Port-forward to Grafana.
kubectl port-forward svc/prometheus-grafana 3000:80
-
Open
http://localhost:3000
. Default login isadmin/admin
.
Step 2: Import Dashboard
- Go to Dashboards > Import and pick a Kubernetes-focused dashboard.
Step 3: Set Alerts
-
In Prometheus, go to
Alerts
and set your rules.
Step 4: Test
- Deploy a busy pod or two and watch the metrics to validate the setup.
And there you go! This guide should help you monitor Kubernetes clusters in an SAP environment with Prometheus.
Top comments (0)