Metric types
Prometheus defines four core metric types that serve different purposes:Counter
A cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart. Use counters for metrics like:
- Total number of HTTP requests served
- Total number of tasks completed
- Total number of errors
Gauge
A metric that represents a single numerical value that can arbitrarily go up and down. Use gauges for metrics like:
- Current memory usage
- Number of concurrent requests
- Temperature readings
- Cache size
Histogram
A metric that samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values. Use histograms for:
- Request duration
- Response sizes
- Query execution times
Registries
All metrics in PromGleam are registered in a named registry. The most common registry name is"default", but you can create and use multiple registries to organize your metrics.
Labels
Labels allow you to partition your metrics into multiple dimensions. When you create a metric, you specify the label names. When you record a measurement, you provide the label values.The order of label values must match the order of label names defined when creating the metric.
Naming conventions
Follow these best practices when naming your metrics:- Use snake_case for metric names
- Include the unit of measurement in the metric name (e.g.,
_seconds,_bytes,_total) - Use descriptive names that clearly indicate what is being measured
- Add
_totalsuffix to counters
Next steps
Counters
Learn how to use counter metrics
Gauges
Learn how to use gauge metrics
Histograms
Learn how to use histogram metrics
Registries
Learn how to manage registries