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

feat(inputs.kafka_consumer): Add regular expression support for topics #11831

Merged
merged 21 commits into from
May 23, 2023

Conversation

athornton
Copy link
Contributor

@athornton athornton commented Sep 18, 2022

Required for all PRs

This is a companion piece to #11816 and builds on top of it. It uses a connection to the Kafka broker to determine which topics are available, match them with a regular expression. This requires the set-metric-from-measurement in the Avro handler, which requires the schema registry, and therefore this is only useful in conjunction with the Avro parser.

In the Rubin Observatory use case, we connect to a Kafka broker with a large number of topics, which are added to dynamically, and we therefore require something like this. (For the time being, we will restart the broker to pick up new topics; dynamic detection is a planned future enhancement.)

The motivation is that this is essentially the behavior that lensesio/stream-reactor gives with its kafka-influx connector (which is what we have been using), except that that implementation only works with InfluxDBv1, while this will work with any Telegraf output. Since Rubin Observatory is trying to move to InfluxDBv2, we require something like this.

Added a configuration items to specify a list of regular expressions for topics to match; then I added an implementation for this item.

@athornton athornton changed the title (feat)/inputs/kafka_consumer: add regular expression support for topics and dynamic topic detection feat(inputs/kafka_consumer): add regular expression support for topics and dynamic topic detection Sep 19, 2022
@Hipska Hipska added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin area/kafka plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Sep 19, 2022
@Hipska Hipska changed the title feat(inputs/kafka_consumer): add regular expression support for topics and dynamic topic detection feat(inputs.kafka_consumer): add regular expression support for topics and dynamic topic detection Sep 19, 2022
@athornton athornton force-pushed the features/kafka-regexp branch 5 times, most recently from 3e9696c to 6fe3366 Compare September 20, 2022 18:33
@athornton athornton force-pushed the features/kafka-regexp branch 11 times, most recently from 7e4ff5d to b139e0e Compare September 28, 2022 03:20
@athornton athornton force-pushed the features/kafka-regexp branch 4 times, most recently from 4af8375 to 50a80b4 Compare October 4, 2022 16:58
@athornton athornton force-pushed the features/kafka-regexp branch 3 times, most recently from cb2f57f to 38fdfd2 Compare March 2, 2023 19:09
@athornton
Copy link
Contributor Author

The Avro changes have landed, and now there's a test suite that uses Docker to run Kafka containers, so I'm working on this again.

plugins/inputs/kafka_consumer/kafka_consumer.go Outdated Show resolved Hide resolved
plugins/inputs/kafka_consumer/kafka_consumer.go Outdated Show resolved Hide resolved
plugins/inputs/kafka_consumer/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/kafka_consumer/sample.conf Outdated Show resolved Hide resolved
@srebhan
Copy link
Member

srebhan commented May 22, 2023

@athornton I agree with the comments of @Hipska. Can you please fix those and we are good to go.

Co-authored-by: Thomas Casteleyn <[email protected]>
@srebhan
Copy link
Member

srebhan commented May 22, 2023

@athornton added two suggestions. Those should work and only require you to run make docs... No need to do big explanations... :-)

@athornton
Copy link
Contributor Author

Suggestions incorporated and "make docs" rerun.

@Hipska Hipska added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label May 22, 2023
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for the nice contribution @athornton!

@srebhan srebhan changed the title feat(inputs.kafka_consumer): add regular expression support for topics and dynamic topic detection feat(inputs.kafka_consumer): Add regular expression support for topics and dynamic topic detection May 23, 2023
@srebhan srebhan assigned powersj and unassigned srebhan May 23, 2023
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Hi,

What tells the consumer go routine to reload the topics?

There is a comment about signally the goroutine, but where does this happen?

@athornton
Copy link
Contributor Author

We currently are not signaling to restart consumers on topic change. That's going to take some thought to implement without race conditions. I would prefer to tackle that as future work and close this one, which has been open eight months.

@powersj
Copy link
Contributor

powersj commented May 23, 2023

We currently are not signaling to restart consumers on topic change. That's going to take some thought to implement without race conditions.

Then I would need to ask you to remove the dynamic topic detection for the purpose of this PR. No reason to have it land when it does nothing.

An update to the PR title and description would be good as well.

@athornton athornton changed the title feat(inputs.kafka_consumer): Add regular expression support for topics and dynamic topic detection feat(inputs.kafka_consumer): Add regular expression support for topics May 23, 2023
@athornton
Copy link
Contributor Author

Refresh interval removed.

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Thanks!

@powersj powersj merged commit 8762c71 into influxdata:master May 23, 2023
@athornton athornton deleted the features/kafka-regexp branch June 6, 2023 16:53
@athornton athornton restored the features/kafka-regexp branch June 6, 2023 16:53
@athornton athornton deleted the features/kafka-regexp branch June 6, 2023 16:53
@srebhan srebhan added this to the v1.27.0 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kafka feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants