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

Customizable prefix for Kafka topics #102

Closed
hekike opened this issue Jul 11, 2023 · 2 comments
Closed

Customizable prefix for Kafka topics #102

hekike opened this issue Jul 11, 2023 · 2 comments
Assignees
Labels
area/ingest kind/feature New feature or request

Comments

@hekike
Copy link
Contributor

hekike commented Jul 11, 2023

Currently, we use a hardcoded prefix om_ to prefix Kafka topics. For example:

  • om_events
  • om_detected_events
  • om_meter_m1

Requirements:

  • Support prefixes via header as OM-Prefix.
  • Default to om_ prefix.
  • Add API to create events and detected_events topics: POST /api/ingests
  • By default create om_events and om_detected_events topics.
  • Optionally configure ingestion topics via Kafka instead of ksql streams (in this case move partition and scheme a config to Kafka create)
@sagikazarmark
Copy link
Member

This proved to be a tougher nut to crack than expected, but after some experimentation and bouncing off some walls, here is what I came up with:

  • The name "prefix" seems too implementation specific. I'd recommend going back to the "namespace" terminology as it's easier to explain without delving too much into the implementation.
  • I did some research and it seems there is nothing against sending a query string in a POST request (ie. the HTTP spec does not specifically deny it and people seem to accept it as a viable solution). Why is a query string better? Easier to represent in the OpenAPI spec.

With those in mind:

  • OpenMeter would create a "default" (empty) namespace on launch (In case of Kafka and KSQLDB this means the current behavior)
  • Sending a POST /api/namespaces request will create a namespace (TODO: come up with a validation rule for the name) (In case of Kafka and KSQLDB, it means new events and detected_events topic/table)
  • Sending a POST /api/ingest request (without namespace) will land the event in the "default" (empty) namespace (ie. no topic name prefix)
  • Sending a POST /api/ingest?namespace=asd request will land the event in the "asd" namespace (ie. topic name will be om_asd_events)

It took me some time to figure out a way to even think about the prefix concept in a consistent way and I realized that it's not a good term we can easily explain or reason about, so I decided to change it.

Let me know what you think.

@sagikazarmark
Copy link
Member

This is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ingest kind/feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants