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

[datadog_service_level_objective] Add query_interval_seconds to time-slice SLO condition parameters #2349

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

ddjamesfrullo
Copy link
Contributor

@ddjamesfrullo ddjamesfrullo commented Apr 4, 2024

https://datadoghq.atlassian.net/browse/SLO-3189

Overview

This adds the query_interval_seconds parameter to the time-slice SLO condition, used when creating and modifying SLOs. This parameter controls the size of a time-slice, and hence the granularity of the uptime measurement. We only want to allow two values for - 60 (1 minute) and 300 (5 minutes). This is done via validation. The corresponding API change was done here.

Motivation

Allow customers to create time-slice SLOs using 1-minute granularity by specifying query_interval_seconds as 60.

Example Terraform

resource "datadog_service_level_objective" "time_slice_slo_1" {
  name              = "Terraform test for Time Slice"
  type              = "time_slice"
  description       = "Created as part of a manual test of Terrform provider changes to support time-slice SLO"
  sli_specification {
    time_slice {
      query {
        formula {
          formula_expression = "(query1-query2)/query1"
        }
        query {
          metric_query {
            name        = "query1"
            data_source = "metrics"
            query       = "sum:trace.grpc.server.hits{service:monitor-history-reader}"
          }
        }
        query {
          metric_query {
            name        = "query2"
            query       = "sum:trace.grpc.server.errors{service:monitor-history-reader}"
          }
        }
      }
      comparator             = ">"
      threshold              = 0.99
      query_interval_seconds = 60
    }
  }

  thresholds {
    timeframe = "7d"
    target    = 99.0
    warning   = 99.5
  }

  timeframe         = "7d"
  target_threshold  = 99.0
  warning_threshold = 99.5

  tags              = ["test:true"]
}

Testing

I tested the following:

  1. Applying the above resource to create a time-slice SLO with 1-minute granularity
  2. Applying a change from 60 -> 300 for the query interval, modifying the existing SLO
  3. Applying a change back to 60, again modifying the SLO

The resulting SLO is here.

I also tested not specifying query_interval_seconds and tested that a 5-minute-granularity time-slice SLO was created. That SLO is here.

Finally, I tested specifying an invalid value for query_interval_seconds, and I get this error message:

╷
│ Error: Invalid enum value
│ 
│   with datadog_service_level_objective.invalid_query_interval,
│   on slo.tf line 111, in resource "datadog_service_level_objective" "invalid_query_interval":
│  111:       query_interval_seconds = 120
│ 
│ `invalid value '120' for SLOTimeSliceInterval: valid values are [60 300]`
╵

@ddjamesfrullo ddjamesfrullo requested review from a team as code owners April 4, 2024 14:57
@ddjamesfrullo ddjamesfrullo force-pushed the ddjamesfrullo/slo-3189 branch 3 times, most recently from 7778721 to 7f36567 Compare April 4, 2024 15:55
@ddjamesfrullo ddjamesfrullo requested a review from a team as a code owner April 4, 2024 15:55
aliciascott
aliciascott previously approved these changes Apr 4, 2024
zhengshizhao
zhengshizhao previously approved these changes Apr 4, 2024
Copy link
Contributor

@zhengshizhao zhengshizhao left a comment

Choose a reason for hiding this comment

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

nice!

@ddjamesfrullo ddjamesfrullo dismissed stale reviews from zhengshizhao and aliciascott via fa4ff85 April 4, 2024 19:58
@ddjamesfrullo ddjamesfrullo force-pushed the ddjamesfrullo/slo-3189 branch 3 times, most recently from a3ecaae to e7a9f3b Compare April 4, 2024 21:14
@ddjamesfrullo ddjamesfrullo force-pushed the ddjamesfrullo/slo-3189 branch from e7a9f3b to 2406ffc Compare April 4, 2024 22:13
@nkzou nkzou changed the title SLO-3189: Add query_interval_seconds to time-slice SLO condition parameters [datadog_service_level_objective] Add query_interval_seconds to time-slice SLO condition parameters Apr 5, 2024
@nkzou nkzou merged commit 9e2b0ff into master Apr 5, 2024
11 of 14 checks passed
@nkzou nkzou deleted the ddjamesfrullo/slo-3189 branch April 5, 2024 19:04
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.

4 participants