---
title: "POST /api/v1/config/derived-metrics"
method: POST
path: "/api/v1/config/derived-metrics"
tags: ["DerivedMetric"]
---

# POST /api/v1/config/derived-metrics

`POST /api/v1/config/derived-metrics`

## Request body

- Configv1CreateDerivedMetricRequest
  - `derived_metric` Configv1DerivedMetric
    - `created_at` string, date-time — Timestamp of when the DerivedMetric was created. Cannot be set by clients.
    - `description` string — Optional. Description of the derived metric.
    - `metric_name` string, required — Name of the derived metric, which must be unique across the system.
    - `name` string, required — The name of the DerivedMetric. You can modify this value after the DerivedMetric is created.
    - `queries` DerivedMetricSelectorQuery[], required — Defines the queries that the derived metric can map to.
      - `query` DerivedMetricQuery, required
        - `prometheus_expr` string, required — PromQL expression the derived metric executes. The expression should include all configured variables.
        - `variables` DerivedMetricVariable[] — Optional. Specifies the variables that can be used in the derived metric as label selectors.
          - `default_prometheus_selector` string, required — PromQL label selector, which must match the given variable name. If the variable is not specified in the derived metric usage, then the default selector is used.
          - `name` string, required — Name of the variable.
      - `selector` DerivedMetricSelector
        - `labels` Configv1DerivedMetricLabelMatcher[] — Labels that must match in the derived metric usage for the selector to match.
          - `name` string — name always matches against an exact label name.
          - `type` 'EXACT'
          - `value` string — value matches against a label value based on the configured type.
    - `slug` string — The unique identifier of the DerivedMetric. If a `slug` isn't provided, one is generated based on the `name` field. You can't modify this field after the DerivedMetric is created.
    - `updated_at` string, date-time — Timestamp of when the DerivedMetric was last updated. Cannot be set by clients.
  - `dry_run` boolean — If `true`, validates the specified configuration without creating the DerivedMetric. If the specified configuration is valid, the endpoint returns a partial response without the DerivedMetric. If the specified configuration is invalid, the endpoint returns an error.

## Response `200`

A successful response containing the created DerivedMetric.

- Configv1CreateDerivedMetricResponse
  - `derived_metric` Configv1DerivedMetric
    - `created_at` string, date-time — Timestamp of when the DerivedMetric was created. Cannot be set by clients.
    - `description` string — Optional. Description of the derived metric.
    - `metric_name` string, required — Name of the derived metric, which must be unique across the system.
    - `name` string, required — The name of the DerivedMetric. You can modify this value after the DerivedMetric is created.
    - `queries` DerivedMetricSelectorQuery[], required — Defines the queries that the derived metric can map to.
      - `query` DerivedMetricQuery, required
        - `prometheus_expr` string, required — PromQL expression the derived metric executes. The expression should include all configured variables.
        - `variables` DerivedMetricVariable[] — Optional. Specifies the variables that can be used in the derived metric as label selectors.
          - `default_prometheus_selector` string, required — PromQL label selector, which must match the given variable name. If the variable is not specified in the derived metric usage, then the default selector is used.
          - `name` string, required — Name of the variable.
      - `selector` DerivedMetricSelector
        - `labels` Configv1DerivedMetricLabelMatcher[] — Labels that must match in the derived metric usage for the selector to match.
          - `name` string — name always matches against an exact label name.
          - `type` 'EXACT'
          - `value` string — value matches against a label value based on the configured type.
    - `slug` string — The unique identifier of the DerivedMetric. If a `slug` isn't provided, one is generated based on the `name` field. You can't modify this field after the DerivedMetric is created.
    - `updated_at` string, date-time — Timestamp of when the DerivedMetric was last updated. Cannot be set by clients.

## Other responses

- `400` — Cannot create the DerivedMetric because the request is invalid.
- `409` — Cannot create the DerivedMetric because there is a conflict with an existing DerivedMetric.
- `500` — An unexpected error response.
- `default` — An undefined error response.

---

[API](https://skmtc.dev/chronosphere/apis/data-v1-api.md) · [All operations](https://skmtc.dev/chronosphere/apis/data-v1-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/chronosphere/data-v1-api/revisions/ee91fd539ced/schema)
