Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Add support for topic "selectors" to Kafka output #199

Merged
merged 8 commits into from
Dec 13, 2022

Conversation

robbavey
Copy link
Member

@robbavey robbavey commented Dec 7, 2022

What does this PR do?

This commit adds support for topic selectors to provide parity with the existing beats Kafka output - see https://www.elastic.co/guide/en/beats/filebeat/current/kafka-output.html#topic-option-kafka and https://www.elastic.co/guide/en/beats/filebeat/current/kafka-output.html#topics-option-kafka for details on how to use this function.

This PR continues to use the outil.Selector from libbeat as used in the beats Kafka output

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
    - [ ] I have added an entry in CHANGELOG.md or CHANGELOG-developer.md.

How to test this PR locally

Testing can be done the same way as #147, with changes for the kafka output:

Run a local Kafka running on port 9092, and using metricbeat with:

output.shipper:
  server: "localhost:50052"

And the following settings in elastic-agent-shipper.yml

output.kafka:
  enabled: true
  hosts: ["localhost:9092"]
  topics:
  - topic: "network"
    when.contains:
      metricset.name: "network"
  - topic: "process"
    when.contains:
      metricset.name: "process"
  - topic: "error"
    default:  

And using kcat to pull messages out of the various topics to prove the correctness of delivery.

kcat -b localhost:9092 -G mygroup <TOPIC_NAME>

Related issues

Closes #167

@mergify
Copy link
Contributor

mergify bot commented Dec 7, 2022

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @robbavey? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 7, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-12-08T18:46:06.036+0000

  • Duration: 16 min 58 sec

❕ Flaky test report

No test was executed to be analysed.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@robbavey robbavey marked this pull request as ready for review December 8, 2022 17:37
@robbavey robbavey requested a review from a team as a code owner December 8, 2022 17:38
@robbavey robbavey requested review from rdner and faec and removed request for a team December 8, 2022 17:38
Copy link
Contributor

@faec faec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks good as a stopgap but it makes me nervous that it expands our dependence on beat.Event, which we ultimately want to remove from the shipper. Can you open a followup issue to add "real" selector support to the Kafka output that doesn't depend on the old libbeat data structures?

@robbavey robbavey merged commit 82e6a53 into elastic:main Dec 13, 2022
@robbavey
Copy link
Member Author

@faec Yeah, I agree with that - I've created #203 to track

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kafka output topic selection should match that from beats output
3 participants