# Grafana Guide for the Monitoring Stack

## What You'll Learn

- How Grafana connects to Prometheus and Loki
- Why provisioning dashboards and data sources as files matters
- What makes a dashboard useful during an incident

Grafana provides the dashboards and log views for the monitoring lab.

## Important Files

- `grafana/provisioning/datasources/datasources.yml`
- `grafana/provisioning/dashboards/dashboards.yml`
- `grafana/dashboards/node-exporter-full.json` — downloaded during [lab setup](<https://computecentral.in/monitoring-tools/overview/index.md#2-grafana>)

## What Happens Automatically

Grafana is provisioned on startup, so you do not need to create data sources and dashboards by hand every time.

That usually gives you:

- A Prometheus data source
- A Loki data source
- A ready-made dashboard for the stack

## Why Provisioning Matters

- Keeps dashboards reproducible
- Prevents manual drift
- Makes reviews easier because changes live in Git

## What to Validate

- Prometheus data source is healthy
- Loki data source is healthy
- Dashboards load without broken panels
- Panels show useful host, container, and probe metrics

## Good Dashboard Areas

- CPU, memory, disk, and network
- Container resource trends
- Prometheus target health
- Probe success rate
- Recent logs from Loki
- Alert summary

## Make Dashboards Useful During Incidents

Organize dashboards from user impact to infrastructure cause: availability and error rate first, then latency, dependencies, resources, logs, and recent deploy events. Use variables for environment, cluster, service, and instance. Add panel links that open a filtered Loki query or trace view so an operator can investigate without rebuilding context.

Avoid a dashboard that only shows system CPU. Include an application-level signal such as request rate, error rate, latency percentile, queue lag, or successful business operations.

## Quick Check

```bash
docker compose logs -f grafana
curl http://localhost:3000/api/health
```

Default login:

- Username: `admin`
- Password: `admin`

## FAQ

### What is Grafana used for?

Grafana is used to build dashboards, explore metrics and logs, and make system health easier to understand during normal operations and incidents.

### Does Grafana store metrics?

Grafana usually visualizes data from other systems. In this stack, metrics come from [Prometheus](<https://computecentral.in/monitoring-tools/prometheus/index.md>) and logs come from [Loki](<https://computecentral.in/monitoring-tools/logging/index.md>).

### Why provision Grafana dashboards?

Provisioning keeps data sources and dashboards reproducible. It also lets teams review dashboard changes in Git instead of relying on manual UI edits.

### What should a good monitoring dashboard show?

A useful dashboard shows service health, latency or probe success, resource usage, error signals, recent logs, and alert context without overwhelming the operator.

## Related Learning

- [Prometheus guide](<https://computecentral.in/monitoring-tools/prometheus/index.md>)
- [Loki logging with Grafana Alloy](<https://computecentral.in/monitoring-tools/logging/index.md>)
- [Monitoring stack troubleshooting](<https://computecentral.in/monitoring-tools/troubleshooting/index.md>)

## Common Mistakes

- Building dashboards by hand in the UI with no provisioning, so they're lost or drift between environments.
- Dashboards with dozens of panels and no clear question they answer.
- Not linking metrics panels to the related logs, so every investigation starts from scratch.
- Using Grafana as the alerting source of truth without deciding how it relates to Prometheus rules and Alertmanager.

## Interview Questions

- Does Grafana store metrics? Where does the data live?
- Why provision dashboards and data sources from files?
- What should the first row of a service dashboard show?

## Next

Continue to [Alertmanager](<https://computecentral.in/monitoring-tools/alertmanager/index.md>).
