อธิบายประเภทของตัวชี้วัด
ทำความเข้าใจประเภทพื้นฐานของตัวชี้วัด ได้แก่ มาตรวัด ตัวนับ ฮิสโตแกรม และสรุปค่า เรียนรู้ว่าเมื่อใดและอย่างไรจึงควรใช้แต่ละประเภทเพื่อการตรวจสอบที่มีประสิทธิภาพ
อธิบายประเภทของตัวชี้วัด เป็นบทเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
What are Metric Types?
Welcome to "Types of Metrics Explained"! In observability, metrics are crucial for understanding your system's health and performance.
But not all numbers are the same! Categorizing metrics helps us collect, store, and analyze them effectively.
We'll explore the four fundamental types: Gauges, Counters, Histograms, and Summaries.
Gauges: Snapshot of Now
A Gauge represents a single numerical value that can go up and down over time. Think of it like a car's speedometer or a thermometer.
Gauges are perfect for capturing the current state of a system at a specific moment.
- Use for: Current CPU usage, memory consumption, queue size, temperature.
- Nature: Point-in-time value.
Gauge Code Example
Here's a simple Java example simulating a gauge tracking current CPU utilization. Notice how its value can change freely.
public class Main {
public static void main(String[] args) {
double cpuUsage = 0.5; // 50% CPU
System.out.println("Current CPU Usage: " + cpuUsage);
// Later, CPU usage might change
cpuUsage = 0.8; // 80% CPU
System.out.println("Updated CPU Usage: " + cpuUsage);
cpuUsage = 0.3; // 30% CPU
System.out.println("Further Updated CPU Usage: " + cpuUsage);
}
}Counters: Always Increasing
A Counter is a cumulative metric that only ever increases. It represents a total count of something that has occurred since the system started.
It can reset to zero only when the monitored system restarts.
- Use for: Total requests served, errors encountered, bytes sent, login attempts.
- Nature: Monotonically increasing total.
Counter Code Example
This Java example demonstrates a counter for total requests. Each 'request' simply increments the counter.
public class Main {
private static long totalRequests = 0;
public static void handleRequest() {
totalRequests++;
System.out.println("Requests handled: " + totalRequests);
}
public static void main(String[] args) {
System.out.println("Initial requests: " + totalRequests);
handleRequest(); // First request
handleRequest(); // Second request
// ... more requests later
handleRequest(); // Third request
}
}Histograms: Value Distributions
Histograms sample observations (like request durations or response sizes) and count them in configurable buckets.
They give you insight into the distribution of values, not just the average. This is vital for understanding latency and performance.
- Benefit: You can calculate percentiles (e.g., 99th percentile latency) on the server side.
- Use for: Request latency, response sizes, data transfer rates.
Summaries: Pre-calculated Percentiles
Summaries are similar to histograms but often pre-calculate configurable quantiles (like p99, p95, p50) on the client side.
Instead of sending raw data, the client library sends pre-computed statistics (sum, count, and quantiles) to the monitoring system.
- Benefit: Less data sent over the network, but less flexible for custom percentile calculations later.
- Use for: Latency measurements where specific percentiles are known to be needed.
Histograms vs. Summaries
Both Histograms and Summaries track distributions, but they differ in where calculations happen:
- Histograms: Send raw data (counts in buckets). Percentiles are calculated on the server. More flexible for ad-hoc analysis.
- Summaries: Calculate percentiles on the client and send pre-computed results. More resource-efficient if you know exactly which percentiles you need.
For most modern systems, Histograms are generally preferred due to their flexibility.
Picking the Best Metric Type
Choosing the right metric type is key for effective monitoring:
- Gauges: For current values that can go up/down (e.g., disk usage, active users).
- Counters: For cumulative totals that only increase (e.g., total errors, processed items).
- Histograms: For distributions of values where you need server-side percentile calculation and flexibility (e.g., request durations).
- Summaries: For distributions where client-side pre-calculated percentiles are sufficient and network efficiency is critical (less common than histograms now).
Metric Type Challenge
Your application processes user orders. You want to track the total number of orders placed since the application started, and also the current number of items in the processing queue.
Key Takeaways on Metrics
Great job! You've now learned about the four fundamental metric types:
- Gauges: For current, fluctuating values.
- Counters: For cumulative, ever-increasing totals.
- Histograms: For understanding the distribution of values and calculating percentiles server-side.
- Summaries: For pre-calculated percentiles client-side.
Understanding these types helps you choose the right tool for the right job, leading to more insightful monitoring and faster debugging!
เรียนรู้ 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 ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “อธิบายประเภทของตัวชี้วัด” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) นี้ได้ไหม
ได้ บทเรียน System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- อธิบายประเภทของตัวชี้วัด
- กลยุทธ์การรวบรวมตัวชี้วัด
- การแสดงผลและการแจ้งเตือนตัวชี้วัด
- คาร์ดินาลิตีของเมทริกซ์และแนวทางปฏิบัติที่ดีในการติดป้ายกำกับ