Developer Platform Developer Platform Developer Platform Cơ bản Entry កម្រិតចាប់ផ្តើម ~7 phút đọc · ~769 từ ~7 min read · ~703 words

Logs & observability trên Cloudflare: biết app đang “khỏe” không Logs & observability on Cloudflare: knowing if your app is healthy Logs & observability on Cloudflare: knowing if your app is healthy

App edge chạy ở hàng trăm điểm — bạn không SSH vào “một máy” được. Logs và observability là cách biết request có đến, có lỗi, và ai đang gặp vấn đề. Edge apps run at hundreds of points — you cannot SSH into “one box.” Logs and observability tell you whether requests arrive, fail, and who is affected. Edge apps run at hundreds of points — you cannot SSH into “one box.” Logs and observability tell you whether requests arrive, fail, and who is affected.

Hình 1: Kiến trúc truyền thống một vùng

API serverless toàn cầu Serverless global APIs Serverless global APIs

Ví dụ kiến trúc API serverless trên Cloudflare — compute và data product (Workers, D1, R2) tương tác thế nào. An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other. An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other.

Thuật ngữ: Concepts: Concepts: Workers · D1 · R2 · Global API · Edge compute

Sơ đồ chính thức ↗ Official diagram ↗ Official diagram ↗ · Serverless Serverless Serverless

Observability là gì — và vì sao edge khác server truyền thống? What is observability — and why is edge different from traditional servers? What is observability — and why is edge different from traditional servers?

Observability (quan sát hệ thống) là khả năng hiểu app đang làm gì từ bên ngoài: request có thành công không, chậm ở đâu, lỗi xảy ra khi nào. Với server VPS, bạn có thể mở terminal, đọc file log trên đĩa, hoặc chạy `top` khi có sự cố. Với Cloudflare Workers, code chạy phân tán trên mạng edge — không có “một máy” để SSH. Observability is the ability to understand what your app is doing from the outside: whether requests succeed, where slowness happens, when errors occur. On a VPS you might open a terminal, read log files on disk, or run `top` during an incident. With Cloudflare Workers, code runs distributed on the edge network — there is no single box to SSH into. Observability is the ability to understand what your app is doing from the outside: whether requests succeed, where slowness happens, when errors occur. On a VPS you might open a terminal, read log files on disk, or run `top` during an incident. With Cloudflare Workers, code runs distributed on the edge network — there is no single box to SSH into.

Đó là lý do logs, metrics và tracing trở thành “mắt và tai” bắt buộc thay vì tùy chọn. Trên blog.cloudflare.com, các bài observability nhấn mạnh: phát hiện lỗi sớm rẻ hơn debug sau khi user đã báo “site lỗi cả ngày”. Người mới không cần xây data lake — chỉ cần biết request có fail và đọc được message lỗi. That is why logs, metrics, and tracing become mandatory senses rather than optional extras. On blog.cloudflare.com, observability posts stress that catching errors early is cheaper than debugging after users report “the site was broken all day.” Beginners do not need a data lake — just knowing requests fail and reading error messages is enough to start. That is why logs, metrics, and tracing become mandatory senses rather than optional extras. On blog.cloudflare.com, observability posts stress that catching errors early is cheaper than debugging after users report “the site was broken all day.” Beginners do not need a data lake — just knowing requests fail and reading error messages is enough to start.

Hub này có lộ trình Operational Excellence cho DevOps/SRE: observability là bước đầu trước incident response và release safety. Bài viết này nối Workers — khối compute phổ biến — với thực hành vận hành hàng ngày. This hub has an Operational Excellence track for DevOps/SRE: observability is the first step before incident response and release safety. This post connects Workers — the common compute block — to day-to-day operations practice. This hub has an Operational Excellence track for DevOps/SRE: observability is the first step before incident response and release safety. This post connects Workers — the common compute block — to day-to-day operations practice.

Hình 1: Kiến trúc truyền thống một vùng

API serverless toàn cầu Serverless global APIs Serverless global APIs

Ví dụ kiến trúc API serverless trên Cloudflare — compute và data product (Workers, D1, R2) tương tác thế nào. An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other. An example architecture of a serverless API on Cloudflare and aims to illustrate how different compute and data products could interact with each other.

Thuật ngữ: Concepts: Concepts: Workers · D1 · R2 · Global API · Edge compute

Sơ đồ chính thức ↗ Official diagram ↗ Official diagram ↗ · Serverless Serverless Serverless

Ba công cụ người mới nên biết trước SIEM Three tools beginners should know before SIEM Three tools beginners should know before SIEM

