# metric

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: metric
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: connect/components/processors/metric
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/processors/metric.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/processors/metric.adoc
page-git-created-date: "2024-09-09"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/metric.md -->

**Available in:** Cloud, [Self-Managed](https://docs.redpanda.com/connect/components/processors/metric/%20%22View%20the%20Self-Managed%20version%20of%20this%20component%22)

Emit custom metrics by extracting values from messages.

```yml
# Config fields, showing default values
label: ""
metric:
  type: "" # No default (required)
  name: "" # No default (required)
  labels: {} # No default (optional)
  value: ""
```

This processor works by evaluating an [interpolated field `value`](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries) for each message and updating a emitted metric according to the [type](#types).

Custom metrics such as these are emitted along with Redpanda Connect internal metrics, where you can customize where metrics are sent, which metric names are emitted and rename them as/when appropriate. For more information see the [metrics docs](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/metrics/about/).

## [](#fields)Fields

### [](#labels)`labels`

A map of label names and values that can be used to enrich metrics. Labels are not supported by some metric destinations, in which case the metrics series are combined. This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

```yaml
# Examples:
labels:
  topic: ${! meta("kafka_topic") }
  type: ${! json("doc.type") }
```

### [](#name)`name`

The name of the metric to create, this must be unique across all Redpanda Connect components otherwise it will overwrite those other metrics.

**Type**: `string`

### [](#type)`type`

The metric [type](#types) to create.

**Type**: `string`

**Options**: `counter`, `counter_by`, `gauge`, `timing`

### [](#value)`value`

For some metric types specifies a value to set, increment. Certain metrics exporters such as Prometheus support floating point values, but those that do not will cast a floating point value into an integer. This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

**Default**: `""`

## [](#examples)Examples

### [](#counter)Counter

In this example we emit a counter metric called `Foos`, which increments for every message processed, and we label the metric with some metadata about where the message came from and a field from the document that states what type it is. We also configure our metrics to emit to CloudWatch, and explicitly only allow our custom metric and some internal Redpanda Connect metrics to emit.

```yaml
pipeline:
  processors:
    - metric:
        name: Foos
        type: counter
        labels:
          topic: ${! meta("kafka_topic") }
          partition: ${! meta("kafka_partition") }
          type: ${! json("document.type").or("unknown") }

metrics:
  mapping: |
    root = if ![
      "Foos",
      "input_received",
      "output_sent"
    ].contains(this) { deleted() }
  aws_cloudwatch:
    namespace: ProdConsumer
```

### [](#gauge)Gauge

In this example we emit a gauge metric called `FooSize`, which is given a value extracted from JSON messages at the path `foo.size`. We then also configure our Prometheus metric exporter to only emit this custom metric and nothing else. We also label the metric with some metadata.

```yaml
pipeline:
  processors:
    - metric:
        name: FooSize
        type: gauge
        labels:
          topic: ${! meta("kafka_topic") }
        value: ${! json("foo.size") }

metrics:
  mapping: 'if this != "FooSize" { deleted() }'
  prometheus: {}
```

## [](#types)Types

### [](#counter-2)`counter`

Increments a counter by exactly 1, the contents of `value` are ignored by this type.

### [](#counter_by)`counter_by`

If the contents of `value` can be parsed as a positive integer value then the counter is incremented by this value.

For example, the following configuration will increment the value of the `count.custom.field` metric by the contents of `field.some.value`:

```yaml
pipeline:
  processors:
    - metric:
        type: counter_by
        name: CountCustomField
        value: ${!json("field.some.value")}
```

### [](#gauge-2)`gauge`

If the contents of `value` can be parsed as a positive integer value then the gauge is set to this value.

For example, the following configuration will set the value of the `gauge.custom.field` metric to the contents of `field.some.value`:

```yaml
pipeline:
  processors:
    - metric:
        type: gauge
        name: GaugeCustomField
        value: ${!json("field.some.value")}
```

### [](#timing)`timing`

Equivalent to `gauge` where instead the metric is a timing. It is recommended that timing values are recorded in nanoseconds in order to be consistent with standard Redpanda Connect timing metrics, as in some cases these values are automatically converted into other units such as when exporting timings as histograms with Prometheus metrics.