Four metric types in Prometheus:
-
Counter:
- Cumulative value that only increases
- Used for recording request counts, error counts
- Example:
http_requests_total - Common functions:
rate()for calculating growth rate
-
Gauge:
- Instantaneous value that can increase or decrease
- Used for recording temperature, memory usage
- Example:
memory_usage_bytes - Common functions:
avg(),max(),min()
-
Histogram:
- Samples observations and groups them into buckets
- Provides
_count,_sum,_bucketmetrics - Used for recording request latency, response size
- Example:
http_request_duration_seconds - Can calculate quantiles
-
Summary:
- Similar to Histogram but calculates quantiles on the client side
- Provides
_count,_sum, and quantile metrics - Suitable for scenarios with smaller data volumes
- Example:
rpc_duration_seconds
Selection Guidelines:
- Use Histogram for aggregated statistics
- Use Summary for precise quantiles
- Use Counter for cumulative values
- Use Gauge for instantaneous values