Workers Observability trong dashboard: xem request, lỗi, và thời gian phản hồi theo Worker. Đây là điểm vào trực quan khi bạn chưa quen CLI. Cloudflare Web Analytics (hoặc analytics traffic tùy setup) cho website: biết traffic tăng hay giảm, trang nào được truy cập — hữu ích khi “API có vẻ lỗi” nhưng bạn chưa biết có phải do không ai gọi. Workers Observability in the dashboard: see requests, errors, and response time per Worker. This is a visual entry point before you are comfortable with CLI. Cloudflare Web Analytics (or traffic analytics depending on setup) for the site: know whether traffic rises or falls, which pages get hits — useful when “the API seems broken” but you do not know if anyone is calling it. Workers Observability in the dashboard: see requests, errors, and response time per Worker. This is a visual entry point before you are comfortable with CLI. Cloudflare Web Analytics (or traffic analytics depending on setup) for the site: know whether traffic rises or falls, which pages get hits — useful when “the API seems broken” but you do not know if anyone is calling it.

`wrangler tail` (hoặc tail qua dashboard): stream log thời gian thực từ Worker khi bạn deploy hoặc test. Giống ngồi cạnh “máy” và xem console.log — nhưng cho edge. Khi form signup workshop trên hub trả lỗi 500, tail thường cho thấy binding D1 chưa apply migration hoặc JSON parse fail trong vài giây. `wrangler tail` (or tail via the dashboard): stream real-time logs from a Worker while you deploy or test. Like sitting next to the “machine” watching console.log — but for the edge. When a workshop signup form on this hub returns 500, tail often shows an unapplied D1 migration or JSON parse failure within seconds. `wrangler tail` (or tail via the dashboard): stream real-time logs from a Worker while you deploy or test. Like sitting next to the “machine” watching console.log — but for the edge. When a workshop signup form on this hub returns 500, tail often shows an unapplied D1 migration or JSON parse failure within seconds.

Structured logging: thay vì in chuỗi lung tung, log JSON với `level`, `message`, `requestId` — sau này filter dễ hơn. Người mới có thể bắt đầu với `console.error` rõ ràng; khi app lớn dần, chuẩn hóa format. Docs Workers Observability giải thích chi tiết — hub trỏ tới docs, blog.cloudflare.com cho câu chuyện sản phẩm. Structured logging: instead of random strings, log JSON with `level`, `message`, `requestId` — easier to filter later. Beginners can start with clear `console.error`; standardize format as the app grows. Workers Observability docs explain details — the hub points to docs, blog.cloudflare.com for product stories. Structured logging: instead of random strings, log JSON with `level`, `message`, `requestId` — easier to filter later. Beginners can start with clear `console.error`; standardize format as the app grows. Workers Observability docs explain details — the hub points to docs, blog.cloudflare.com for product stories.

Kịch bản đời thực: từ “không biết lỗi” đến “sửa trong 10 phút” Real scenario: from “no idea what failed” to “fixed in ten minutes” Real scenario: from “no idea what failed” to “fixed in ten minutes”

Kịch bản 1: API đăng ký workshop trả 502 sau deploy. Không có observability, bạn đoán DNS, đoán origin, đoán D1. Với tail + dashboard, bạn thấy exception “DB not ready” — apply migration local/production, xong. Kịch bản 2: trang nhanh bất thường ở một region. Analytics + Worker timing cho biết một fetch upstream chậm — không phải Workers “chậm” mà là API bên thứ ba. Scenario 1: workshop signup API returns 502 after deploy. Without observability you guess DNS, origin, D1. With tail + dashboard you see exception “DB not ready” — apply migration locally/production, done. Scenario 2: a page is oddly slow in one region. Analytics + Worker timing show a slow upstream fetch — not Workers being “slow” but a third-party API. Scenario 1: workshop signup API returns 502 after deploy. Without observability you guess DNS, origin, D1. With tail + dashboard you see exception “DB not ready” — apply migration locally/production, done. Scenario 2: a page is oddly slow in one region. Analytics + Worker timing show a slow upstream fetch — not Workers being “slow” but a third-party API.

Kịch bản 3: traffic tăng gấp đôi sau chiến dịch marketing. Observability cho biết error rate vẫn thấp — bạn yên tâm scale; hoặc error rate nhảy — bạn rollback hoặc bật rate limit trước khi user flood Twitter. Đó là operational excellence ở mức thực tế, không cần war room. Scenario 3: traffic doubles after a marketing campaign. Observability shows error rate still low — you scale with confidence; or error rate spikes — you rollback or enable rate limiting before users flood Twitter. That is practical operational excellence without a war room. Scenario 3: traffic doubles after a marketing campaign. Observability shows error rate still low — you scale with confidence; or error rate spikes — you rollback or enable rate limiting before users flood Twitter. That is practical operational excellence without a war room.

