Docker Compose service
- image — uses the official
grafana/grafana:latestimage. - ports — maps host port
3000to container port3000, making the Grafana UI available athttp://localhost:3000. - environment — sets the admin password via the
GF_SECURITY_ADMIN_PASSWORDenvironment variable.
Default login
The default credentials for this stack are:| Field | Value |
|---|---|
| Username | admin |
| Password | admin |
Changing the admin password
To set a different password, update the environment variable indocker-compose.yml:
Adding datasources
Grafana must be connected to Prometheus and Loki before you can query data or build dashboards. Use the following internal URLs — both use Docker’s internal DNS, so the connections work entirely inside the Docker network:| Datasource | URL |
|---|---|
| Prometheus | http://prometheus:9090 |
| Loki | http://loki:3100 |
Open the datasource settings
Log in to Grafana at
http://localhost:3000. In the left sidebar, go to Connections → Data sources.Add a new data source
Click Add new data source and select the datasource type (for example, Prometheus).
Enter the connection URL
In the URL field, enter the internal address for the datasource. Use
http://prometheus:9090 for Prometheus or http://loki:3100 for Loki.Save and test
Click Save & test. Grafana sends a probe request to the datasource and confirms the connection is working.
Building a dashboard
Once your datasources are configured you can create a dashboard to visualize metrics and logs:Add a visualization
Click Add visualization and choose a datasource — select Prometheus to query metrics or Loki to query logs.
Write a query
Enter a PromQL expression (for Prometheus) or a LogQL expression (for Loki) in the query editor. For example, use
{job="varlogs"} to display all logs collected by Promtail.