Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otelcol.processor.cumulativetodelta: new component #2689

Merged
merged 7 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Main (unreleased)

### Features

- (_Public preview_) Add a `otelcol.processor.cumulativetodelta` component to convert metrics from
cumulative temporality to delta. (@madaraszg-tulip)

- (_Experimental_) Add a `stage.windowsevent` block in the `loki.process` component. This aims to replace the existing `stage.eventlogmessage`. (@wildum)

- Add `pyroscope.relabel` component to modify or filter profiles using Prometheus relabeling rules. (@marcsanmi)
Expand Down
2 changes: 2 additions & 0 deletions docs/sources/reference/compatibility/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ The following components, grouped by namespace, _export_ OpenTelemetry `otelcol.
- [otelcol.exporter.syslog](../components/otelcol/otelcol.exporter.syslog)
- [otelcol.processor.attributes](../components/otelcol/otelcol.processor.attributes)
- [otelcol.processor.batch](../components/otelcol/otelcol.processor.batch)
- [otelcol.processor.cumulativetodelta](../components/otelcol/otelcol.processor.cumulativetodelta)
- [otelcol.processor.deltatocumulative](../components/otelcol/otelcol.processor.deltatocumulative)
- [otelcol.processor.discovery](../components/otelcol/otelcol.processor.discovery)
- [otelcol.processor.filter](../components/otelcol/otelcol.processor.filter)
Expand Down Expand Up @@ -348,6 +349,7 @@ The following components, grouped by namespace, _consume_ OpenTelemetry `otelcol
- [otelcol.connector.spanmetrics](../components/otelcol/otelcol.connector.spanmetrics)
- [otelcol.processor.attributes](../components/otelcol/otelcol.processor.attributes)
- [otelcol.processor.batch](../components/otelcol/otelcol.processor.batch)
- [otelcol.processor.cumulativetodelta](../components/otelcol/otelcol.processor.cumulativetodelta)
- [otelcol.processor.deltatocumulative](../components/otelcol/otelcol.processor.deltatocumulative)
- [otelcol.processor.discovery](../components/otelcol/otelcol.processor.discovery)
- [otelcol.processor.filter](../components/otelcol/otelcol.processor.filter)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
canonical: https://grafana.com/docs/alloy/latest/reference/components/otelcol/otelcol.processor.cumulativetodelta/
aliases:
- ../otelcol.processor.cumulativetodelta/ # /docs/alloy/latest/reference/otelcol.processor.cumulativetodelta/
description: Learn about otelcol.processor.cumulativetodelta
labels:
stage: public-preview
title: otelcol.processor.cumulativetodelta
---

# `otelcol.processor.cumulativetodelta`

{{< docs/shared lookup="stability/public_preview.md" source="alloy" version="<ALLOY_VERSION>" >}}

`otelcol.processor.cumulativetodelta` accepts metrics from other `otelcol` components and converts metrics with the cumulative temporality to delta.

{{< admonition type="note" >}}
`otelcol.processor.cumulativetodelta` is a wrapper over the upstream OpenTelemetry Collector `cumulativetodelta` processor.
Bug reports or feature requests will be redirected to the upstream repository, if necessary.
{{< /admonition >}}

You can specify multiple `otelcol.processor.cumulativetodelta` components by giving them different labels.

## Usage

```alloy
otelcol.processor.cumulativetodelta "<LABEL>" {
output {
metrics = [...]
}
}
```

## Arguments

You can use the following arguments with `otelcol.processor.cumulativetodelta`:

| Name | Type | Description | Default | Required |
| --------------- | ---------- | ---------------------------------------------------------------------- | -------- | -------- |
| `initial_value` | `string` | Handling of the first observed point for a given metric identity. | `"auto"` | no |
| `max_staleness` | `duration` | The total time a state entry will live past the time it was last seen. | `"0"` | no |

`otelcol.processor.cumulativetodelta` tracks incoming metric streams.
Sum and exponential histogram metrics with delta temporality are tracked and converted into cumulative temporality.

If a new sample hasn't been received since the duration specified by `max_staleness`, tracked streams are considered stale and dropped.
When set to `"0"`, the state is retained indefinitely.

The `initial_value` sets the handling of the first observed point for a given metric identity.
When the collector (re)starts, there's no record of how much of a given cumulative counter has already been converted to delta values.

* `"auto"` (default): Send the observed value if the start time is set AND the start time happens after the component started AND the start time is different from the timestamp.
This is suitable for gateway deployments. This heuristic is like `drop`, but it keeps values for newly started counters which could not have had previous observed values.
* `"keep"`: Send the observed value as the delta value. This is suitable for when the incoming metrics haven't been observed before. For example, when you are running the collector as a sidecar, the collector lifecycle is tied to the metric source.
* `"drop"`: Keep the observed value but don't send it. This is suitable for gateway deployments. It guarantees that all delta counts it produces haven't been observed before, but drops the values between the first two observations.

## Blocks

You can use the following blocks with `otelcol.processor.cumulativetodelta`:

| Block | Description | Required |
| -------------------------------- | -------------------------------------------------------------------------- | -------- |
| [`output`][output] | Configures where to send received telemetry data. | yes |
| [`debug_metrics`][debug_metrics] | Configures the metrics that this component generates to monitor its state. | no |
| [`exclude`][exclude] | Configures which metrics to not convert to delta. | no |
| [`include`][include] | Configures which metrics to convert to delta. | no |

If metric matches both `include` and `exclude`, exclude takes preference.
If neither `include` nor `exclude` are supplied, no filtering is applied.

[include]: #include
[exclude]: #exclude
[output]: #output
[debug_metrics]: #debug_metrics

### `output`

<span class="badge docs-labels__stage docs-labels__item">Required</span>

{{< docs/shared lookup="reference/components/output-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

### `include`

The `include` block configures which metrics to convert to delta.

The following attributes are supported:

| Name | Type | Description | Default | Required |
| ------------ | -------------- | --------------------------------------- | ------- | -------- |
| `metrics` | `list(string)` | Names or patterns to convert to delta | | no |
| `match_type` | `string` | Match type to use, `strict` or `regexp` | | no |

If one of `metrics` or `match_type` is supplied, the other must be supplied too.

### `exclude`

The `exclude` block configures which metrics not to convert to delta.
`exclude` takes precedence over `include`

The following attributes are supported:

| Name | Type | Description | Default | Required |
| ------------ | -------------- | --------------------------------------- | ------- | -------- |
| `metrics` | `list(string)` | Names or patterns to convert to delta | | no |
| `match_type` | `string` | Match type to use, `strict` or `regexp` | | no |

If one of `metrics` or `match_type` is supplied, the other must be supplied too.

### `debug_metrics`

{{< docs/shared lookup="reference/components/otelcol-debug-metrics-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

## Exported fields

The following fields are exported and can be referenced by other components:

| Name | Type | Description |
| ------- | ------------------ | ---------------------------------------------------------------- |
| `input` | `otelcol.Consumer` | A value that other components can use to send telemetry data to. |

`input` accepts `otelcol.Consumer` data for metrics.

## Component health

`otelcol.processor.cumulativetodelta` is only reported as unhealthy if given an invalid configuration.

## Debug information

`otelcol.processor.cumulativetodelta` doesn't expose any component-specific debug information.

## Example


This example converts cumulative temporality metrics to delta before sending it to [`otelcol.exporter.otlp`][otelcol.exporter.otlp] for further processing.

```alloy
otelcol.processor.cumulativetodelta "default" {
output {
metrics = [otelcol.exporter.otlp.production.input]
}
}

otelcol.exporter.otlp "production" {
client {
endpoint = sys.env("OTLP_SERVER_ENDPOINT")
}
}
```

[otelcol.exporter.otlp]: ../otelcol.exporter.otlp/

<!-- START GENERATED COMPATIBLE COMPONENTS -->

## Compatible components

`otelcol.processor.cumulativetodelta` can accept arguments from the following components:

- Components that export [OpenTelemetry `otelcol.Consumer`](../../../compatibility/#opentelemetry-otelcolconsumer-exporters)

`otelcol.processor.cumulativetodelta` has exports that can be consumed by the following components:

- Components that consume [OpenTelemetry `otelcol.Consumer`](../../../compatibility/#opentelemetry-otelcolconsumer-consumers)

{{< admonition type="note" >}}
Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.
{{< /admonition >}}

<!-- END GENERATED COMPATIBLE COMPONENTS -->
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/loki v0.116.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.116.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.116.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.116.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.116.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.116.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor v0.116.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/zipkin v0.116.0/go.mod h1:9TzKV3YvfXnz9PUoKluRG3iQkOVQMNZcUJy+CUnthkY=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.116.0 h1:3qdGwEhZmRyepVnOwPTe4fk6WDKxUCivr6RHleX7hy4=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.116.0/go.mod h1:FAuz4SFxKZwNgptL1BVarh6SEO4gQ1I7SclJScBBho4=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.116.0 h1:+daFa0jsEaIgyEfGQfn/osSfKYaErOypxHNeytYYF08=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/cumulativetodeltaprocessor v0.116.0/go.mod h1:+nGFbElge3UAkSHzrPalOUYmGKcQGgKU8e6NZbRy1x8=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.116.0 h1:ZBmLuipJv7BT9fho/2yAFsS8AtMsCOCe4ON8oqkX3n8=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.116.0/go.mod h1:f0GdYWGxUunyRZ088gHnoX78pc/gZc3dQlRtidiGXzg=
github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.116.0 h1:XHe77t+TheItR0xPgtmk3+ijTdXlkupCNXidzUEyjbc=
Expand Down
1 change: 1 addition & 0 deletions internal/component/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import (
_ "github.com/grafana/alloy/internal/component/otelcol/extension/jaeger_remote_sampling" // Import otelcol.extension.jaeger_remote_sampling
_ "github.com/grafana/alloy/internal/component/otelcol/processor/attributes" // Import otelcol.processor.attributes
_ "github.com/grafana/alloy/internal/component/otelcol/processor/batch" // Import otelcol.processor.batch
_ "github.com/grafana/alloy/internal/component/otelcol/processor/cumulativetodelta" // Import otelcol.processor.cumulativetodelta
_ "github.com/grafana/alloy/internal/component/otelcol/processor/deltatocumulative" // Import otelcol.processor.deltatocumulative
_ "github.com/grafana/alloy/internal/component/otelcol/processor/discovery" // Import otelcol.processor.discovery
_ "github.com/grafana/alloy/internal/component/otelcol/processor/filter" // Import otelcol.processor.filter
Expand Down
Loading