Desenvolvimento
Loki Docker Compose: test the outage before rollout
December 4, 2026
Why it matters
Centralized logs become useful when an incident crosses boundaries. A failed request may leave evidence in the reverse proxy, the application container, and the Linux host. Bringing those records into Grafana can shorten the path from a vague symptom to an explanation you can check.
My adoption criterion would be whether the setup remains useful during a failure. Christian Lempa demonstrates the plumbing with Loki, Grafana, Traefik, and Authentik. I would extend that walkthrough with an acceptance test: disconnect the logging backend, keep the application running, and account for the events afterward.
One change matters when following this February 2025 tutorial today: Promtail reached end of life on March 2, 2026. I would use Alloy for a new deployment and plan a migration for an existing one. Grafana states the maintenance status in its Promtail documentation.
Key points
- 03:21 Metrics and logs provide different evidence. Resource utilization helps locate a change in behavior; event records help explain what happened around it. Having both makes an investigation easier to narrow down.
- 05:00 Labels shape the index. Loki organizes retrieval around metadata attached to log streams. Choosing those labels affects how easily you can find the source involved in an incident.
- 07:11 Local storage keeps the demonstration approachable. Once the records matter operationally, capacity, recovery, and availability need explicit decisions alongside the storage location.
- 09:56 Monolithic deployment reduces the initial component count. The tutorial uses it to get started. I would validate its suitability against actual query patterns and hardware rather than treating a daily ingestion figure as a guarantee.
- 15:33 Exposing Loki introduces an access boundary. A reverse proxy provides a controlled entry point, provided the backend cannot also be reached through an unprotected route.
- 19:59 Displayed severity can misread a message. The presence of the word “error” is imperfect evidence. Reading the original event and neighboring records remains part of diagnosis.
- 23:18 Collection can be enabled per container. That supports a gradual rollout: start with useful sources, measure their volume, and expand deliberately.
- 25:33 A logging destination can affect Docker operations. The tutorial addresses driver blocking by changing retries, timeouts, and delivery behavior. This deserves a failure test before wider use.
- 28:56 Encrypted transport still needs access controls. A valid certificate protects the connection. Deciding who may read or submit records requires additional configuration.
- 34:30 Machine identities should have their own boundaries. The author recommends a dedicated user but uses an administrative account for the demonstration. I would follow the dedicated-account recommendation.
- 38:24 Host collection extends coverage beyond containers. Promtail reads files under
/var/login the demonstration. Applying the idea today requires a supported collector and verification of the host’s actual log sources. - 42:26 Retention remains unfinished work. The closing discussion establishes the tutorial’s scope: successful ingestion is the beginning of operating a logging system with a sustainable storage footprint.
How to apply
Loki Docker Compose: define a useful pilot
Pick one application and one incident question, such as why a particular request failed. Include its reverse proxy records, application output, and one relevant Linux service. Time an investigation using your current tools so you have a baseline for comparison.
I would begin in staging with a monolithic Loki instance and persistent storage. Pin image versions and keep a record of the configuration used. The author’s templates are useful starting material, but check them against the documentation for the release you select.
Collect with Alloy and keep local evidence
For a new setup, evaluate Alloy’s Docker collector alongside its file or journal sources. Grafana’s Alloy ingestion guide describes these building blocks. If collection requires the Docker socket, treat that as privileged access and restrict who can modify the collector.
Check where host events actually live. A /var/log mount does not establish coverage for services writing to the systemd journal. Keep a local troubleshooting path and configure log rotation so you can compare events produced at the source with events received centrally.
If you retain the Loki Docker driver shown in the video, review its documented Docker blocking limitation. Non-blocking delivery can drop records when its buffer fills, as explained in the Docker logging documentation. Decide what loss is acceptable for the workload before relying on it.
Make a known event easy to find
Start with a small label set such as service_name, env, and host. Configure those fields in the collector and inspect their received values. Avoid indexing request IDs, email addresses, and similarly variable values as stream labels. Grafana recommends low-cardinality labels.
Have the application emit a recognizable message, such as loki-test-001, and search a narrow time window:
{service_name="checkout", env="staging"} |= "loki-test-001"This assumes the collector supplies those labels. The |= operator filters line content, as documented in the LogQL reference. Compare the original timestamp with Grafana’s display. Record the time zone explicitly when people investigating the same incident work in different regions.
Rehearse a backend outage
In staging, generate 100 numbered events and retain their identifiers locally. Block access to Loki for two minutes while the application continues receiving requests. Restore connectivity and compare the local and central records.
| Exercise | Evidence required to pass | |---|---| | Logging backend unavailable | Application stays within its agreed service target | | Container restart | Service restarts without an indefinite wait | | Connectivity restored | Fresh events become visible again | | Event comparison | Missing and duplicate identifiers are accounted for |
Write down recovery time and any gaps. Do not assume that retaining a local file means its contents will automatically be replayed. Verify the selected pipeline’s behavior and document how someone would retrieve records that never reached central storage.
Check access boundaries and storage behavior
Attempt reads and writes without credentials; both should be rejected. Check that Loki’s internal port cannot bypass the proxy. In the demonstrated architecture, the authentication boundary sits in front of the backend, consistent with Loki’s authentication guidance.
Use a dedicated collector identity and separate query credentials. If you require independent read and write permissions, enforce and test endpoint rules. Different usernames alone do not establish that separation. Likewise, an .env file needs appropriate permissions and exclusion from version control.
Choose an initial operational retention period that matches your investigation needs. Fourteen days could be a pilot decision. Retention deletion requires the Compactor and its configuration; free disk space does not automatically determine cleanup. Follow the retention documentation and verify deletion after the configured period and processing delays.
Measure actual disk growth over representative days. At an observed 0.8 GB per day, fourteen days would be roughly 11.2 GB; a hypothetical 50% allowance would bring the initial estimate to 16.8 GB. Use that as a monitoring starting point and revise it as traffic changes.
I would expand collection when the pilot demonstrates faster incident investigation, understood failure behavior, and storage growth that fits the operating budget. That provides a concrete reason to add the next host.
Resources mentioned
- Grafana Loki · Sistema de agregação demonstrado; versão open source auto-hospedada.
- Grafana OSS · Interface usada para conectar a fonte Loki e consultar os registros.
- Boilerplates de Christian Lempa · Templates usados no tutorial; a estrutura atual pode diferir daquela apresentada.
- Loki Docker Driver · Plugin demonstrado para enviar logs dos containers; consulte a limitação de bloqueio.
- Grafana Alloy · Apresentado como sucessor do Promtail; alternativa atual para a coleta.
- Promtail · Coletor demonstrado para Linux; chegou ao fim de vida em 02/03/2026.
- Traefik Proxy · Proxy open source usado na demonstração para TLS e integração de autenticação.
- Authentik e Proxy Outpost · Autenticação demonstrada com proxy provider e senha de aplicativo; possui edição open source.
- Prometheus · Sistema de métricas explicado como complemento; há tutorial recomendado na descrição.