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

# Update Metric Config

> Update a metric config. Requires version for optimistic locking.

<Warning>
  Updates use optimistic locking. Include the current `version` in your request.
  If the version doesn't match, you'll receive a `409 Conflict` error.
</Warning>


## OpenAPI

````yaml PUT /api/v1/metric-configs/{configId}
openapi: 3.0.3
info:
  title: LogFleet API
  description: >
    LogFleet is a distributed edge observability platform for fleet management.


    ## Overview

    LogFleet collects logs from distributed edge devices, stores them locally
    with

    configurable retention, extracts metrics for cloud observability platforms,

    and provides on-demand log streaming and remote access.


    ## Authentication

    LogFleet uses two authentication methods:


    - **JWT Bearer Token**: For dashboard and user operations. Obtain via
    `/auth/login`

    - **API Key**: For edge agents. Create via `/api-keys` endpoint


    ## Rate Limits

    - General endpoints: 100 requests/minute

    - Streaming endpoints: 20 requests/minute

    - Edge/metrics endpoints: 1000 requests/minute


    ## Multi-Tenancy

    All resources are scoped to organizations. Users can only access resources

    belonging to their organization.
  version: 1.0.0
  contact:
    name: LogFleet Support
    email: support@logfleet.io
    url: https://logfleet.io
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
servers:
  - url: https://api.logfleet.io
    description: Production
  - url: http://localhost:8080
    description: Local development
security: []
tags:
  - name: Authentication
    description: User registration and authentication
  - name: Organization
    description: Organization management
  - name: Agents
    description: Edge agent management
  - name: API Keys
    description: API key management for edge agents
  - name: Dashboard
    description: Dashboard metrics and summaries
  - name: Streaming
    description: Real-time log streaming
  - name: Billing
    description: Plans, quotas, and invoices
  - name: Metric Configs
    description: Custom metric extraction configuration
  - name: Edge API
    description: Edge agent communication endpoints
paths:
  /api/v1/metric-configs/{configId}:
    put:
      tags:
        - Metric Configs
      summary: Update metric config
      description: Update a metric config. Requires version for optimistic locking.
      operationId: updateMetricConfig
      parameters:
        - $ref: '#/components/parameters/ConfigId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMetricConfigRequest'
      responses:
        '200':
          description: Config updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricConfigResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Version conflict - config was modified
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  parameters:
    ConfigId:
      name: configId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Metric config ID
  schemas:
    UpdateMetricConfigRequest:
      type: object
      required:
        - version
      properties:
        name:
          type: string
        description:
          type: string
        enabled:
          type: boolean
        scope:
          $ref: '#/components/schemas/ConfigScope'
        version:
          type: integer
          description: Required for optimistic locking
    MetricConfigResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: string
        version:
          type: integer
        enabled:
          type: boolean
        scope:
          $ref: '#/components/schemas/ConfigScope'
        metrics:
          type: array
          items:
            $ref: '#/components/schemas/MetricDefinitionResponse'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        created_by:
          type: string
          format: uuid
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message
        message:
          type: string
          description: Additional details
    ConfigScope:
      type: object
      properties:
        type:
          type: string
          enum:
            - all
            - locations
            - tags
        locations:
          type: array
          items:
            type: string
        tags:
          type: array
          items:
            type: string
    MetricDefinitionResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        config_id:
          type: string
          format: uuid
        name:
          type: string
        namespace:
          type: string
        description:
          type: string
        enabled:
          type: boolean
        type:
          type: string
          enum:
            - counter
            - gauge
            - histogram
        source_field:
          type: string
        filter:
          $ref: '#/components/schemas/FilterCondition'
        tags:
          type: array
          items:
            $ref: '#/components/schemas/TagDefinition'
        counter_opts:
          $ref: '#/components/schemas/CounterOptions'
        gauge_opts:
          $ref: '#/components/schemas/GaugeOptions'
        histogram_opts:
          $ref: '#/components/schemas/HistogramOptions'
        cardinality:
          $ref: '#/components/schemas/CardinalityLimits'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    FilterCondition:
      type: object
      properties:
        field:
          type: string
        operator:
          type: string
          enum:
            - eq
            - neq
            - contains
            - regex
            - gt
            - lt
            - gte
            - lte
        value:
          type: string
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/FilterCondition'
        logic:
          type: string
          enum:
            - and
            - or
    TagDefinition:
      type: object
      properties:
        name:
          type: string
        source:
          type: string
          enum:
            - field
            - static
            - template
        value:
          type: string
    CounterOptions:
      type: object
      properties:
        increment_by:
          type: string
          description: Field name or static value
    GaugeOptions:
      type: object
      properties:
        value_field:
          type: string
    HistogramOptions:
      type: object
      properties:
        value_field:
          type: string
        buckets:
          type: array
          items:
            type: number
    CardinalityLimits:
      type: object
      properties:
        max_tag_cardinality:
          type: integer
          default: 1000
        on_limit_exceeded:
          type: string
          enum:
            - drop
            - sample
            - aggregate
          default: drop
  responses:
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token obtained from /auth/login

````