You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**Supported in**| Prometheus version `>=0.4.0`, `<2.0.0`| Prometheus version `>=0.4.0`|
45
-
|**Transmission**| HTTP | HTTP |
46
-
|**Encoding**|[32-bit varint-encoded record length-delimited](https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/AbstractMessageLite#writeDelimitedTo(java.io.OutputStream)) Protocol Buffer messages of type [io.prometheus.client.MetricFamily](https://github.com/prometheus/client_model/blob/086fe7ca28bde6cec2acd5223423c1475a362858/metrics.proto#L76- L81) | UTF-8, `\n` line endings |
47
-
|**HTTP `Content-Type`**|`application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited`|`text/plain; version=0.0.4` (A missing `version` value will lead to a fall-back to the most recent text format version.) |
|**Advantages**| <ul><li>Cross-platform</li><li>Size</li><li>Encoding and decoding costs</li><li>Strict schema</li><li>Supports concatenation and theoretically streaming (only server-side behavior would need to change)</li></ul> | <ul><li>Human-readable</li><li>Easy to assemble, especially for minimalistic cases (no nesting required)</li><li>Readable line by line (with the exception of type hints and docstrings)</li></ul> |
50
-
|**Limitations**| <ul><li>Not human-readable</li></ul> | <ul><li>Verbose</li><li>Types and docstrings not integral part of the syntax, meaning little-to-nonexistent metric contract validation</li><li>Parsing cost</li></ul>|
As of Prometheus version 2.0, all processes that expose metrics to Prometheus need to use
23
+
a text-based format. In this section you can find some [basic information](#basic-info)
24
+
about this format as well as a more [detailed breakdown](#text-format-details) of the
25
+
format.
26
+
27
+
### Basic info
28
+
29
+
| Aspect | Description |
30
+
|--------|-------------|
31
+
|**Inception**| April 2014 |
32
+
|**Supported in**| Prometheus version `>=0.4.0`|
33
+
|**Transmission**| HTTP |
34
+
|**Encoding**| UTF-8, `\n` line endings |
35
+
|**HTTP `Content-Type`**|`text/plain; version=0.0.4` (A missing `version` value will lead to a fall-back to the most recent text format version.) |
36
+
|**Optional HTTP `Content-Encoding`**|`gzip`|
37
+
|**Advantages**| <ul><li>Human-readable</li><li>Easy to assemble, especially for minimalistic cases (no nesting required)</li><li>Readable line by line (with the exception of type hints and docstrings)</li></ul> |
38
+
|**Limitations**| <ul><li>Verbose</li><li>Types and docstrings not integral part of the syntax, meaning little-to-nonexistent metric contract validation</li><li>Parsing cost</li></ul>|
*`metric_name` and `label_name` carry the usual Prometheus expression language restrictions.
84
+
*`label_value` can be any sequence of UTF-8 characters, but the backslash (`\`, double-quote (`"`}, and line feed (`\n`) characters have to be escaped as `\\`, `\"`, and `\n`, respectively.
85
+
*`value` is a float.
86
+
* the `timestamp` is an `int64` (milliseconds since epoch, i.e. 1970-01-01 00:00:00 UTC, excluding leap seconds), represented as required by the [Go strconv package](http://golang.org/pkg/strconv/) (see functions [`ParseInt`](https://golang.org/pkg/strconv/#ParseInt) and [`ParseFloat`](https://golang.org/pkg/strconv/#ParseFloat)). In addition to standard integers, `Nan`, `+Inf`, and `-Inf` are valid values representing not a number, positive infinity, and negative infinity, respectively.
94
87
95
-
`metric_name` and `label_name` have the usual Prometheus expression language restrictions. `label_value` can be any sequence of UTF-8 characters, but the backslash, the double-quote, and the line-feed characters have to be escaped as `\\`, `\"`, and `\n`, respectively.
96
-
`value` is a float, and timestamp an `int64` (milliseconds since epoch, i.e. 1970-01-01 00:00:00 UTC, excluding leap seconds), represented as required by the [Go strconv package](http://golang.org/pkg/strconv/) (see functions `ParseInt` and `ParseFloat`). In particular, `Nan`, `+Inf`, and `-Inf` are valid values.
88
+
#### Grouping and sorting
97
89
98
-
All lines for a given metric must be provided as one uninterrupted group, with
90
+
All lines for a given metric must be provided as one single group, with
99
91
the optional `HELP` and `TYPE` lines first (in no particular order). Beyond
100
92
that, reproducible sorting in repeated expositions is preferred but not
101
93
required, i.e. do not sort if the computational cost is prohibitive.
102
94
103
-
Each line must have a unique combination of metric name and labels. Otherwise,
95
+
Each line must have a unique combination of a metric name and labels. Otherwise,
104
96
the ingestion behavior is undefined.
105
97
98
+
#### Histograms and summaries
99
+
106
100
The `histogram` and `summary` types are difficult to represent in the text
107
101
format. The following conventions apply:
108
102
@@ -113,7 +107,11 @@ format. The following conventions apply:
113
107
* A histogram _must_ have a bucket with `{le="+Inf"}`. Its value _must_ be identical to the value of `x_count`.
114
108
* The buckets of a histogram and the quantiles of a summary must appear in increasing numerical order of their label values (for the `le` or the `quantile` label, respectively).
115
109
116
-
See also the example below.
110
+
### Text format example
111
+
112
+
Below is an example of a full-fledged Prometheus metric exposition, including
113
+
comments, `HELP` and `TYPE` expressions, a histogram, a summary, character
114
+
escaping examples, and more.
117
115
118
116
```
119
117
# HELP http_requests_total The total number of HTTP requests.
0 commit comments