Skip to main content

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

  1. Click "+" → "Create Dashboard".
  2. Click "Add visualization".
  3. Select "Prometheus" as the data source.

Part 2: Adding Panels

Step 2.1: CPU Usage Panel

Create a panel for CPU usage:

  1. In the query field, enter:
    rate(container_cpu_usage_seconds_total[5m])
  2. Set the title: "CPU Usage".
  3. Save the panel.

Step 2.2: Memory Usage Panel

Create a panel for memory:

  1. Query:
    container_memory_usage_bytes
  2. Title: "Memory Usage".
  3. 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

  1. In a panel, click "Alert".
  2. Configure the condition (e.g., CPU > 80%).
  3. 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