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

# Logs to Metrics Processor

> Generate custom metrics from log events matching specified conditions using the Sawmills Logs to Metrics Processor with configurable names, types, and labels.

## Supported Data Types

📘 **Logs**

### Overview

The **Logs to Metrics** processor generates **metrics** from log events that match your conditions.

### How it works (conceptually)

* **Match**: optionally restrict which logs participate using conditions.
* **Map**: define the metric name/type and where the numeric value comes from.
* **Label**: choose which attributes/fields should become metric labels.
* **Export**: select the metrics destination to receive the generated metrics.

### Configuration Components

#### 1. Name

* **Description**: A descriptive name to help you identify this processor in your pipeline.

#### 2. Conditions (optional)

* **Description**: Limit which log events generate metrics.
* **How to use**: Add one or more conditions and choose whether to **match all (AND)** or **match any (OR)**.

<Tip>
  Use conditions to keep metrics intentional and avoid “counting everything.” For example, match only  logs whose body equals  a specific substring.
</Tip>

#### 3. Metric Mapping

* **Metric Name**: The metric to produce (for example, `http_requests_total`, `login_failures_total`).
* **Metric Type**: Currently **Counter**.
* **Unit** (optional): A unit string such as `ms`, `s`, `bytes`, `MB`.
* **Description** (optional): A human-readable description of what the metric represents.

#### 4. Value Source

Choose where the numeric value for the counter increment comes from:

* **Fixed Value**: Always increment by the same number (commonly `1` for counting events).
* **From Attribute**: Increment by a numeric value taken from a **log attribute**.

<Warning>
  If the selected attribute is missing or is not numeric for a given log event, that event will not contribute to the metric.
</Warning>

#### 5. Labels

Labels are taken from selected log attributes under **From Log Attributes** and attached to each emitted metric datapoint (for example, `service`, `env`, `status_code`).

<Warning>
  Be careful with high-cardinality labels (for example, request IDs, user IDs, full URLs). High cardinality can significantly increase metric cost and reduce query performance.
</Warning>

#### 6. Metrics Destination

Choose where the generated metrics are sent. Only destinations that support **metrics** will be selectable

#### 7. Post-Processing

* **Drop original logs after extracting metrics**: If enabled, logs will not continue past this point in the pipeline after metrics are generated.

<Warning>
  Enable “Drop original logs” only if you are sure you do not need the logs downstream (for example, in a logs destination or later log processors).
</Warning>

<Note>
  In case you need to extract from values from a string -- to be used for Log selection condition or you need parts of the string to pass as labels, use the \*\*Parse Log processor \*\*before the Log-to-metric processor to extract the needed fields to a specific attribute.    Then use in condition and pass as labels
</Note>
