Open
Conversation
Add support for Datadog Time Slice SLOs alongside the existing metric and monitor SLO types. Time Slice SLOs use an SLI specification with metric queries, formulas, a comparator, and a threshold to determine what counts as good uptime in each time slice. - Add DatadogSLOTypeTimeSlice and related CRD types (DatadogSLOTimeSlice, DatadogSLOFormula, DatadogSLODataSourceQuery, DatadogSLOTimeSliceComparator) - Add TimeSlice field to DatadogSLOSpec following the existing pattern where each SLO type has its own dedicated payload field - Add validation for time_slice specs including cross-field rejection to prevent invalid type/field combinations - Add buildSliSpecification() mapping to the datadogV1 SDK types with hardcoded metrics data source - Add comprehensive unit tests for validation and API mapping - Regenerate CRDs and deepcopy/openapi code
6ce7bb9 to
7fcdc8e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2701 +/- ##
==========================================
+ Coverage 38.80% 38.90% +0.10%
==========================================
Files 309 309
Lines 26750 26775 +25
==========================================
+ Hits 10379 10416 +37
+ Misses 15592 15586 -6
+ Partials 779 773 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds support for Datadog Time Slice SLOs alongside the existing
metricandmonitorSLO types.Time Slice SLOs use an SLI specification with a metric query, a comparator, and a threshold to determine what counts as good uptime in each time window. This is modeled as a new
timeSlicefield onDatadogSLOSpec, following the existing pattern where each SLO type has its own dedicated payload field (queryfor metric,monitorIDsfor monitor,timeSlicefor time_slice).The API is designed for simplicity: the user provides a single metric query string, and the operator auto-generates the named query (
query1) and formula (query1) when building the Datadog API request — matching the ergonomics of metric SLOs where users provide one query and the operator handles the rest.Example CR:
Motivation
The Datadog API supports three SLO types:
metric,monitor, andtime_slice. The operator previously only supportedmetricandmonitor. Time Slice SLOs are useful for monitoring uptime based on SLI thresholds evaluated per time window, which is a common pattern for service availability targets.Additional Notes
DataSourceis intentionally omitted from the CRD and hardcoded to"metrics"in the API mapping, since Datadog only supports metric data sources for time_slice SLOs.Comparatorfield is a kubebuilder-validated enum (>,>=,<,<=), rejected at admission time if invalid.timeSlicewithtype: metric, orquerywithtype: time_slice).Minimum Agent Versions
No minimum agent version required. This change only affects the operator's interaction with the Datadog API.
Describe your test plan
datadogslo_validation_test.go): 7 test cases covering valid time_slice spec, missing TimeSlice field, empty query, and all cross-field rejection combinations.slo_test.go):buildSLOtest cases covering metric, monitor, and time_slice — verifying the full SDK object construction including hardcoded data source and auto-generated query/formula names.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel