Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 1.74 KB

File metadata and controls

71 lines (55 loc) · 1.74 KB

Loki agent (Docker)

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

Install on the application server

# 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-agent

On devops.local first:

make setup          # LOKI_PUSH_*
make monitoring
make middleware

Your application (Docker)

No 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 up

Example app+agent together: examples/spring-boot/.

Verify

Grafana → Explore → Loki:

{host="appserver-01"}
{container="note-keeper"}
{job="docker"}

Files

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)