Limitations
Although recording rules are powerful, they have the following limitations:- Recording rules might be delayed because they run in a batch format.
- Recording rules apply only to individual metrics, not broad aggregations.
- Recording rules don’t have the ability to discard raw data after aggregation.
- Recording rules don’t capture late-arriving data.
- If a recording rule fails to run, there’s no way to backfill the data.
Attributes
Configure a recording rule with a PromQL statement executed against the metrics data with the result stored in a new time series with a unique metric name. PromQL statements in recording rules can include any PromQL function. Rule fields:-
prometheus_expr: The PromQL expression to evaluate. -
interval_secs: How often to evaluate the rule. Default is60s. -
label_policy: Specify label names to add to the output metric. If you attempt to add an existing label, the label isn’t added. For example,add (instance123:instance). -
execution_group: The execution group this rule is assigned to. Rules in the same execution group run at intervals. All rules in a group must complete before the rules in that group run again.Creating too many rules in an execution group can cause delays in execution of the next iteration. Chronosphere recommends limiting the number of rules in an execution group to 200-300 maximum. -
name: The name of the rule. Ifmetric_nameis set, this is the human-readable name. Otherwise, it’s the time series to output to. -
metric_name: The time series to output to. -
slug: The slug for the rule. This can’t change after rule creation.
Best practices
Recording rules support adding labels to the resultant aggregated metrics, which rollup rules don’t support. Rollup rules also require using either a Prometheus relabel rule, or a derived metric with alabel_replace function in conjunction with
the rollup rule, to accomplish the same goal.
Due to architectural differences between Observability Platform and Prometheus,
defining recording rules is sometimes different, especially for expensive recording
rules that span many metrics. For example, recording rules in Observability Platform
are part of a rule group, whereas recording rules in Prometheus aren’t guaranteed to
be run sequentially.
Observability Platform uses a single data store. To enhance performance, use the
following recommendations:
- Break up the recording rules to scope to different clusters, or another label that scopes your metrics.
- Use the
metric_namefield so they all get written back into the same name.
View recording rules
Select from the following methods to view your recording rules.- Web
- Chronoctl
- API
In the navigation menu, click Go to Admin and then select
Control > Recording Rules.The recording rules page is searchable by rule Name or Execution group.The following fields display:
- Name: The rule name.
- Execution Group: The execution group this rule is assigned to. Rules in the same execution group run at intervals. The entire group must complete an execution before the rules in that group will run again.
- Metric Name: The time series to output to.
- Interval: How often the rule evaluates.
- Labels: Label names added to the output metric.
- Query: Click the
<>to display the query used for this rule.
Create or update recording rules
Select from the following methods to create or update recording rules.Users can modify Terraform-managed resources only by using Terraform.
Learn more.
- Chronoctl
- Terraform
- API
To create a recording rule with Chronoctl, define the rule in a
YAML file and apply it.
If you don’t already have a YAML configuration file, use the You can redirect the results (using the redirection operator
scaffold Chronoctl
parameter to generate a template for a specific resource type:>) to a file for
editing.- Create or edit a YAML configuration file to configure the recording rule. See the Chronoctl example for a complete configuration file.
-
Apply the recording rule:
FILE_NAME with the name of the YAML configuration file.Chronoctl example
The following YAML example includes three recording rules that calculate the average rate of increase per second for jobs that contain a value fornode. The results
display for instance and container as measured over one minute.
This example uses the metric_name field to specify the output name of the time
series, and the name field to display the human readable name. For backwards
compatibility, the example uses the name field for the time series if metric_name
isn’t specified, like in the third rule.
Terraform example
The following code creates a recording rule that Terraform refers to asscrape_duration_recording_rule with the name 60s rule, and defines the other
data needed to create a recording rule.
Delete recording rules
Select from the following methods to delete a recording rule.- Chronoctl
- Terraform
- API
To delete a recording rule using Chronoctl, use the
Replace
chronoctl recording-rules delete command:SLUG with the slug of the rule you want to delete.