Lab 11.2 - Creating Custom Dashboards
Lab Objectives
By the end of this lab, you will be able to:
- Create a custom dashboard in Grafana.
- Add panels with Prometheus metrics.
- Use PromQL for queries.
- Configure basic alerts.
Estimated Duration
45-60 minutes
Prerequisites
- Prometheus and Grafana installed (Lab 11.1).
- Access to the Grafana interface.
Part 1: Creating a Dashboard
Step 1.1: Access Grafana
Port-forward to Grafana:
kubectl port-forward -n monitoring svc/prometheus-grafana 3000:80
Log in at http://localhost:3000.
Step 1.2: Create a New Dashboard
- Click "+" → "Create Dashboard".
- Click "Add visualization".
- Select "Prometheus" as the data source.
Part 2: Adding Panels
Step 2.1: CPU Usage Panel
Create a panel for CPU usage:
- In the query field, enter:
rate(container_cpu_usage_seconds_total[5m]) - Set the title: "CPU Usage".
- Save the panel.
Step 2.2: Memory Usage Panel
Create a panel for memory:
- Query:
container_memory_usage_bytes - Title: "Memory Usage".
- Format: "Bytes".
Part 3: Advanced Configuration
Step 3.1: Adding Labels
Use queries with labels:
sum(rate(container_cpu_usage_seconds_total{namespace="default"}[5m])) by (pod)
Step 3.2: Time Series Graphs
Configure a time series graph to visualize the evolution.
Part 4: Basic Alerts
Step 4.1: Create an Alert
- In a panel, click "Alert".
- Configure the condition (e.g., CPU > 80%).
- Define the alert message.
Lab Summary
In this lab, you created custom dashboards in Grafana with Prometheus metrics. You learned how to use PromQL and configure alerts.
Next Steps
The next lab will show you how to configure logging with Fluentd/Fluent Bit.
Lab 11.3: Logging Configuration
Lab created on: December 2024