> ## 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.

# CreateRollupRule



## OpenAPI

````yaml openapi/api_v1_config_openapi3_DOCUMENTATION_ONLY.json POST /api/v1/config/rollup-rules
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/rollup-rules:
    post:
      tags:
        - RollupRule
      operationId: CreateRollupRule
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/configv1CreateRollupRuleRequest'
        required: true
        x-originalParamName: body
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/configv1CreateRollupRuleResponse'
          description: A successful response containing the created RollupRule.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiError'
          description: Cannot create the RollupRule because the request is invalid.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/apiError'
          description: >-
            Cannot create the RollupRule because there is a conflict with an
            existing RollupRule.
        '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:
    configv1CreateRollupRuleRequest:
      properties:
        dry_run:
          description: >-
            If `true`, validates the specified configuration without creating
            the RollupRule. If the specified configuration is valid, the
            endpoint returns a partial response without the RollupRule. If the
            specified configuration is invalid, the endpoint returns an error.
          type: boolean
        rollup_rule:
          allOf:
            - $ref: '#/components/schemas/configv1RollupRule'
          description: The RollupRule to create.
      type: object
    configv1CreateRollupRuleResponse:
      properties:
        rollup_rule:
          $ref: '#/components/schemas/configv1RollupRule'
      type: object
    apiError:
      properties:
        message:
          description: An error message describing what went wrong.
          type: string
      type: object
    genericError:
      additionalProperties: true
      type: object
    configv1RollupRule:
      properties:
        add_metric_type_label:
          description: Defines whether to add a `__rollup_type__` label in the new metric.
          type: boolean
        aggregation:
          allOf:
            - $ref: '#/components/schemas/configv1AggregationType'
          description: Defines the method by which metrics are aggregated.
        bucket_slug:
          description: The slug of the bucket the RollupRule belongs to.
          type: string
        created_at:
          description: >-
            Timestamp of when the RollupRule was created. Cannot be set by
            clients.
          format: date-time
          readOnly: true
          type: string
        drop_raw:
          description: >-
            Defines whether to automatically generate drop rules for this rollup
            rule. Set

            to `true` to remove raw metrics that match this rollup rule.
            Default: `false`.
          type: boolean
        expansive_match:
          description: >-
            **DEPRECATED**.

            A series matches and aggregates only if each label defined by
            filters and

            `label_policy.keep` or `graphite_label_policy.replace`
            (respectively) exist in

            the series. Setting `expansive_match=true` removes this restriction.
            Default:

            `expansive_match=false`.


            If `false`, a series matches and aggregates only if each label
            defined by the

            provided `filters` and the `label_policy.keep` or

            `graphite_label_policy.replace` settings exist in the series.
          type: boolean
        filters:
          description: >-
            Filters incoming metrics by label. If multiple label filters are
            specified, an

            incoming metric must match every label filter to match the rule.
            Label values

            support glob patterns, including matching multiple patterns with an
            `OR`, such

            as `service:{svc1,svc2}`. These special filters are available for
            matching

            metrics by non-label request metadata:
             * `__metric_type__`: Matches the incoming metric's [Observability Platform
               metric
               type](https://docs.chronosphere.io/control/shaping/types#observability-platform-types).
               This is the recommended method for filtering on metric type. Valid values:
               `cumulative_counter`, `cumulative_exponential_histogram`, `delta_counter`,
               `delta_exponential_histogram`, `gauge`, `measurement`.
             * `__metric_source__`: Matches the incoming metric's [source
               format](https://docs.chronosphere.io/control/shaping/types#supported-formats).
               Valid values: `carbon`, `chrono_gcp`, `dogstatsd`, `open_metrics`,
               `open_telemetry`, `prometheus`, `signalfx`, `statsd`, `wavefront`.
             * `__m3_prom_type__`: When ingesting metric data with Prometheus, matches the
               incoming metric's [Prometheus metric
               type](https://docs.chronosphere.io/control/shaping/types#prometheus). Valid
               values: `counter`, `gauge`, `histogram`, `gauge_histogram`, `summary`,
               `info`, `state_set`, `quantile`.
             * `__otel_type__`: When ingesting with OpenTelemetry, matches on the incoming
               metric's [OpenTelemetry metric
               type](https://docs.chronosphere.io/control/shaping/types#opentelemetry).
               Valid values: `sum`, `monotonic_sum`, `gauge`, `histogram`, `exp_histogram`,
              `summary`. For example, the following filter matches any cumulative counter
              metric with a `service=gateway` label whose metric name starts with
              `http_requests_`:
            ```

            __metric_type__:cumulative_counter service:gateway
            __name__:http_requests_*

            ```
          items:
            $ref: '#/components/schemas/configv1LabelFilter'
          type: array
        graphite_label_policy:
          allOf:
            - $ref: '#/components/schemas/RollupRuleGraphiteLabelPolicy'
          description: >-
            Optional. Label aggregation policy for Graphite metrics. If set, new

            restrictions will apply to the rule:

            - `label_policy` cannot be set.

            - `metric_name` cannot be set.

            - `filters` can reference only positional Graphite labels, such as
            `__gX__`,
              and synthetic labels, such as `__metric_type__`.
        interval:
          description: >-
            Optional. Sets a custom interval that defines the amount of

            time between aggregated data points. Intervals are based on your

            [retention
            policy](https://docs.chronosphere.io/administer/licensing#retention-policies).

            This field was known as `storage_policies` in version

            0.286.0-2023-01-06-release.1

            and earlier.
          type: string
        label_policy:
          allOf:
            - $ref: '#/components/schemas/configv1RollupRuleLabelPolicy'
          description: >-
            Label aggregation policy, which acts as a filter, defining which
            labels to

            preserve in the resulting metric. Use `keep` to keep one or more
            labels, or

            `discard` to ignore one or more labels. Required for non-Graphite
            rules.
        label_replace:
          allOf:
            - $ref: '#/components/schemas/RollupRuleLabelReplace'
          description: '**DEPRECATED**.'
        metric_name:
          description: >-
            The name of the new metric to create and persist to the database.
            You can use

            the template string `{{.MetricName }}` to create a new metric name
            that

            references the original metric name. For example, `new_metric: '{{
            .MetricName

            }}:by_instance'` outputs a metric with the name
            `my_metric:by_instance` if the

            matched metric is `my_metric`.

            This field is optional for Graphite rollup rules.
          type: string
        metric_type:
          allOf:
            - $ref: '#/components/schemas/RollupRuleMetricType'
          description: >-
            Declares the metric type of the input metrics. Each rollup rule must
            declare the

            type of metric it aggregates by setting the `metric_type` field,
            because each

            metric type aggregates differently. Choosing the wrong `metric_type`
            for your

            rule can produce unexpected results.


            `COUNTER` is deprecated; use `CUMULATIVE_COUNTER` instead.


            `DELTA` is deprecated; use `DELTA_COUNTER` instead.
        mode:
          allOf:
            - $ref: '#/components/schemas/configv1RollupRuleMode'
          description: >-
            The operational mode for this rollup rule. If `mode=ENABLED`, the
            rule is

            applied. If `mode=PREVIEW`, the rule is not applied, but shaping
            impact stats

            for the rule are recorded. If empty, defaults to `mode=ENABLED`.
        name:
          description: >-
            The name of the RollupRule. You can modify this value after the
            RollupRule is created.
          type: string
        skip_on_conflict:
          description: >-
            If true, this rollup rule is skipped if another rollup rule produces
            a

            metric with the same output name. Use this flag to write rollup
            rules that

            produce metrics only if no other rollup rule produces a series with
            the

            same name.
          type: boolean
        slug:
          description: >-
            The unique identifier of the RollupRule. If a `slug` isn't provided,
            one is generated based on the `name` field. You can't modify this
            field after the RollupRule is created.
          type: string
        storage_policy:
          allOf:
            - $ref: '#/components/schemas/configv1RollupRuleStoragePolicy'
          description: >-
            **DEPRECATED**.

            Use `interval` instead. Storage policy applied to the resulting

            rollup rule, which must match a known storage policy. If empty, the
            default

            storage policy is used. If set, `interval` can't be set.
        updated_at:
          description: >-
            Timestamp of when the RollupRule was last updated. Cannot be set by
            clients.
          format: date-time
          readOnly: true
          type: string
      required:
        - bucket_slug
        - name
      type: object
    configv1AggregationType:
      enum:
        - LAST
        - MIN
        - MAX
        - MEAN
        - MEDIAN
        - COUNT
        - SUM
        - SUMSQ
        - STDEV
        - P10
        - P20
        - P30
        - P40
        - P50
        - P60
        - P70
        - P80
        - P90
        - P95
        - P99
        - P999
        - P9999
        - P25
        - P75
        - COUNT_SAMPLES
        - HISTOGRAM
      type: string
    configv1LabelFilter:
      properties:
        name:
          description: The name of the label to match.
          example: job
          type: string
        value_glob:
          description: The glob value of the label to match.
          example: myservice*
          type: string
      type: object
    RollupRuleGraphiteLabelPolicy:
      properties:
        replace:
          description: >-
            List of labels to replace. Use to discard high-cardinality values
            while still

            preserving the original positions of the Graphite metric.
          items:
            $ref: '#/components/schemas/GraphiteLabelPolicyReplace'
          type: array
      required:
        - replace
      type: object
    configv1RollupRuleLabelPolicy:
      description: |-
        TODO: consolidate w/ RecordingRule.LabelPolicy once both of these
         entities implement the same label semantics.
      properties:
        discard:
          description: >-
            Labels to discard in the output metric. If set, the `keep` field
            must be

            empty.
          items:
            type: string
          type: array
        keep:
          description: >-
            Labels to retain in the output metric. If set, the `discard` field
            must

            be empty.
          items:
            type: string
          type: array
      type: object
    RollupRuleLabelReplace:
      description: |-
        Must keep this around for backwards compatibility because terraform will
        still send this key w/ a null value.
      type: object
    RollupRuleMetricType:
      description: |2-
         - CUMULATIVE_COUNTER: Alias of COUNTER.
         - DELTA_COUNTER: Alias of DELTA.
      enum:
        - COUNTER
        - GAUGE
        - DELTA
        - DISTRIBUTION
        - CUMULATIVE_EXPONENTIAL_HISTOGRAM
        - MEASUREMENT
        - CUMULATIVE_COUNTER
        - DELTA_COUNTER
        - DELTA_EXPONENTIAL_HISTOGRAM
      type: string
    configv1RollupRuleMode:
      enum:
        - ENABLED
        - PREVIEW
      title: '- PREVIEW: TODO: DISABLED = 2;'
      type: string
    configv1RollupRuleStoragePolicy:
      properties:
        resolution:
          description: Resolution of the aggregated metrics.
          type: string
        retention:
          description: Retention of the aggregated metrics.
          type: string
      required:
        - resolution
        - retention
      type: object
    GraphiteLabelPolicyReplace:
      properties:
        name:
          description: >-
            Name of the label to replace the value for. Only positional Graphite
            labels

            such as `__gX__` are allowed.
          example: __g1__
          type: string
        new_value:
          description: New value of the replaced label.
          example: ALL_HOSTS
          type: string
      required:
        - name
        - new_value
      type: object
  securitySchemes:
    ApiKeyAuth:
      description: Chronosphere API token
      in: header
      name: API-Token
      type: apiKey

````