Đọc bài Workers intro và Developer Platform trên blog hub nếu bạn chưa hiểu Workers là gì; quay lại bài này khi bạn đã deploy Worker đầu tiên và cần “nhìn thấy” nó chạy. Read the Workers intro and Developer Platform posts on this blog hub if you do not yet know what Workers are; return here after your first Worker deploy when you need to “see” it run. Read the Workers intro and Developer Platform posts on this blog hub if you do not yet know what Workers are; return here after your first Worker deploy when you need to “see” it run.

Bắt đầu tuần này — checklist người mới Start this week — a beginner checklist Start this week — a beginner checklist

Bật Workers Observability cho Worker bạn đang dùng. Chạy `wrangler tail` một lần sau deploy và cố ý gây lỗi (gửi JSON sai) để thấy log xuất hiện. Ghi note: “lỗi signup thường là D1 migration hoặc Turnstile” — tùy app của bạn. Không cần SIEM, Splunk, hay Grafana ngày đầu. Enable Workers Observability for the Worker you use. Run `wrangler tail` once after deploy and deliberately trigger an error (send bad JSON) to see logs appear. Note: “signup errors are usually D1 migration or Turnstile” — for your app. No SIEM, Splunk, or Grafana required on day one. Enable Workers Observability for the Worker you use. Run `wrangler tail` once after deploy and deliberately trigger an error (send bad JSON) to see logs appear. Note: “signup errors are usually D1 migration or Turnstile” — for your app. No SIEM, Splunk, or Grafana required on day one.

Tiếp theo trên hub: lộ trình Operational Excellence (observability → incident → release safety) và trang sản phẩm Workers. Khi app AI lớn dần, AI Gateway observability là lớp bổ sung — nhưng nền Workers logs vẫn là chỗ bạn debug API và binding. Next on the hub: Operational Excellence track (observability → incident → release safety) and the Workers product page. As AI apps grow, AI Gateway observability is an extra layer — but Workers logs remain where you debug APIs and bindings. Next on the hub: Operational Excellence track (observability → incident → release safety) and the Workers product page. As AI apps grow, AI Gateway observability is an extra layer — but Workers logs remain where you debug APIs and bindings.

Hình minh họa Cloudflare Cloudflare visuals Cloudflare visuals

Sơ đồ Reference Architecture chính thức và (khi có) ảnh Dashboard — giúp đối chiếu khi học. Official Reference Architecture diagrams and (when available) Dashboard screenshots — useful while you learn. Official Reference Architecture diagrams and (when available) Dashboard screenshots — useful while you learn.

Hình 1: Cloudflare Developer Platform

Ứng dụng fullstack Fullstack applications Fullstack applications

Ví dụ fullstack trên Developer Platform — Workers/Pages, storage và AI services trong một kiến trúc thực tế. A practical example of how these services come together in a real fullstack application architecture. A practical example of how these services come together in a real fullstack application architecture.

Thuật ngữ: Concepts: Concepts: Workers · Pages · D1 · R2 · KV · Durable Objects

Sơ đồ chính thức ↗ Official diagram ↗ Official diagram ↗ · Serverless Serverless Serverless

Câu hỏi thường gặp Frequently asked questions Frequently asked questions

Observability có tốn nhiều không? Is observability expensive? Is observability expensive?

Bật log và dashboard cơ bản thường nằm trong gói bạn đã dùng; chi phí tăng khi lưu log lâu hoặc volume rất lớn. Người mới nên bắt tail + dashboard trước khi lo data retention phức tạp. Basic logs and dashboard are usually part of plans you already use; cost rises with long retention or very high volume. Beginners should start with tail + dashboard before worrying about complex retention. Basic logs and dashboard are usually part of plans you already use; cost rises with long retention or very high volume. Beginners should start with tail + dashboard before worrying about complex retention.

Workers logs thay thế được monitoring server không? Can Workers logs replace server monitoring? Can Workers logs replace server monitoring?

Với app chủ yếu trên Workers, logs + analytics là nền. Nếu bạn vẫn có origin hoặc container riêng, cần monitor cả hai lớp — edge và origin. For apps mostly on Workers, logs + analytics are the foundation. If you still have your own origin or containers, monitor both layers — edge and origin. For apps mostly on Workers, logs + analytics are the foundation. If you still have your own origin or containers, monitor both layers — edge and origin.

