惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
B
Blog RSS Feed
GbyAI
GbyAI
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
D
Docker
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recorded Future
Recorded Future
美团技术团队
The Register - Security
The Register - Security
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
量子位
B
Blog
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
L
LangChain Blog
Latest news
Latest news
S
SegmentFault 最新的问题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cisco Talos Blog
Cisco Talos Blog
F
Full Disclosure
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
W
WeLiveSecurity
T
Tenable Blog
T
Tor Project blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Membangun Observability GBIM: Metrics Bisnis, Correlation ID, dan k6 Smoke Test
Vincent Davi · 2026-05-20 · via DEV Community

Judul

Membangun Observability GBIM: Metrics Bisnis, Correlation ID, dan k6 Smoke Test

Ringkasan

Iterasi monitoring GBIM akhirnya difokuskan pada tiga hal yang benar-benar bisa dibuktikan dari implementasi saat ini: custom metrics Prometheus, correlation ID end-to-end, dan k6 smoke test yang mengirim telemetry ke Prometheus/Grafana. Frontend juga menambahkan analytics event GA4 sebagai sinyal aktivitas pengguna, tetapi bukti utama untuk CPL 6 tetap berada pada Prometheus, Grafana, k6, dan log request.

Masalah Awal

Sebelum perubahan monitoring ini, stack Prometheus dan Grafana sudah ada, tetapi bukti observability masih kurang kuat:

  • Endpoint metrics masih lebih banyak menampilkan telemetry HTTP generik, belum banyak outcome bisnis GBIM.
  • Dashboard k6 masih berisiko kosong karena belum ada alur yang konsisten untuk menjalankan k6 dan menulis hasilnya ke Prometheus remote write.
  • Request dari frontend ke backend belum mudah ditelusuri saat error karena correlation ID belum konsisten dibawa, divalidasi, dan dikembalikan.
  • Aktivitas penting pengguna seperti registrasi, aktivasi akun, verifikasi akun admin, dan update status pengajuan belum punya sinyal monitoring yang eksplisit.

Batasan Klaim

Bagian ini penting supaya klaim monitoring sesuai dengan yang benar-benar dikerjakan.

Yang diklaim selesai:

  • Backend mengekspos /api/metrics dan custom metric gbm_*.
  • Prometheus/Grafana membaca metric backend dan metric k6.
  • k6 smoke test tersedia sebagai script dan Kubernetes Job.
  • Frontend mengirim X-Correlation-ID, backend memvalidasi/menghasilkan ID, lalu mengembalikannya di response.
  • Backend log memakai corr_id melalui logging filter.
  • Frontend analytics helper GA4 tersedia dan dibatasi untuk host/environment yang diizinkan.

Solusi yang Dibangun

1. Backend Metrics

Backend menambahkan custom metric Prometheus untuk flow yang penting secara operasional. Metric utama berada di monitoring/metrics.py dan dinaikkan dari flow autentikasi, aktivasi, verifikasi akun admin, serta update status pengajuan admin.

Metric yang menjadi fokus:

  • gbm_auth_register_total{role,outcome}
  • gbm_auth_activation_total{outcome}
  • gbm_auth_reactivation_total{outcome}
  • gbm_auth_email_send_duration_seconds{event,outcome}
  • gbm_admin_account_verification_total{action,outcome}
  • gbm_pengajuan_admin_status_update_total{status,outcome}

Selain itu, beberapa domain lain juga memiliki metric khusus seperti account verification, pengajuan service, kegiatan, dan document upload. Dengan metric ini, Grafana tidak hanya membaca request HTTP, tetapi juga bisa menjawab pertanyaan bisnis seperti:

  • Berapa banyak registrasi yang sukses atau gagal validasi?
  • Apakah aktivasi akun sering gagal karena token invalid, expired, atau rate limited?
  • Apakah admin verification gagal pada list, detail, atau update status?
  • Apakah update status pengajuan gagal karena validasi, data tidak ditemukan, atau error service?

2. Correlation ID End-to-End

Frontend menambahkan header X-Correlation-ID dari lib/api.ts pada request API normal dan refresh token. Backend memiliki CorrelationIdMiddleware yang:

  1. Membaca header X-Correlation-ID dari request.
  2. Menerima nilai yang valid jika berbentuk UUID.
  3. Mengganti nilai yang kosong/tidak valid dengan UUID baru.
  4. Menyimpan ID ke context logging.
  5. Mengembalikan ID yang sama di response header X-Correlation-ID.

Log backend memakai CorrelationIdFilter, sehingga format log memiliki field corr_id. Dampaknya, ketika frontend mendapatkan error dari backend, correlation ID di response bisa langsung dipakai untuk mencari log request yang sama di backend.

3. k6 Smoke Test dan Dashboard Grafana

k6 dipakai untuk membuat telemetry performa yang bisa masuk ke dashboard Grafana. Implementasinya terdiri dari:

  • Script k6/monitoring-smoke.js.
  • Kubernetes Job k8s/job/k6-monitoring-smoke.yaml.
  • Output k6 experimental-prometheus-rw.
  • Remote write ke http://prometheus:9090/api/v1/write.
  • Tag testid=monitoring-smoke agar metric k6 mudah difilter di Grafana.
  • Prometheus dijalankan dengan argumen --web.enable-remote-write-receiver.

