Skip to main content

Recording Rules

Recording rules allow you to preprocess and derive new time series from existing ones. By recording a new metric time series, you can simplify complex and resource-intensive PromQL queries into a leaner and more quickly queried metric. The newly recorded metric can be used in various dashboard visualizations and delivers high-performance analytics.

Overview​

Create recording rules using your Coralogix UI or import existing rules from a YAML file using our Recording Rules API. These rules are executed in the background at a regular interval specified in the rule group.

A recording rule is defined by:

  • a name

  • a query expression

  • an optional set of labels to add to the resulting time series

The query expression is used to select the time series upon which the rule will operate. It may include aggregation functions such as sum, min, max, etc. When a rule is executed, it evaluates the query expression over a range of time specified in the configuration file as evaluation_interval. It then creates a new time series for each unique combination of label values resulting from the evaluation.

What you need​

  • To view recording rules, you need METRICS.RECORDING-RULES:READCONFIG (Data Admin, Observability Lead, Platform Admin, or Security User role).
  • To create, modify, or import recording rules, you need METRICS.RECORDING-RULES:UPDATECONFIG (same roles).

Prerequisites​

Add a new rule​

Add a new recording rule using your Coralogix UI.

1.

In your navigation pane, click Data Flow > Recording Rules to view the existing list of recording rules.

2.

Click + New Group.

3.

Select the rule set for the new group. Either select from the Select set for this group dropdown, or click + Add New Set to add the rule group to a new rule set.

4.

Enter a name for the group and select the Evaluation interval (how frequently the rule is run) and Series limit (the number of permutations the rule can create) for the new group.

Notes:

  • The default setting for the Evaluation interval is 60 seconds, which is also the minimum. Note that the evaluation interval set in the rule must be greater than the time it will actually take to evaluate. If the frequency is shorter than the actual evaluation time, the recording rule will fail.
  • The default setting for the Series limit is 0, which means "no limit".
5.

Under Rule, enter a Metric Name for the new time series and enter the Expression as a PromQL query. A chart previews the series the expression returns. For the characters a name can contain, see Metric and label names.

6.

[Optional] Under Labels, select Add Label and enter a Label Name and Label Value. Repeat for each label.

The New Recording Rule Group panel with a rule set selected, a group named my.app.requests_total, and a rule with Metric Name my.app.requests_total, an expression, a preview chart, and a label named my.app.requests_label

7.

To add more rules to the group, select Add Rule To Group and repeat steps 5 and 6 for each rule.

8.

Click Save Rule Group at the top of the screen.

Metric and label names​

The editor checks names as you type and keeps Save Rule Group unavailable until every name is valid.

  • Metric Name starts with a letter, _, or :, and continues with letters, digits, _, :, or .. For example, my.app.requests_total and job:http_requests:rate5m are both valid.
  • Label Name follows the same pattern without :. Spaces and dashes are not allowed.

A letter can be any Unicode letter, not only A to Z, so names such as équipe are valid. Names that read as numbers, such as inf or nan, are rejected when you save.

Import rules from a YAML file​

To import rules from an existing YAML file:

1.

In your navigation pane, click Data Flow > Recording Rules to view the existing list of recording rules.

2.

Click Import Yaml.

3.

Select the YAML file to import and click Open.

If the upload is successful, the imported rules appear in the Recording Rules page.

If the upload fails for any reason, an error message appears with the reason for the failure.

Additional resources​

DocumentationRecording Rules API
Last updated on