Kamu Wajib Tahu Best Practice Logging Management

Logging Management dari Nol: console.log → Centralized Logging (Alloy → Loki → Grafana)

Lognya jalan lancar di laptop sendiri, semua hijau, kelihatan aman. Justru itu jebakannya. Di video ini kita bedah pelan-pelan kenapa `console.log` nggak cukup, terus naik bertahap sampai punya centralized logging yang beneran kepakai pas aplikasi di-scale ke banyak container.

Studi kasusnya 2 microservice kecil (order-service & payment-service) jalan di Bun, dibungkus container pakai Podman, dan log-nya dikumpulin ke Grafana Loki lewat Grafana Alloy.

💻 SOURCE CODE (GITHUB)
https://github.com/ProgrammerZamanNow/logging-management-demo

Tiap babak ada di branch-nya sendiri, tinggal checkout buat ngikutin:
- Babak 1 (console.log) ......... git checkout 01-console-log
- Babak 2 (structured logging) .. git checkout 02-proper-logging
- Babak 3 (di-scale) ............ git checkout 03-scale
- Babak 4 (centralized logging) . git checkout 04-centralized

⏱️ TIMELINE
00:00 — Pendahuluan
02:05 — Bagian 1 Titik Awal
08:49 — Bagian 2 Beresin Lognya di Aplikasi
21:27 — Bagian 3 Pas di-scale mulai kacau
28:32 — Bagian 4 Centralized Logging
36:13 — Kesimpulan

📌 YANG DIBAHAS
- Kenapa `console.log` jadi masalah: log nggak rapi buat mesin, bisa bocorin data sensitif (password), dan nggak bisa dilacak antar service.
- Structured logging: log berbentuk JSON, ada level (info/warn/error), sensor data sensitif (redact), dan pasang requestId buat ngelacak satu request ujung ke ujung.
- Masalah pas di-scale: log kececer di banyak container, hilang pas container restart, dan risiko disk penuh kalau nulis ke file. Makanya: stdout only, jangan ke file.
- Centralized logging ala 12-Factor App: aplikasi cukup buang log ke stdout, infrastruktur yang ngumpulin (Alloy), nyimpen (Loki), dan nyediain pencarian (Grafana).
- Label vs structured metadata di Loki: kenapa requestId TIDAK dijadikan label (high cardinality explosion), dan cara nyimpen field cardinality-tinggi yang tetap bisa difilter.
- Kenapa pakai Grafana Alloy, bukan Promtail (Promtail sudah disetop 2 Maret 2026).

🧰 STACK & TOOLS
- Bun (runtime + HTTP server)
- Pino (structured logging)
- Podman + podman-compose (container)
- nginx (load balancer)
- Grafana Alloy (pengumpul log)
- Grafana Loki (penyimpan & mesin query)
- Grafana + LogQL (pencarian & dashboard)

✅ ATURAN MAIN LOGGING
1. Pakai library logging + level, jangan console.log
2. Lognya JSON
3. Sensor data sensitif (redact)
4. Pasang requestId buat ngelacak
5. Buang ke stdout, jangan ke file
6. Kirim ke centralized logging (Alloy → Loki → Grafana)

#logging #observability #grafana #loki #podman #microservices #devops #bun


JOIN PREMIUM : https://www.youtube.com/ProgrammerZamanNow/join

DISCORD PREMIUM : https://www.youtube.com/post/UgxBHnvjdwwAioDHe0x4AaABCQ

Donasi :
Saweria : https://saweria.co/ProgrammerZamanNow

Social Media :
Instagram : https://www.instagram.com/ProgrammerZamanNow
Facebook : https://www.facebook.com/ProgrammerZamanNow
Telegram : https://t.me/ProgrammerZamanNow
Youtube : https://www.youtube.com/c/ProgrammerZamanNow Receive SMS online on sms24.me

TubeReader video aggregator is a website that collects and organizes online videos from the YouTube source. Video aggregation is done for different purposes, and TubeReader take different approaches to achieve their purpose.

Our try to collect videos of high quality or interest for visitors to view; the collection may be made by editors or may be based on community votes.

Another method is to base the collection on those videos most viewed, either at the aggregator site or at various popular video hosting sites.

TubeReader site exists to allow users to collect their own sets of videos, for personal use as well as for browsing and viewing by others; TubeReader can develop online communities around video sharing.

Our site allow users to create a personalized video playlist, for personal use as well as for browsing and viewing by others.

@YouTubeReaderBot allows you to subscribe to Youtube channels.

By using @YouTubeReaderBot Bot you agree with YouTube Terms of Service.

Use the @YouTubeReaderBot telegram bot to be the first to be notified when new videos are released on your favorite channels.

Look for new videos or channels and share them with your friends.

You can start using our bot from this video, subscribe now to Kamu Wajib Tahu Best Practice Logging Management

What is YouTube?

YouTube is a free video sharing website that makes it easy to watch online videos. You can even create and upload your own videos to share with others. Originally created in 2005, YouTube is now one of the most popular sites on the Web, with visitors watching around 6 billion hours of video every month.