เสาหลัก: ล็อก ตัวชี้วัด และแทรซ
สำรวจสัญญาณสามประเภทของการสังเกตระบบที่แตกต่างแต่เสริมกัน ได้แก่ ล็อก ตัวชี้วัด และแทรซ ทำความเข้าใจจุดแข็งของแต่ละประเภทและวิธีทำงานร่วมกัน
เสาหลัก: ล็อก ตัวชี้วัด และแทรซ เป็นบทเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Observability's Core Pillars
Observability rests on three pillars: logs, metrics, and traces. Each gives a different view, and together they paint a full picture of your system.
Logs: The Event Diary
Logs are your system's diary — text records of discrete events like a login or an error. They tell you exactly what happened and when.
What Logs Tell Us
Logs are gold for debugging and auditing. When something breaks, they hand you the error message, stack trace, and context right up to the failure.
Logs in Action (Code)
Even a print statement is a primitive log. Real apps use logging libraries for structure, but this snippet shows the basic idea of log output.
public class LogDemo {
public static void main(String[] args) {
System.out.println("INFO: Application started.");
int userCount = 10;
System.out.println("DEBUG: Current users: " + userCount);
// Imagine an error occurring here
System.out.println("ERROR: Failed to connect to database.");
}
}Metrics: Measuring Performance
Metrics are numbers measured over time — CPU, memory, request rate, error count. They tell you how much or how often, stored as time-series data.
Metrics for Trends & Health
Metrics reveal trends and health. A sudden request drop or CPU spike shows up instantly, making them perfect for spotting bottlenecks and firing alerts.
Metrics in Action (Concept)
Real metrics need libraries, but the core idea is simple: a counter that increments and gets reported periodically. This snippet sketches that out.
public class MetricDemo {
static int successfulRequests = 0;
static int failedRequests = 0;
public static void processRequest(boolean success) {
if (success) {
successfulRequests++;
} else {
failedRequests++;
}
// In a real system, these counts would be
// reported to a metrics system periodically.
}
public static void main(String[] args) {
processRequest(true);
processRequest(true);
processRequest(false);
System.out.println("Simulated request counts:");
System.out.println("Successful: " + successfulRequests);
System.out.println("Failed: " + failedRequests);
}
}Traces: Following a Request
A trace follows one request end-to-end across services. It's built from spans — each span an operation — revealing timing and relationships between components.
Traces for Distributed Systems
Traces are essential for microservices. When a request is slow, a trace pinpoints exactly which service or DB call caused the delay, even hops away.
Pillars: Stronger Together
The pillars are strongest together: traces show the path and timing, logs add context per span, metrics give aggregate trends. Correlate all three for the full view.
Check Your Understanding
Let's check what you've learned about the three pillars of observability.
Recap: The Observability Pillars
You've met all three pillars: logs for debugging, metrics for trends, traces for distributed request journeys. Next: why observability is so crucial today.
เรียนรู้ System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “เสาหลัก: ล็อก ตัวชี้วัด และแทรซ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “เสาหลัก: ล็อก ตัวชี้วัด และแทรซ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “เสาหลัก: ล็อก ตัวชี้วัด และแทรซ”
สำรวจสัญญาณสามประเภทของการสังเกตระบบที่แตกต่างแต่เสริมกัน ได้แก่ ล็อก ตัวชี้วัด และแทรซ ทำความเข้าใจจุดแข็งของแต่ละประเภทและวิธีทำงานร่วมกัน คุณปฏิบัติ System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “เสาหลัก: ล็อก ตัวชี้วัด และแทรซ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) นี้ได้ไหม
ได้ บทเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การสังเกตระบบคืออะไร
- เสาหลัก: ล็อก ตัวชี้วัด และแทรซ
- เหตุใดการสังเกตระบบจึงสำคัญในปัจจุบัน
- การเฝ้าติดตามปะทะการสังเกตได้: สิ่งที่รู้และไม่รู้