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

# Metric Configs Overview

> Configure log-to-metric extraction at the edge

Metric configurations define how LogFleet extracts metrics from logs at the edge. Instead of shipping raw logs to the cloud (expensive and bandwidth-intensive), you configure extraction rules that run on edge agents.

## How It Works

```
Logs → Pattern Matching → Metric Extraction → Cloud
      (at edge)          (at edge)          (metrics only)
```

This reduces bandwidth by **100-1000x** compared to shipping raw logs.

## Metric Types

| Type          | Description         | Example Use Case                     |
| ------------- | ------------------- | ------------------------------------ |
| **Counter**   | Counts occurrences  | HTTP requests, errors, events        |
| **Gauge**     | Point-in-time value | Temperature, queue size, connections |
| **Histogram** | Value distributions | Response times, payload sizes        |

## Configuration Structure

```json theme={null}
{
  "name": "nginx_metrics",
  "description": "Extract metrics from nginx access logs",
  "log_source": "nginx",
  "metrics": [
    {
      "name": "http_requests_total",
      "type": "counter",
      "pattern": "\\\"(GET|POST|PUT|DELETE)\\s",
      "labels": ["method", "status"]
    },
    {
      "name": "response_time_seconds",
      "type": "histogram",
      "pattern": "request_time=([0-9.]+)",
      "buckets": [0.01, 0.05, 0.1, 0.5, 1.0, 5.0]
    }
  ]
}
```

## Version Control

Metric configs use **optimistic locking** to prevent conflicts:

1. Each config has a `version` field
2. When updating, include the current version
3. If version doesn't match, update fails with `409 Conflict`
4. Re-fetch, resolve conflicts, and retry

This ensures safe concurrent edits across your team.

## Deployment to Agents

When you create or update a metric config:

1. Config is stored in LogFleet platform
2. Agents sync configs periodically via `/edge/sync-config`
3. Agents apply new extraction rules immediately
4. New metrics start flowing to cloud

<Note>
  Config changes typically propagate to all agents within 60 seconds.
</Note>
