Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created hyperlink for custom collectors - writing_exporters.md #2399

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions content/docs/concepts/data_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,26 @@ as the result of queries.

## Metric names and labels

Every time series is uniquely identified by its _metric name_ and optional
key-value pairs called _labels_.
Every time series is uniquely identified by its metric name and optional key-value pairs called labels.

The _metric name_ specifies the general feature of a system that is measured
(e.g. `http_requests_total` - the total number of HTTP requests received). It
may contain ASCII letters and digits, as well as underscores and colons. It
must match the regex `[a-zA-Z_:][a-zA-Z0-9_:]*`.
***Metric names:***

Note: The colons are reserved for user defined recording rules. They should not
be used by exporters or direct instrumentation.
* Specify the general feature of a system that is measured (e.g. `http_requests_total` - the total number of HTTP requests received).
* Metric names may contain ASCII letters, digits, underscores, and colons. It must match the regex `[a-zA-Z_:][a-zA-Z0-9_:]*`.

Note: The colons are reserved for user defined recording rules. They should not be used by exporters or direct instrumentation.

Labels enable Prometheus's dimensional data model: any given combination of
labels for the same metric name identifies a particular dimensional
instantiation of that metric (for example: all HTTP requests that used the
method `POST` to the `/api/tracks` handler). The query language
allows filtering and aggregation based on these dimensions. Changing any label
value, including adding or removing a label, will create a new time series.

Label names may contain ASCII letters, numbers, as well as underscores. They
must match the regex `[a-zA-Z_][a-zA-Z0-9_]*`. Label names beginning with `__`
(two "_") are reserved for internal use.

Label values may contain any Unicode characters.
***Metric labels:***

* Enable Prometheus's dimensional data model to identify any given combination of labels for the same metric name. It identifies a particular dimensional instantiation of that metric (for example: all HTTP requests that used the method `POST` to the `/api/tracks` handler). The query language allows filtering and aggregation based on these dimensions.
* The change of any labels value, including adding or removing labels, will create a new time series.
* Labels may contain ASCII letters, numbers, as well as underscores. They must match the regex `[a-zA-Z_][a-zA-Z0-9_]*`.
* Label names beginning with `__` (two "_") are reserved for internal use.
* Label values may contain any Unicode characters.
* Labels with an empty label value are considered equivalent to labels that do not exist.

A label with an empty label value is considered equivalent to a label that does not exist.

See also the [best practices for naming metrics and labels](/docs/practices/naming/).

Expand Down
2 changes: 1 addition & 1 deletion content/docs/instrumenting/writing_exporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ each scrape.
Rather create new metrics each time. In Go this is done with
[MustNewConstMetric](https://godoc.org/github.com/prometheus/client_golang/prometheus#MustNewConstMetric)
in your `Collect()` method. For Python see
[https://github.com/prometheus/client_python#custom-collectors](https://github.com/prometheus/client_python#custom-collectors)
[Custom collectors](https://github.com/prometheus/client_python#custom-collectors)
and for Java generate a `List<MetricFamilySamples>` in your collect
method, see
[StandardExports.java](https://github.com/prometheus/client_java/blob/master/simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/StandardExports.java)
Expand Down
5 changes: 5 additions & 0 deletions content/docs/introduction/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,8 @@ being included in notifications.

A target is the definition of an object to scrape. For example, what labels to apply, any authentication required to connect, or other information that defines how the scrape will occur.

### Time Series

The Prometheus time series are streams of timestamped values belonging to the same metric and the same set of labeled dimensions.
Prometheus stores all data as time series.

28 changes: 15 additions & 13 deletions content/docs/practices/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ A consistent naming scheme for [recording rules](/docs/prometheus/latest/configu
makes it easier to interpret the meaning of a rule at a glance. It also avoids
mistakes by making incorrect or meaningless calculations stand out.

This page documents how to correctly do aggregation and suggests a naming
convention.
This page documents proper naming conventions and aggregation for recording rules.

## Naming and aggregation
## Naming

Recording rules should be of the general form `level:metric:operations`.
`level` represents the aggregation level and labels of the rule output.
`metric` is the metric name and should be unchanged other than stripping
`_total` off counters when using `rate()` or `irate()`. `operations` is a list
of operations that were applied to the metric, newest operation first.
* Recording rules should be of the general form `level:metric:operations`.
* `level` represents the aggregation level and labels of the rule output.
* `metric` is the metric name and should be unchanged other than stripping.
* `_total` off counters when using `rate()` or `irate()`.
* `operations` is a list of operations that were applied to the metric, newest operation first.

Keeping the metric name unchanged makes it easy to know what a metric is and
easy to find in the codebase.
Expand All @@ -31,17 +30,20 @@ If there is no obvious operation to use, use `sum`. When taking a ratio by
doing division, separate the metrics using `_per_` and call the operation
`ratio`.

When aggregating up ratios, aggregate up the numerator and denominator
separately and then divide. Do not take the average of a ratio or average of an
average as that is not statistically valid.
## Aggregation

When aggregating up the `_count` and `_sum` of a Summary and dividing to
* When aggregating up ratios, aggregate up the numerator and denominator
separately and then divide.
* Do not take the average of a ratio or average of an
average, as that is not statistically valid.

* When aggregating up the `_count` and `_sum` of a Summary and dividing to
calculate average observation size, treating it as a ratio would be unwieldy.
Instead keep the metric name without the `_count` or `_sum` suffix and replace
the `rate` in the operation with `mean`. This represents the average
observation size over that time period.

Always specify a `without` clause with the labels you are aggregating away.
* Always specify a `without` clause with the labels you are aggregating away.
This is to preserve all the other labels such as `job`, which will avoid
conflicts and give you more useful metrics and alerts.

Expand Down