---
title: "POST /api/v1/config/trace-metrics-rules"
method: POST
path: "/api/v1/config/trace-metrics-rules"
tags: ["TraceMetricsRule"]
---

# POST /api/v1/config/trace-metrics-rules

`POST /api/v1/config/trace-metrics-rules`

***
Trace Metrics Rules
***

## Request body

- Configv1CreateTraceMetricsRuleRequest
  - `trace_metrics_rule` Configv1TraceMetricsRule
    - `name` string — Required. Name of the TraceMetricsRule. You can modify this value after the TraceMetricsRule is created.
    - `slug` string — Unique identifier of the TraceMetricsRule. If a `slug` isn't provided, one will be generated based of the `name` field. You can't modify this field after the TraceMetricsRule is created.
    - `created_at` string, date-time — Timestamp of when the TraceMetricsRule was created. Cannot be set by clients.
    - `updated_at` string, date-time — Timestamp of when the TraceMetricsRule was last updated. Cannot be set by clients.
    - `metric_name` string — The name of the generated trace metrics.
    - `metric_labels` object — Labels to apply to the generated trace metrics.
    - `histogram_buckets_secs` number[] — Histogram bucket values, in seconds, for generated duration metrics.
    - `trace_filter` Configv1TraceSearchFilter
      - `trace` TraceSearchFilterTraceFilter
        - `duration` TraceSearchFilterDurationFilter
          - `min_secs` number, double — Minimum duration, in seconds, required for a span or trace to match.
          - `max_secs` number, double — Maximum duration, in seconds, required for a span or trace to match.
        - `error` TraceSearchFilterBoolFilter
          - `value` boolean — The value of the filter compared to the target trace or span field.
      - `span` TraceSearchFilterSpanFilter[] — Specifies the span conditions to match on. All conditions must be true in a single span for the span to be considered a match. If `span_count` is specified, the number of spans within the trace that match span conditions must be within `[min, max]`. You can specify multiple span conditions, and each can be satisfied by any number of spans within the trace.
        - `match_type` 'INCLUDE' | 'EXCLUDE'
        - `service` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `operation` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `parent_service` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `parent_operation` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `duration` TraceSearchFilterDurationFilter
          - `min_secs` number, double — Minimum duration, in seconds, required for a span or trace to match.
          - `max_secs` number, double — Maximum duration, in seconds, required for a span or trace to match.
        - `error` TraceSearchFilterBoolFilter
          - `value` boolean — The value of the filter compared to the target trace or span field.
        - `tags` TraceSearchFilterTagFilter[] — Matches the tags of the candidate span.
          - `key` string — The key or name of the span tag that this filter inspects.
          - `value` TraceSearchFilterStringFilter
            - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
            - `value` string — The value of the filter compared to the target trace or span field.
            - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
          - `numeric_value` TraceSearchFilterNumericFilter
            - `comparison` 'EQUAL' | 'NOT_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL'
            - `value` number, double — The filter value used in comparison against match candidates.
        - `span_count` TraceSearchFilterCountFilter
          - `min` integer — Minimum number of spans that must match a span query, inclusive.
          - `max` integer — Maximum number of spans that must match a span query, inclusive.
        - `is_root_span` TraceSearchFilterBoolFilter
          - `value` boolean — The value of the filter compared to the target trace or span field.
    - `group_by` Configv1TraceMetricsRuleGroupBy[] — Add labels to the resultant metrics based on these specified GroupBy messages.
      - `label` string — The label to use in the resultant metrics.
      - `key` GroupByGroupByKey — GroupByKey describes a key to group by.
        - `type` 'SERVICE' | 'OPERATION' | 'TAG' — - SERVICE: Group by service. - OPERATION: Group by operation. - TAG: Group by span tag.
        - `named_key` string — For named KeyTypes (e.g. span tags), the name of the key to group by.
  - `dry_run` boolean — If true, the TraceMetricsRule isn't created, and no response TraceMetricsRule will be returned. The response will return an error if the given TraceMetricsRule is invalid.

## Response `200`

A successful response containing the created TraceMetricsRule.