Smoke test k6 memukul endpoint yang relevan untuk monitoring:

  • /api/monitoring/health/
  • /api/metrics
  • /api/auth/activation/?token=... untuk skenario token invalid/rate-limited
  • optional register Kaprodi jika ENABLE_REGISTER_FLOW=true

Script k6 juga mengirim X-Correlation-ID dan X-Forwarded-Proto: https, sehingga request synthetic tetap mengikuti pola observability dan konfigurasi reverse proxy/SSL yang dipakai backend.

4. Frontend Analytics sebagai Sinyal Tambahan

Frontend menambahkan helper lib/analytics.ts untuk mengirim event GA4. Helper ini tidak mengirim event jika window.gtag tidak tersedia, dan hanya aktif jika:

  1. NEXT_PUBLIC_GA_MEASUREMENT_ID tersedia.
  2. NEXT_PUBLIC_APP_ENV bernilai staging atau production.
  3. Host runtime masuk allowlist analytics, misalnya gbim-staging.ppl.cs.ui.ac.id.

Event yang diinstrumentasi:

  • register_submitted, register_success, register_failed
  • activation_verified, activation_expired, activation_used, activation_invalid, activation_rate_limited
  • reactivation_requested, reactivation_success, reactivation_failed
  • admin_verification_list_viewed, admin_verification_detail_clicked, admin_verification_status_updated
  • pengajuan_admin_status_updated

Pada akhir implementasi, pipeline FE juga perlu meneruskan variable analytics ke Docker build karena variable NEXT_PUBLIC_* di Next.js dibaca saat build. Tanpa itu, tag GA tidak muncul di bundle staging walaupun kode analytics sudah ada.

[Placeholder SS-06] GA4 Realtime atau DebugView menampilkan page view/event dari staging setelah variable CI/CD FE terpasang dan frontend dideploy ulang.

Mapping ke CPL 6

Criterion 1: Built-in Platform Monitoring

Monitoring sudah masuk ke lifecycle aplikasi, bukan hanya screenshot manual. Backend mengekspos /api/metrics, Prometheus melakukan scrape, dan Grafana membaca data dari Prometheus. k6 juga dijalankan sebagai Job Kubernetes sehingga telemetry performa bisa masuk ke jalur monitoring yang sama.

Correlation ID memperkuat sisi platform monitoring karena request tidak hanya terlihat secara agregat di metric, tetapi juga bisa ditelusuri sampai log backend. Ini membuat investigasi error lebih operasional: dari error frontend, ambil X-Correlation-ID, lalu cari corr_id yang sama di backend.

Criterion 2: Standard Tool Setup with Live Data

Tool yang digunakan adalah tool standar industri:

  • Prometheus untuk metrics.
  • Grafana untuk dashboard.
  • k6 untuk smoke/load telemetry.
  • Django logging dengan correlation ID untuk investigasi request.
  • GA4 sebagai sinyal tambahan aktivitas frontend.

Data yang ditampilkan bukan mock statis. Custom metric naik dari flow aplikasi, k6 mengirim metric hasil request synthetic, dan correlation ID muncul dari request yang benar-benar melewati frontend/backend.

Criterion 3: Kustomisasi Sesuai Pekerjaan

Kustomisasi monitoring dibuat berdasarkan flow GBIM yang memang penting:

  • Registrasi akun.
  • Aktivasi akun.
  • Reaktivasi token.
  • Verifikasi akun admin.
  • Update status pengajuan admin.
  • Durasi pengiriman email aktivasi/reaktivasi.

Label seperti role, outcome, action, dan status membuat dashboard bisa membedakan kasus sukses, validasi gagal, duplicate email, token invalid, token expired, not found, server error, dan service error. Ini lebih bermakna daripada hanya melihat CPU, memory, atau HTTP 200/500.

Criterion 4: Advanced Usage

Advanced usage pada implementasi final terletak pada gabungan telemetry performa dan traceability:

  • k6 menghasilkan data performa yang masuk ke Prometheus remote write dan bisa divisualisasikan di Grafana.
  • Correlation ID menghubungkan request frontend, response backend, dan log backend.
  • Custom metrics menjelaskan outcome bisnis, bukan hanya status HTTP.
  • Analytics frontend memberi sinyal tambahan untuk aktivitas pengguna di staging/production.

Kesimpulan

Hasil akhir monitoring GBIM bukan sekadar "Grafana sudah ada", tetapi observability yang bisa menjawab pertanyaan operasional:

  • Apakah registrasi sering gagal?
  • Apakah aktivasi akun bermasalah?
  • Apakah verifikasi admin menghasilkan error?
  • Apakah update status pengajuan stabil?
  • Apakah backend tetap responsif saat diuji k6?
  • Request error tertentu bisa dicari di log backend lewat correlation ID apa?

Scope yang benar-benar selesai adalah metrics bisnis, k6 telemetry, correlation ID end-to-end, dan analytics frontend sebagai tambahan.