-
Notifications
You must be signed in to change notification settings - Fork 5k
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
andrzej-stencel
merged 8 commits into
elastic:main
from
andrzej-stencel:add-beat-processor
Jul 21, 2025
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
10b52ba
feat(otel): add skeleton of Beat processor
andrzej-stencel b9390f7
Merge remote-tracking branch 'upstream/main' into add-beat-processor
andrzej-stencel b41e181
refactor: separate the OTel Beat processor from Beat processors in code
andrzej-stencel 2279c6e
docs: add note on compatibility with receivers
andrzej-stencel 6335f5a
Merge remote-tracking branch 'upstream/main' into add-beat-processor
andrzej-stencel 8801c21
Merge remote-tracking branch 'upstream/main' into add-beat-processor
andrzej-stencel d17a2ea
docs: make the processor description clearer
andrzej-stencel 6d9b9b4
docs: add README in `x-pack/otel` directory
andrzej-stencel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}, | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.