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

# Aggregate Metric Labels Processor

> Reduce metric cardinality by aggregating datapoints across specified labels for gauge and sum metric types using the Sawmills Label Aggregation Processor.

## Supported Data Types

📊 **Metrics**

### Supported Metric Types

| Metric Type / Vendor | Datadog         | New Relic       |
| -------------------- | --------------- | --------------- |
| Gauge                | ✅ Supported     | ✅ Supported     |
| Sum (Counter)        | ✅ Supported     | ✅ Supported     |
| Histogram            | ❌ Not Supported | ❌ Not Supported |
| Summary              | ❌ Not Supported | ❌ Not Supported |
| ExponentialHistogram | ✅ Supported     | ❌ Not Supported |

<Warning>
  If you are using the [Datadog Agent](/docs/send-data-from-datadog-agent) as a source, label aggregation on
  histogram-derived metrics may produce misleading results.
</Warning>

### Configuring the Sawmills Aggregate Metric Labels Processor

The Sawmills Aggregate Metric Labels Processor reduces metric cardinality by aggregating datapoints across specified labels. It removes selected labels and combines metric values using an aggregation function, resulting in fewer unique time series.

### Configuration Components

#### 1. Name

* **Description**: Identifier for your processor. Use a unique and descriptive name to differentiate between multiple processors.

#### 2. Metric Names

* **Description**: List of metrics to apply label aggregation to. Select from available metrics in your pipeline.
* **Functionality**: Only the specified metrics will have their labels aggregated. All selected metrics use the same aggregation function.

#### 3. Aggregation Function

* **Description**: The mathematical function used to combine datapoint values when labels are removed.
* **Options**:
* **Sum**: Add all values together
* **Average**: Calculate the mean of all values
* **Max**: Keep the maximum value
* **Min**: Keep the minimum value
* **Use Cases**:
* Use **Sum** for counters and cumulative metrics (e.g., request counts, bytes transferred)
* Use **Average** for gauge-type metrics (e.g., CPU utilization, memory percentage)
* Use **Max** for capturing peak values (e.g., maximum latency, peak connections)
* Use **Min** for capturing floor values (e.g., minimum available capacity)

#### 4. Labels to Aggregate

* **Description**: Select which labels to remove and aggregate across. Available labels are fetched based on the selected metrics.
* **Functionality**: Datapoints that differ only by these labels will be combined into a single datapoint using the selected aggregation function.
* **Select All**: Option to select all available labels for maximum cardinality reduction.

### Use Cases

* **Cardinality Reduction**: Remove high-cardinality labels like `pod_name`, `instance_id`, or `container_id` to reduce the number of unique time series.
* **Cost Optimization**: Lower storage and query costs by reducing metric volume while preserving aggregate insights.
* **Environment Rollup**: Aggregate metrics across replicas or instances to get environment-level totals.
* **Simplified Dashboards**: Create cleaner visualizations by removing unnecessary dimensional detail.

### Example

**Before aggregation:**

```
http_requests_total{service="api", instance="pod-1"} = 100
http_requests_total{service="api", instance="pod-2"} = 150
http_requests_total{service="api", instance="pod-3"} = 120
```

**After aggregating label `instance` with Sum:**

```
http_requests_total{service="api"} = 370
```

### Implementation Notes

* Label aggregation operates on 5-second windows to batch and combine datapoints.
* Choose the aggregation function that matches your metric's semantic meaning (counters → sum, gauges → avg).
* Removing all labels results in a single aggregated value per metric name.
