What is Grafana?
- Docker & Kubernetes course
- Advanced
- Lesson 51/70
- 4 min
Learn visualization with Grafana.
What is Grafana?
Grafana visualizes metrics from data sources like Prometheus (and Loki, Elasticsearch) in dashboards. kube-prometheus-stack installs Grafana with ready dashboards for the cluster, nodes, pods and namespaces:
kubectl port-forward -n izleme svc/izleme-grafana 3000:80
# browser: http://localhost:3000
kubectl get secret -n izleme izleme-grafana -o jsonpath='{.data.admin-password}' | base64 -dDashboards can be exported as JSON and kept under version control with a ConfigMap (a sidecar loads them automatically).
A good dashboard
Service dashboards usually follow the RED method: Rate (request rate), Errors (error rate), Duration (response time). Infrastructure dashboards follow USE: Utilization, Saturation, Errors:
Rate: sum(rate(http_requests_total[5m]))
Errors: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))
Duration: histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))Practice Connect to Grafana
Write two commands: take the admin-password value from the izleme-grafana Secret in izleme with jsonpath and decode it with base64 -d; forward local port 3000 to port 80 of the svc/izleme-grafana service in izleme.
Starter code
# buraya yazSample solution
kubectl get secret -n izleme izleme-grafana -o jsonpath='{.data.admin-password}' | base64 -d
kubectl port-forward -n izleme svc/izleme-grafana 3000:80Expected output
prom-operator Forwarding from 127.0.0.1:3000 -> 3000
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the division of labour between Prometheus and Grafana?
- Prometheus collects and stores; Grafana queries and visualizes Correct answer
- Grafana collects; Prometheus displays
- Both do the same job
- Grafana collects logs
Explanation: Grafana doesn't store metrics by itself.
2 Open Grafana on local port 3000.
kubectl ____ -n izleme svc/izleme-grafana 3000:80
kubectl port-forward -n izleme svc/izleme-grafana 3000:80
Explanation: port-forward also opens a tunnel to a service.
3 Match.
| Term | Meaning |
|---|---|
Rate |
Request rate |
Errors |
Error rate |
Duration |
Response time |
USE |
Infrastructure method |