Skip to content

feat: Add ServiceMonitor auto-generation for Prometheus discovery#6126

Open
ntkathole wants to merge 2 commits intofeast-dev:masterfrom
ntkathole:service_monitor
Open

feat: Add ServiceMonitor auto-generation for Prometheus discovery#6126
ntkathole wants to merge 2 commits intofeast-dev:masterfrom
ntkathole:service_monitor

Conversation

@ntkathole
Copy link
Member

@ntkathole ntkathole commented Mar 18, 2026

What this PR does / why we need it:

This implements ServiceMonitor auto-generation for the Feast Operator, enabling automatic Prometheus discovery for Kubernetes deployments when metrics: true is set on the online store. The operator detects the monitoring.coreos.com API group at startup. If the Prometheus Operator CRD is absent, ServiceMonitor operations are skipped.

Which issue(s) this PR fixes:

Fixes #6072


Open with Devin

@ntkathole ntkathole self-assigned this Mar 18, 2026
@ntkathole ntkathole requested a review from a team as a code owner March 18, 2026 14:22
@ntkathole
Copy link
Member Author

cc @astefanutti

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@ntkathole ntkathole force-pushed the service_monitor branch 2 times, most recently from ab3e933 to 0671276 Compare March 18, 2026 14:51
func (feast *FeastServices) createServiceMonitor() error {
logger := log.FromContext(feast.Handler.Context)
sm := feast.initServiceMonitor()
if op, err := controllerutil.CreateOrUpdate(feast.Handler.Context, feast.Handler.Client, sm, controllerutil.MutateFn(func() error {

Choose a reason for hiding this comment

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

Maybe continue using server-side apply like we've started for HPA?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call 👍 updated

devin-ai-integration[bot]

This comment was marked as resolved.

Signed-off-by: ntkathole <[email protected]>
cr := feast.Handler.FeatureStore
objMeta := feast.GetObjectMetaType(OnlineFeastType)

return map[string]interface{}{

Choose a reason for hiding this comment

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

Maybe use the apply config from the Prometheus operator client?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is trade-off, it will make code cleaner but our use is of just one small builder. May be we can avoid coupling (new dependencies, version alignment) to the Prometheus operator's release cycle ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Operator should create a ServiceMonitor for FeatureStore metrics when metrics: true is enabled

2 participants