Standalone Grafana Alloy container. It reads logs from Docker on the app server and pushes them to Loki on devops.local.
[ your app containers ] --stdout--> Docker
|
loki-agent (this compose)
|
HTTPS /loki/api/v1/push
|
devops.local
# copy folder stacks/monitoring/agent → /opt/loki-agent
scp -r stacks/monitoring/agent user@appserver:/opt/loki-agent
ssh user@appserver
cd /opt/loki-agent
curl -fk https://devops.local/ca.crt -o ca.crt
cp .env.example .env
# edit LOKI_PUSH_PASSWORD and AGENT_HOST
mkdir -p /var/log/apps # optional, for file-based apps
docker compose up -d
docker logs -f loki-agentOn devops.local first:
make setup # LOKI_PUSH_*
make monitoring
make middlewareNo agent inside the app image. Log to stdout.
# next to your app, or on the same host — agent is separate
services:
note-keeper:
image: note-keeper:latest
container_name: note-keeper
# logs go to Docker logging driver → loki-agent picks them upExample app+agent together: examples/spring-boot/.
Grafana → Explore → Loki:
{host="appserver-01"}
{container="note-keeper"}
{job="docker"}
| File | Role |
|---|---|
docker-compose.yml |
Alloy container + docker.sock |
config.alloy |
scrape Docker logs + optional files |
.env |
push URL / credentials / host label |
ca.crt |
portal CA (curl https://devops.local/ca.crt) |