OBSERVABILITY PLATFORM
Mapping rules

Mapping rules

Mapping aggregation rules downsample in-memory metric data on the streaming ingest path before storing any results in the database, which is before metric aggregation.

Downsampling requires the creation of two mapping rules:

  • A rule which performs the downsampling
  • A rule that deletes the raw metric

If you don't create a mapping rule to drop the raw metric, two metrics persist; one with the original resolution and one with the new resolution.

Mapping rules drop a given set of metrics by using the drop: true key/value pair. This can be of use when paired with rollup rules, as often the goal of a rollup rule is to remove the original raw metrics after aggregation. This is unlike drop rules, which drop the metric before any aggregation takes place. This achieves the same result as setting the drop_raw: true flag on the rollup rule; if this flag is set, it's not necessary to add a matching mapping rule with drop: true.

Mapping rules support both Prometheus and Graphite metrics.

View existing mapping rules

Select from the following methods to view your mapping rules.

To list your existing mapping rules using Chronoctl, use the chronoctl mapping-rules list command:

chronoctl mapping-rules list

Create mapping rules

Select from the following methods to create a mapping rule.

To create a mapping rule with Chronoctl, define the desired rule in a YAML file and apply it.

The scaffold parameter requires Chronoctl version 0.55 or later.

If you don't already have a YAML configuration file, use the scaffold Chronoctl parameter to generate a template for a specific resource type:

chronoctl mapping-rules scaffold

You can redirect the results (using the redirection operator >) to a file for editing.

  1. Create or edit a YAML configuration file to configure the mapping rule.

  2. Apply the mapping rule:

    chronoctl apply -f FILE_NAME.yaml

Replace FILE_NAME with the name of the YAML configuration file.

Mapping rules take effect immediately but might require a full recording interval to show a change.

Here are some example mapping rules.

Define a metric's retention interval

This example uses the following definable keys:

  • aggregation_policy: Specifies the policy applied to aggregate the metric for a given resolution window.

    • aggregation: For example, setting this property to LAST takes the last element as the aggregated metric. See Supported aggregation operations for a complete list.
    • interval: Specifies the time between aggregated data points. (Known as storage_policies in version 0.286.0-2023-01-06-release.1 and earlier.) Intervals are based on your retention policy.
  • filters: Specifies that the rule catches metrics of name http_request_duration with the label k8s_pod.

    Label filters can include multiple labels. Metrics must match each label for the filter to apply. Label values support glob syntax, including matching multiple patterns with an OR, such as pattern1,pattern2.

api_version: v1/config
kind: MappingRule
spec:
  name: http request duration
  slug: http_request_duration
  aggregation_policy:
    aggregation: LAST
    interval: 30s
  filters:
  - name: "__name__"
    value_glob: "http_request_duration"
  - name: "k8s_pod"
    value_glob: "*"

Drop a metric

You don't need to specify an aggregation operation or interval to drop a metric.

api_version: v1/config
kind: MappingRule
spec:
  filters:
  - name: "__name__"
    value_glob: http_request_bucket
  - name: k8s_pod
    value_glob: "*"
  - name: le
    value_glob: "*"
  - name: git_sha
    value_glob: "*"
  - name: route
    value_glob: "*"
  name: drop raw http_request_bucket
  slug: http_request_bucket
  drop: true

Delete mapping rules

Select from the following methods to delete a mapping rule.

To delete a mapping rule using Chronoctl, use the chronoctl mapping-rules delete command:

chronoctl mapping-rules delete SLUG

Replace SLUG with the slug of the rule you want to delete.