Operations 5 min read

Prometheus Metric Definitions, Types, and Data Samples

This article explains Prometheus metric naming conventions, label usage, metric types such as Counter, Gauge, Summary, and Histogram, and describes the structure of data samples, providing examples and best‑practice guidelines for defining and classifying metrics in monitoring systems.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Prometheus Metric Definitions, Types, and Data Samples

1. Metrics

Each monitoring system has its own metric definitions and specifications.

The data format of a metric directly affects how the data is collected and stored.

When defining metrics, it is important to consider universality and extensibility.

1.1 Metric Definition

<metric name>{<label name>=<label value>, ...},

1.1.1 Metric Name

Indicates the meaning of the metric.

The name must consist of letters, digits, underscores, or colons.

Matches the regular expression [a-zA-Z:][a-zA-Z0-9:] .

Colons cannot be used in exporter names.

1.1.2 Labels

Represent dimensional attributes of the metric, used for filtering and aggregation.

Formed by label name and label value as key‑value pairs, enabling multiple dimensions.

1.1.3 Example

指标1 http_request_total{status="200",method="POST"}

指标2 {__name__="http_request_total",status="200",method="POST"}

Both examples represent the same metric; labels starting with an underscore are reserved for internal use.

Metric name http_request_total denotes the total number of HTTP requests.

Label status with value 200 indicates HTTP status code 200.

Label method with value POST indicates the request method.

1.2 Metric Types

Prometheus metrics are classified as Counter, Gauge, Histogram, or Summary.

1.2.1 Counter

A monotonically increasing value that never decreases.

Suitable for tracking things like process start time or HTTP request counts.

Unaffected by process restarts; the counter does not reset to zero.

Often combined with the rate() function to obtain the change rate over a time interval.

1.2.2 Gauge

Represents a real‑time value that can increase or decrease.

Commonly used for metrics such as CPU or memory usage.

Most monitoring data types are of the Gauge type.

1.2.3 Summary

An advanced metric that highlights the distribution of data.

Used to record response times of requests within a specific period.

Can be converted to a Histogram and vice versa.

Employs sampled quantile calculations to provide distribution insights.

Does not consume additional resources on the monitored service.

Consumes more system resources compared to a Histogram.

The computed values cannot be used to derive averages or other metrics.

Typically applied to independent metrics such as garbage‑collection pause times.

1.2.4 Histogram

Shows the count of samples within defined buckets, specified by {le="upper_bound"} to indicate the number of samples less than or equal to that bound.

1.3 Data Samples

Prometheus stores collected data samples as time series, each consisting of three components:

Metric name

Sample value: a 64‑bit floating‑point number paired with a timestamp representing the data point at a specific time.

Timestamp

MonitoringOperationsObservabilityMetricsPrometheus
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.