> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chronosphere.io/llms.txt
> Use this file to discover all available pages before exploring further.

# UpdateDerivedMetric



## OpenAPI

````yaml openapi/api_v1_config_openapi3_DOCUMENTATION_ONLY.json PUT /api/v1/config/derived-metrics/{slug}
openapi: 3.0.3
info:
  description: >

    The Config API provides standard HTTP/JSON REST endpoints for creating,
    reading,

    updating, deleting, and listing configurable Chronosphere resources.


    Use this link to download the raw Swagger specification:

    <a href="/api/v1/config/swagger.json">/api/v1/config/swagger.json</a>
  title: Config V1 API
  version: v1
servers:
  - url: https://{tenant}.chronosphere.io
    variables:
      tenant:
        default: tenant
        description: tenant ID assigned by the service provider
security:
  - ApiKeyAuth: []
tags:
  - name: ConfigV1
paths:
  /api/v1/config/derived-metrics/{slug}:
    put:
      tags:
        - DerivedMetric
      operationId: UpdateDerivedMetric
      parameters:
        - in: path
          name: slug
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfigV1UpdateDerivedMetricBody'
        required: true
        x-originalParamName: body
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/configv1UpdateDerivedMetricResponse'
          description: A successful response containing the updated DerivedMetric.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiError'
          description: Cannot update the DerivedMetric because the request is invalid.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiError'
          description: Cannot update the DerivedMetric because the slug does not exist.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiError'
          description: >-
            Cannot update the DerivedMetric because there is a conflict with an
            existing DerivedMetric.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiError'
          description: An unexpected error response.
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericError'
          description: An undefined error response.
components:
  schemas:
    ConfigV1UpdateDerivedMetricBody:
      properties:
        create_if_missing:
          description: >-
            If `true`, the DerivedMetric will be created if it does not already
            exist, identified by `slug`. If `false`, an error will be returned
            if the DerivedMetric does not already exist.
          type: boolean
        derived_metric:
          allOf:
            - $ref: '#/components/schemas/configv1DerivedMetric'
          description: The DerivedMetric to update.
        dry_run:
          description: >-
            If `true`, validates the specified configuration without creating or
            updating 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.
          type: boolean
      type: object
    configv1UpdateDerivedMetricResponse:
      properties:
        derived_metric:
          $ref: '#/components/schemas/configv1DerivedMetric'
      type: object
    apiError:
      properties:
        message:
          description: An error message describing what went wrong.
          type: string
      type: object
    genericError:
      additionalProperties: true
      type: object
    configv1DerivedMetric:
      properties:
        created_at:
          description: >-
            Timestamp of when the DerivedMetric was created. Cannot be set by
            clients.
          format: date-time
          readOnly: true
          type: string
        description:
          description: Optional. Description of the derived metric.
          type: string
        metric_name:
          description: Name of the derived metric, which must be unique across the system.
          example: cpu_usage:instance
          type: string
        name:
          description: >-
            The name of the DerivedMetric. You can modify this value after the
            DerivedMetric is created.
          type: string
        queries:
          description: Defines the queries that the derived metric can map to.
          items:
            $ref: '#/components/schemas/DerivedMetricSelectorQuery'
          type: array
        slug:
          description: >-
            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.
          type: string
        updated_at:
          description: >-
            Timestamp of when the DerivedMetric was last updated. Cannot be set
            by clients.
          format: date-time
          readOnly: true
          type: string
      required:
        - metric_name
        - name
        - queries
      type: object
    DerivedMetricSelectorQuery:
      properties:
        query:
          allOf:
            - $ref: '#/components/schemas/DerivedMetricQuery'
          description: The query to run when the selector matches.
        selector:
          allOf:
            - $ref: '#/components/schemas/DerivedMetricSelector'
          description: >-
            Optional. Defines the selection criteria to select which query to
            use for the

            given derived metric. If selector is empty, then the corresponding
            query is

            the default query used for the derived metric. Exactly one default
            query must

            be configured.
      required:
        - query
      type: object
    DerivedMetricQuery:
      properties:
        prometheus_expr:
          description: |-
            PromQL expression the derived metric executes. The expression should
            include all configured variables.
          example: cpu_usage{$service, $instance} / sum(cpu_usage{$service})
          type: string
        variables:
          description: >-
            Optional. Specifies the variables that can be used in the derived
            metric as

            label selectors.
          items:
            $ref: '#/components/schemas/DerivedMetricVariable'
          type: array
      required:
        - prometheus_expr
      type: object
    DerivedMetricSelector:
      properties:
        labels:
          description: >-
            Labels that must match in the derived metric usage for the selector
            to match.
          items:
            $ref: '#/components/schemas/configv1DerivedMetricLabelMatcher'
          type: array
      type: object
    DerivedMetricVariable:
      properties:
        default_prometheus_selector:
          description: >-
            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.
          example: service=~".*"
          type: string
        name:
          description: Name of the variable.
          example: service
          type: string
      required:
        - default_prometheus_selector
        - name
      type: object
    configv1DerivedMetricLabelMatcher:
      properties:
        name:
          description: name always matches against an exact label name.
          type: string
        type:
          allOf:
            - $ref: >-
                #/components/schemas/configv1DerivedMetricLabelMatcherMatcherType
          description: type determines how the label value is matched.
        value:
          description: value matches against a label value based on the configured type.
          type: string
      type: object
    configv1DerivedMetricLabelMatcherMatcherType:
      enum:
        - EXACT
      type: string
  securitySchemes:
    ApiKeyAuth:
      description: Chronosphere API token
      in: header
      name: API-Token
      type: apiKey

````