Skip to main content
Derived metrics let you create user-friendly names for queries. Use derived metrics to implement query aliasing, which reduces the need to write complex queries.

View your derived metrics

View derived metrics with the Chronoctl command chronoctl derived-metrics list, filtered by their slugs with the --slugs flag.For example, to list all derived metrics:
To list derived metrics with slugs slug_name_1 and slug_name_2:

Create a derived metric

Here’s a Chronoctl example of a derived metric with two underlying expressions:
Chronoctl example
Use a selector in your derived metric definition when you want a metric name that’s used by different queries based on the selector, or when you want the same derived metric to map to different underlying metrics. This can cause performance issues if you have a large number of id items in use. Chronosphere doesn’t support sums across id items. If you have many selectors, a recording rule is often a better option. If you want to map only a derived metric name to a query, you don’t need a selector.

Pass through query matchers

The special variable $__passthrough_matchers forwards all label matchers from the caller’s query into the underlying metric expression. Use it when you want the derived metric to accept arbitrary label filters without enumerating every potential label as a named variable. Add $__passthrough_matchers as a selector inside the curly braces of the underlying metric in the expression field. For example:
Chronoctl example
When you query http_request_errors_total{env="prod", region="us-east-1"}, Observability Platform expands the expression to http_requests_total{env="prod", region="us-east-1", status=~"5.."} before executing it. If you provide no matchers, query results are unaffected because the variable expands to a query that matches all series. You can combine $__passthrough_matchers with named variables and fixed label matchers in the same expression:
  • $__passthrough_matchers: A variable that expands to every matcher that the caller supplies.
  • $service: A named variable with its own default selector. For an example, see Create a derived metric.
  • status=~"5..": A fixed matcher that’s always added to the query.
The difference between $__passthrough_matchers and a named variable such as $job is its scope. Named variables match one specific label, while $__passthrough_matchers captures everything the caller provides, regardless of which labels they filter.

Delete a derived metric

Users can modify Terraform-managed resources only by using Terraform. Learn more.
To delete a derived metric with Chronoctl, use the chronoctl derived-metrics delete command with the slug of the derived metric you want to delete:
You can delete more than one metric at a time by providing a comma-separated list of slugs. For example:

Replace a recording rule

When you have a complex or slow recording rule, in some cases you can replace the rule with a derived metric. For example, this recording rule queries for a number of HTTP status codes:
Replacing the recording rule with this derived metric can reduce query load:
Terraform example