- Configv1CreateTraceMetricsRuleResponse
  - `trace_metrics_rule` Configv1TraceMetricsRule
    - `name` string — Required. Name of the TraceMetricsRule. You can modify this value after the TraceMetricsRule is created.
    - `slug` string — Unique identifier of the TraceMetricsRule. If a `slug` isn't provided, one will be generated based of the `name` field. You can't modify this field after the TraceMetricsRule is created.
    - `created_at` string, date-time — Timestamp of when the TraceMetricsRule was created. Cannot be set by clients.
    - `updated_at` string, date-time — Timestamp of when the TraceMetricsRule was last updated. Cannot be set by clients.
    - `metric_name` string — The name of the generated trace metrics.
    - `metric_labels` object — Labels to apply to the generated trace metrics.
    - `histogram_buckets_secs` number[] — Histogram bucket values, in seconds, for generated duration metrics.
    - `trace_filter` Configv1TraceSearchFilter
      - `trace` TraceSearchFilterTraceFilter
        - `duration` TraceSearchFilterDurationFilter
          - `min_secs` number, double — Minimum duration, in seconds, required for a span or trace to match.
          - `max_secs` number, double — Maximum duration, in seconds, required for a span or trace to match.
        - `error` TraceSearchFilterBoolFilter
          - `value` boolean — The value of the filter compared to the target trace or span field.
      - `span` TraceSearchFilterSpanFilter[] — Specifies the span conditions to match on. All conditions must be true in a single span for the span to be considered a match. If `span_count` is specified, the number of spans within the trace that match span conditions must be within `[min, max]`. You can specify multiple span conditions, and each can be satisfied by any number of spans within the trace.
        - `match_type` 'INCLUDE' | 'EXCLUDE'
        - `service` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `operation` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `parent_service` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `parent_operation` TraceSearchFilterStringFilter
          - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
          - `value` string — The value of the filter compared to the target trace or span field.
          - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
        - `duration` TraceSearchFilterDurationFilter
          - `min_secs` number, double — Minimum duration, in seconds, required for a span or trace to match.
          - `max_secs` number, double — Maximum duration, in seconds, required for a span or trace to match.
        - `error` TraceSearchFilterBoolFilter
          - `value` boolean — The value of the filter compared to the target trace or span field.
        - `tags` TraceSearchFilterTagFilter[] — Matches the tags of the candidate span.
          - `key` string — The key or name of the span tag that this filter inspects.
          - `value` TraceSearchFilterStringFilter
            - `match` 'EXACT' | 'REGEX' | 'EXACT_NEGATION' | 'REGEX_NEGATION' | 'IN' | 'NOT_IN'
            - `value` string — The value of the filter compared to the target trace or span field.
            - `in_values` string[] — Values the filter tests against when using `IN` or `NOT_IN` match type.
          - `numeric_value` TraceSearchFilterNumericFilter
            - `comparison` 'EQUAL' | 'NOT_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL'
            - `value` number, double — The filter value used in comparison against match candidates.
        - `span_count` TraceSearchFilterCountFilter
          - `min` integer — Minimum number of spans that must match a span query, inclusive.
          - `max` integer — Maximum number of spans that must match a span query, inclusive.
        - `is_root_span` TraceSearchFilterBoolFilter
          - `value` boolean — The value of the filter compared to the target trace or span field.
    - `group_by` Configv1TraceMetricsRuleGroupBy[] — Add labels to the resultant metrics based on these specified GroupBy messages.
      - `label` string — The label to use in the resultant metrics.
      - `key` GroupByGroupByKey — GroupByKey describes a key to group by.
        - `type` 'SERVICE' | 'OPERATION' | 'TAG' — - SERVICE: Group by service. - OPERATION: Group by operation. - TAG: Group by span tag.
        - `named_key` string — For named KeyTypes (e.g. span tags), the name of the key to group by.

## Other responses

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

---

[API](https://skmtc.net/chronosphere/apis/config-v1-api.md) · [All operations](https://skmtc.net/chronosphere/apis/config-v1-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/chronosphere/config-v1-api/versions/530951bd2ccf/schema)
