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

[DO NOT MERGE] Standalone Beats OTel collector PoC #41001

Closed
wants to merge 21 commits into from

Conversation

rdner
Copy link
Member

@rdner rdner commented Sep 26, 2024

This is the results of our experiment embedding OTel collector into Beats for running them in the standalone mode.

--

Steps to run filebeat in otel mode:

  1. Clone from this branch.
  2. Build the filebeat binary with mage package
  3. Run the binary using
./filebeat otel --config /path/to/otel/config

The filebeat-otel mode makes use of filebeatreceiver and config of that same as that of standalone filebeat.


Currently, we are using hardcoded OpenTelemetry configurations, as the conversion from Filebeat to OpenTelemetry is nearly complete. There are still a few remaining tasks to address, and we’re actively working on them.

belimawr and others added 6 commits September 24, 2024 21:17
Format files, update NOTICE.txt
This commit improves the TLS handling by reading all certificates and
passing them as PEM strings to the OTel configuration and some other
fields are better handled in the configuration. The tests are
improved.
commit 16ecdee682027804deddd108a0229fbfe57a9013
Author: Vihas Makwana <[email protected]>
Date:   Thu Sep 26 11:49:02 2024 +0530

    go.mod

commit c2aa64b
Merge: b92b041 cc9b664
Author: Vihas Makwana <[email protected]>
Date:   Thu Sep 26 11:29:28 2024 +0530

    Merge branch 'beats-otel-collector' into esotel-beats

commit b92b041
Merge: 126aa22 7cc59c9
Author: Vihas Makwana <[email protected]>
Date:   Thu Sep 26 11:22:14 2024 +0530

    Merge branch 'lee/fbreceiver' into esotel-beats

commit 7cc59c9
Merge: 6aeba30 a08e9c1
Author: Vihas Makwana <[email protected]>
Date:   Thu Sep 26 11:21:51 2024 +0530

    Merge branch 'fbreceiver' of github.com:leehinman/beats into lee/fbreceiver

commit a08e9c1
Author: Lee Hinman <[email protected]>
Date:   Wed Sep 25 17:21:28 2024 -0500

    add debug and enable benchmark input on windows

commit bb7aaf2
Author: Lee E. Hinman <[email protected]>
Date:   Wed Sep 25 14:16:57 2024 -0500

    increase timeout for fbreceiver test, and make sure logs are current

commit f493764
Author: Lee E. Hinman <[email protected]>
Date:   Wed Sep 25 11:22:46 2024 -0500

    add slices and test cases for mapstrToPcommonMap

commit 71f6deb
Author: Blake Rouse <[email protected]>
Date:   Tue Sep 24 20:27:55 2024 -0400

    Update config_test.go

commit f354cb4
Author: Lee E Hinman <[email protected]>
Date:   Tue Sep 24 15:09:50 2024 -0500

    Update x-pack/filebeat/fbreceiver/config.go

    Co-authored-by: Blake Rouse <[email protected]>

commit d41c801
Author: Lee E Hinman <[email protected]>
Date:   Tue Sep 24 15:09:40 2024 -0500

    Update x-pack/filebeat/fbreceiver/config.go

    Co-authored-by: Blake Rouse <[email protected]>

commit 9103b0b
Author: Lee E. Hinman <[email protected]>
Date:   Tue Sep 24 14:33:49 2024 -0500

    update notice.txt

commit bd0cbfd
Author: Lee E. Hinman <[email protected]>
Date:   Tue Sep 24 14:22:21 2024 -0500

    linter fixes

commit 38715e2
Author: Lee E. Hinman <[email protected]>
Date:   Thu Sep 19 14:20:57 2024 -0500

    Add filebeat receiver and otel consumer output

