Skip to content

feat(otel): add skeleton of Beat processor #45328

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

Merged
merged 8 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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,234 changes: 1,723 additions & 1,511 deletions NOTICE.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ require (
go.opentelemetry.io/collector/exporter/debugexporter v0.129.0
go.opentelemetry.io/collector/otelcol v0.129.0
go.opentelemetry.io/collector/pdata v1.35.0
go.opentelemetry.io/collector/processor v1.35.0
go.opentelemetry.io/collector/processor/processorhelper v0.129.0
go.opentelemetry.io/collector/receiver v1.35.0
go.uber.org/mock v0.5.0
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
Expand Down Expand Up @@ -450,7 +452,6 @@ require (
go.opentelemetry.io/collector/pdata/xpdata v0.129.0 // indirect
go.opentelemetry.io/collector/pipeline v0.129.0 // indirect
go.opentelemetry.io/collector/pipeline/xpipeline v0.129.0 // indirect
go.opentelemetry.io/collector/processor v1.35.0 // indirect
go.opentelemetry.io/collector/processor/processortest v0.129.0 // indirect
go.opentelemetry.io/collector/processor/xprocessor v0.129.0 // indirect
go.opentelemetry.io/collector/receiver/receivertest v0.129.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,8 @@ go.opentelemetry.io/collector/pipeline/xpipeline v0.129.0 h1:JDLSoGiUg4JgahMqHXj
go.opentelemetry.io/collector/pipeline/xpipeline v0.129.0/go.mod h1:qDjE/5uvKmXRHaDzy7yMo/VwSm4njtRWzACTjf5CVjg=
go.opentelemetry.io/collector/processor v1.35.0 h1:YOfHemhhodYn4BnPjN7kWYYDhzPVqRkyHCaQ8mAlavs=
go.opentelemetry.io/collector/processor v1.35.0/go.mod h1:cWHDOpmpAaVNCc9K9j2/okZoLIuP/EpGGRNhM4JGmFM=
go.opentelemetry.io/collector/processor/processorhelper v0.129.0 h1:/B2UJ7wOc5oJlQBnzwXjqnhFJOidHbdGmFfWyhi1Iyg=
go.opentelemetry.io/collector/processor/processorhelper v0.129.0/go.mod h1:tZXfmQgvpIE/gxLS9tjX82/EBzWt+xNIE0lUmgZzZlk=
go.opentelemetry.io/collector/processor/processortest v0.129.0 h1:r5iJHdS7Ffdb2zmMVYx4ahe92PLrce5cas/AJEXivkY=
go.opentelemetry.io/collector/processor/processortest v0.129.0/go.mod h1:gdf8GzyzjGoDTA11+CPwC4jfXphtC+B7MWbWn+LIWXc=
go.opentelemetry.io/collector/processor/xprocessor v0.129.0 h1:V3Zgd+YIeu3Ij3DPlGtzdcTwpqOQIqQVcL5jdHHS7sc=
Expand Down
63 changes: 63 additions & 0 deletions x-pack/otel/processor/beatprocessor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Beat Processor

| Status | |
| --------- | ------------------- |
| Stability | [development]: logs |

[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development

> [!NOTE]
> This component is currently in development and no functionality is implemented.
> Including it in a pipeline is a no-op.
> The documentation describes the intended state after the functionality is implemented.

The Beat processor (`beat`) makes the functionality of [Beat processors] available in an OpenTelemetry Collector's processor.
This allows users to configure Beat processors anywhere in the OpenTelemetry Collector's pipeline, independently of Beat receivers.

> [!NOTE]
> This component is only expected to work correctly with data from the Beat receivers: [Filebeat receiver], [Metricbeat receiver].
> This is because it relies on the specific structure of telemetry emitted by those components.
> Using it with data coming from other components is not recommended and may result in unexpected behavior.

## Example

The following [Filebeat receiver] configuration

```yaml
receivers:
filebeatreceiver:
filebeat:
inputs:
- type: filestream
id: host-logs
paths:
- /var/log/*.log
processors:
- add_host_metadata: ~
output:
otelconsumer:
```

is functionally equivalent to this one, using the Beat processor:

```yaml
receivers:
filebeatreceiver:
filebeat:
inputs:
- type: filestream
id: host-logs
paths:
- /var/log/*.log
output:
otelconsumer:

processors:
beat:
processors:
- add_host_metadata: ~
```

[Beat processors]: https://www.elastic.co/docs/reference/beats/filebeat/filtering-enhancing-data#using-processors
[Filebeat receiver]: https://github.com/elastic/beats/tree/main/x-pack/filebeat/fbreceiver
[Metricbeat receiver]: https://github.com/elastic/beats/tree/main/x-pack/metricbeat/mbreceiver
7 changes: 7 additions & 0 deletions x-pack/otel/processor/beatprocessor/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package beatprocessor

type Config struct{}
49 changes: 49 additions & 0 deletions x-pack/otel/processor/beatprocessor/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package beatprocessor

import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/processorhelper"
)

const (
Name = "beat"
)

func NewFactory() processor.Factory {
return processor.NewFactory(
component.MustNewType(Name),
createDefaultConfig,
processor.WithLogs(createLogsProcessor, component.StabilityLevelDevelopment),
)
}

func createDefaultConfig() component.Config {
return &Config{}
}

func createLogsProcessor(
ctx context.Context,
set processor.Settings,
cfg component.Config,
nextConsumer consumer.Logs,
) (processor.Logs, error) {
return processorhelper.NewLogs(
ctx,
set,
cfg,
nextConsumer,
func(_ context.Context, logs plog.Logs) (plog.Logs, error) {
// This is a placeholder for the actual processing logic.
return logs, nil
},
)
}
Loading