Nên học observability trước hay Workers trước? Should I learn observability or Workers first? Should I learn observability or Workers first?

Deploy một Worker “Hello” trước, rồi học tail và dashboard ngay — observability có ý nghĩa khi bạn có thứ cần quan sát. Deploy a “Hello” Worker first, then learn tail and dashboard — observability matters when you have something to observe. Deploy a “Hello” Worker first, then learn tail and dashboard — observability matters when you have something to observe.

Học tiếp trên hub (on-page backlinks) Keep learning on this hub (on-page links) Keep learning on this hub (on-page links)

Nguồn tham khảo (blog.cloudflare.com) Sources (blog.cloudflare.com) Sources (blog.cloudflare.com)

Nội dung được viết lại để dễ hiểu hơn; luôn đọc bài gốc trên blog.cloudflare.com và docs chính thức khi cần chi tiết kỹ thuật hoặc cập nhật mới nhất. Content is rewritten for clarity; always read the original posts on blog.cloudflare.com and official docs for technical detail or the latest updates. Content is rewritten for clarity; always read the original posts on blog.cloudflare.com and official docs for technical detail or the latest updates.

What are Cloudflare Workers? Serverless at the edge, explained simply
Workers Workers Workers Cơ bản Entry កម្រិតចាប់ផ្តើម ~7 phút ~7 min ~7 នាទី

Cloudflare Workers là gì? Serverless ở “mép mạng” giải thích đơn giản What are Cloudflare Workers? Serverless at the edge, explained simply What are Cloudflare Workers? Serverless at the edge, explained simply

Workers giống thuê “người trực” ngay gần khách hàng: nhận request, xử lý nhanh, trả kết quả — bạn không phải tự mua và bảo trì cả tòa nhà server. Workers are like stationing helpers near customers: take a request, handle it quickly, return a result — without buying and maintaining a whole server building. Workers are like stationing helpers near customers: take a request, handle it quickly, return a result — without buying and maintaining a whole server building.

Đọc bài → Read post → អានអត្ថបទ →

Cloudflare Developer Platform: build global apps without managing servers yourself
Developer Platform Developer Platform Developer Platform Trung cấp Intermediate កម្រិតមធ្យម ~9 phút ~9 min ~9 នាទី

Cloudflare Developer Platform: xây ứng dụng toàn cầu mà không tự quản lý server Cloudflare Developer Platform: build global apps without managing servers yourself Cloudflare Developer Platform: build global apps without managing servers yourself

Developer Platform giống bộ lego edge: compute (Workers), hộp đựng (R2/KV/D1), AI, và lớp bảo vệ — lắp theo use case thay vì mua cả trung tâm dữ liệu. The Developer Platform is like an edge Lego set: compute (Workers), storage boxes (R2/KV/D1), AI, and protection layers — assemble by use case instead of buying a whole data center. The Developer Platform is like an edge Lego set: compute (Workers), storage boxes (R2/KV/D1), AI, and protection layers — assemble by use case instead of buying a whole data center.

Đọc bài → Read post → អានអត្ថបទ →

Controlling LLM cost with AI Gateway (practical for small teams)
AI AI AI Trung cấp Intermediate កម្រិតមធ្យម ~8 phút ~8 min ~8 នាទី

Kiểm soát chi phí LLM với AI Gateway (thực tế cho team nhỏ) Controlling LLM cost with AI Gateway (practical for small teams) Controlling LLM cost with AI Gateway (practical for small teams)

Chi phí LLM không “bùng” vì một đêm — nó tích lũy từ mỗi request không được đếm. AI Gateway giúp bạn nhìn token, giới hạn và cắt sớm trước khi hóa đơn gây choáng. LLM bills rarely explode overnight — they accumulate from every uncounted request. AI Gateway helps you see tokens, set limits, and cut early before the invoice stuns you. LLM bills rarely explode overnight — they accumulate from every uncounted request. AI Gateway helps you see tokens, set limits, and cut early before the invoice stuns you.

Đọc bài → Read post → អានអត្ថបទ →

Xem tất cả bài blog Browse all blog posts Browse all blog posts

Chuỗi bài AI · Security · CDN · Workers · Developer Platform — viết lại cho người mới và trung cấp. AI · Security · CDN · Workers · Developer Platform — rewritten for entry and intermediate learners. AI · Security · CDN · Workers · Developer Platform — rewritten for entry and intermediate learners.