commit dbbfb5b
Author: Julien Lind <[email protected]>
Date:   Wed Sep 25 19:34:34 2024 +0200

    Revert "[filebeat] Fix long filepaths in diagnostics exceeding max path limit…" (#40980)

    This reverts commit d82fe9a.

commit 126aa22
Author: Vihas Makwana <[email protected]>
Date:   Wed Sep 25 19:12:09 2024 +0530

    chore: initial commit

commit 378b796
Author: Olga Naydyonock <[email protected]>
Date:   Wed Sep 25 13:31:35 2024 +0300

    added pre-commit to x-pack/agentbeat (#40965)

commit 1e6364a
Author: Klim Markelov <[email protected]>
Date:   Wed Sep 25 12:26:16 2024 +0200

    Change codeowners from ent-search-application to app-search-team (#40963)

commit 6aeba30
Author: Blake Rouse <[email protected]>
Date:   Tue Sep 24 20:27:55 2024 -0400

    Update config_test.go

commit 55e5375
Author: Lee E Hinman <[email protected]>
Date:   Tue Sep 24 15:09:50 2024 -0500

    Update x-pack/filebeat/fbreceiver/config.go

    Co-authored-by: Blake Rouse <[email protected]>

commit d7a5211
Author: Lee E Hinman <[email protected]>
Date:   Tue Sep 24 15:09:40 2024 -0500

    Update x-pack/filebeat/fbreceiver/config.go

    Co-authored-by: Blake Rouse <[email protected]>

commit 38d1b5d
Author: Lee E. Hinman <[email protected]>
Date:   Tue Sep 24 14:33:49 2024 -0500

    update notice.txt

commit 931d661
Author: Lee E. Hinman <[email protected]>
Date:   Tue Sep 24 14:22:21 2024 -0500

    linter fixes

commit a74d26f
Author: Lee E. Hinman <[email protected]>
Date:   Thu Sep 19 14:20:57 2024 -0500

    Add filebeat receiver and otel consumer output
@rdner rdner added skip-ci Skip the build in the CI but linting backport-skip Skip notification from the automated backport with mergify labels Sep 26, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 26, 2024
It converts all configs which have a direct translation and assumes `topic` is a single topic, not a template
@elastic elastic deleted a comment from cla-checker-service bot Sep 26, 2024
@VihasMakwana
Copy link
Contributor

Attaching a demo of docker autodiscovery using filebeat (standalone otel mode)

Untitled_Project_V1.mp4

cc: @cmacknz

AndersonQ and others added 4 commits September 26, 2024 15:23
@belimawr
Copy link
Contributor

Some key points regarding converting the Elasticsearch output configuration to the Elasticsearch OTel exporter:

  1. Beats uses a custom TLS implementation, so currently only none and strict are supported
  2. ILM management is done by Beats during startup, it's not directly tied to the output
  3. None of the templateing features for index and pipelines are supported
  4. Defining the pipeline or index on the input has not been tested

Testing the output config conversion

There is a test on libbeat/outputs/elasticsearch/config_otel_test.go that shows how the conversion can be used, libbeat/outputs/elasticsearch/testdata/filebeat.yml is an example configuration covering most of the currently supported fields.

@AndersonQ AndersonQ added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Sep 26, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 26, 2024
@AndersonQ
Copy link
Member

Kafka config converter key points:

  • supporters config converted
  • topic is supported ONLY if it's a constant or just the value of an attribute
  • TLS: TODO - use the same as ES output
  • not tested with OTel kafka exporter
  • need more tests and review the current ones

@belimawr
Copy link
Contributor

Folks, I've been trying to test it but I could not get my ES config translation function to work/be called, so I made some changes, now it is used, however as it is it's first test, there are some issues I haven't fixed yet.

Currently I'm using a hack to get the ES output configuration and use it as OTel ES exporter:

  1. In cmd/otel.yml I added an output section with the Beats ES output configuration, that's the one parsed by
    esCfg, err := elasticsearch.ToOTelConfig(cfg)
  2. For some reason skipping TLS validation is not working (one of the many things to fix), so I'm using a Cloud deployment.

The way I'm testing/running:

cd x-pack/filebeat
go build .
./filebeat otel -e -v -d "*" -config filebeat:./cmd/otel.yml

I can see the config is correctly parsed, converted and used to create an Elasticsearch exporter, however the index seems to be missing. If you let it running for a while you'll get an error from the exporter.

Fix the ES output transformation so it is actually used when running
the example and add an example filebeat.yml
@belimawr
Copy link
Contributor

belimawr commented Sep 27, 2024

I finally managed to get all the different bits working together 🎉

TL;DR:
Disabling TLS is not working, it might be an issue in the Elasticsearch exporter, so just make sure to either not use TLS or use an ES/Kibana with valid certificates. If you want the dataview to be automatically created, you need to setup the Kibana host and credentials.
The configuration file for the demo is x-pack/filebeat/cmd/filebeat.yml

cd x-pack/filebeat
# This will setup ILM, Index templates, data view, etc
go run . setup -e -v
# Actually run Filebeat as OTel collector using the converted ES output settings
go run . otel -e -v -d "*" -config filebeat:./cmd/filebeat.yml

Known issues:

  • Disabling TLS validation is not working as expected.
  • cloud.id cannot be used to run Filebeat because it clashes with the output.otelconsumer we manually insert.
  • The only supported output is Elasticsearch because assemble an OTel config based on the filebeat.yml passed by picking some pieces like the output settings.

@rdner
Copy link
Member Author

rdner commented Jan 7, 2025

This PoC got polished and finalized in #41849
Closing.

@rdner rdner closed this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify skip-ci Skip the build in the CI but linting Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants