We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Visualizing Metrics

Now let's install and configure Grafana. This is where metrics become fun, at least for those of us who like pretty, colorful charts and graphs.

Assignment

Install Grafana and connect it to Prometheus.

  1. grafana:
      image: grafana/grafana:latest
      ports:
        - "3000:3000"
      environment:
        - GF_SECURITY_ADMIN_PASSWORD=admin
      volumes:
        - grafana_data:/var/lib/grafana
    
    And make sure your compose file has a top-level volume declaration:
    volumes:
      grafana_data:
    

    Persist Grafana state with a named volume (grafana_data) so your data source and dashboards survive restarts. In production, back this storage with durable infrastructure and avoid wiping it with commands like docker compose down -v.

  2. docker compose up
    
  3. Out of the box, Grafana is an empty (and potentially confusing) interface. We'll fix that quickly by adding a useful dashboard to monitor your operating system.

    1. In the left sidebar, click Connections -> Data sources
    2. Click Add data source and choose Prometheus
    3. Set the URL to http://prometheus:9090
    4. Click Save & test
    1. In the left sidebar, click Dashboards.
    2. Click New -> Import in the top right.
    3. Enter dashboard ID 1860 and click Load
    4. Set the dashboard name to Host System Metrics
    5. Click Import
    6. Confirm you can see CPU, memory, disk, and network metrics in the imported dashboard. These are the metrics for your local machine!

Run and submit the CLI tests from the root of the Linko repo.