---
title: "Update a log-based metric"
method: PATCH
path: "/api/v2/logs/config/metrics/{metric_id}"
tags: ["Logs Metrics"]
---

# Update a log-based metric

`PATCH /api/v2/logs/config/metrics/{metric_id}`

Update a specific log-based metric from your organization.
Returns the log-based metric object from the request body when the request is successful.

## Path parameters

- `metric_id` string, required

## Request body

- LogsMetricUpdateRequest — The new log-based metric body.
  - `data` LogsMetricUpdateData, required — The new log-based metric properties.
    - `attributes` LogsMetricUpdateAttributes, required — The log-based metric properties that will be updated.
      - `compute` LogsMetricUpdateCompute — The compute rule to compute the log-based metric.
        - `include_percentiles` boolean — Toggle to include or exclude percentile aggregations for distribution metrics. Only present when the `aggregation_type` is `distribution`.
      - `filter` LogsMetricFilter — The log-based metric filter. Logs matching this filter will be aggregated in this metric.
        - `query` string — The search query - following the log search syntax.
      - `group_by` LogsMetricGroupBy[] — The rules for the group by.
        - `path` string, required — The path to the value the log-based metric will be aggregated over.
        - `tag_name` string — Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.
    - `type` 'logs_metrics', required — The type of the resource. The value should always be logs_metrics.

## Response `200`

OK

- LogsMetricResponse — The log-based metric object.
  - `data` LogsMetricResponseData — The log-based metric properties.
    - `attributes` LogsMetricResponseAttributes — The object describing a Datadog log-based metric.
      - `compute` LogsMetricResponseCompute — The compute rule to compute the log-based metric.
        - `aggregation_type` 'count' | 'distribution' — The type of aggregation to use.
        - `include_percentiles` boolean — Toggle to include or exclude percentile aggregations for distribution metrics. Only present when the `aggregation_type` is `distribution`.
        - `path` string — The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
      - `filter` LogsMetricResponseFilter — The log-based metric filter. Logs matching this filter will be aggregated in this metric.
        - `query` string — The search query - following the log search syntax.
      - `group_by` LogsMetricResponseGroupBy[] — The rules for the group by.
        - `path` string — The path to the value the log-based metric will be aggregated over.
        - `tag_name` string — Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.
    - `id` string — The name of the log-based metric.
    - `type` 'logs_metrics' — The type of the resource. The value should always be logs_metrics.

## Other responses

- `400` — Bad Request
- `403` — Not Authorized
- `404` — Not Found
- `429` — Too many requests

---

[API](https://skmtc.net/datadog/apis/api-v2.md) · [All operations](https://skmtc.net/datadog/apis/api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/datadog/api-v2/revisions/da68bf029e4c/schema)
