Skip to content

googleMonitoringSlo

A Service-Level Objective (SLO) describes the level of desired good service. It consists of a service-level indicator (SLI), a performance goal, and a period over which the objective is to be evaluated against that goal. The SLO can use SLIs defined in a number of different manners. Typical SLOs might include "99% of requests in each rolling week have latency below 200 milliseconds" or "99.5% of requests in each calendar month return successfully."

To get more information about Slo, see:

Example Usage - Monitoring Slo Appengine

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const dataGoogleMonitoringAppEngineServiceDefault =
  new google.dataGoogleMonitoringAppEngineService.DataGoogleMonitoringAppEngineService(
    this,
    "default",
    {
      module_id: "default",
    }
  );
new google.monitoringSlo.MonitoringSlo(this, "appeng_slo", {
  basic_sli: [
    {
      latency: [
        {
          threshold: "1s",
        },
      ],
    },
  ],
  calendar_period: "DAY",
  display_name: "Terraform Test SLO for App Engine",
  goal: 0.9,
  service: dataGoogleMonitoringAppEngineServiceDefault.serviceId,
  slo_id: "ae-slo",
  user_labels: [
    {
      my_key: "my_value",
      my_other_key: "my_other_value",
    },
  ],
});

Example Usage - Monitoring Slo Request Based

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleMonitoringCustomServiceCustomsrv =
  new google.monitoringCustomService.MonitoringCustomService(
    this,
    "customsrv",
    {
      display_name: "My Custom Service",
      service_id: "custom-srv-request-slos",
    }
  );
new google.monitoringSlo.MonitoringSlo(this, "request_based_slo", {
  display_name: "Terraform Test SLO with request based SLI (good total ratio)",
  goal: 0.9,
  request_based_sli: [
    {
      distribution_cut: [
        {
          distribution_filter:
            'metric.type="serviceruntime.googleapis.com/api/request_latencies" resource.type="api"  ',
          range: [
            {
              max: 0.5,
            },
          ],
        },
      ],
    },
  ],
  rolling_period_days: 30,
  service: googleMonitoringCustomServiceCustomsrv.serviceId,
  slo_id: "consumed-api-slo",
});

Example Usage - Monitoring Slo Windows Based Good Bad Metric Filter

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleMonitoringCustomServiceCustomsrv =
  new google.monitoringCustomService.MonitoringCustomService(
    this,
    "customsrv",
    {
      display_name: "My Custom Service",
      service_id: "custom-srv-windows-slos",
    }
  );
new google.monitoringSlo.MonitoringSlo(this, "windows_based", {
  calendar_period: "FORTNIGHT",
  display_name: "Terraform Test SLO with window based SLI",
  goal: 0.95,
  service: googleMonitoringCustomServiceCustomsrv.serviceId,
  windows_based_sli: [
    {
      good_bad_metric_filter:
        '${join(" AND ", [\n      "metric.type=\\"monitoring.googleapis.com/uptime_check/check_passed\\"",\n      "resource.type=\\"uptime_url\\"",\n    ])}',
      window_period: "400s",
    },
  ],
});

Example Usage - Monitoring Slo Windows Based Metric Mean

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleMonitoringCustomServiceCustomsrv =
  new google.monitoringCustomService.MonitoringCustomService(
    this,
    "customsrv",
    {
      display_name: "My Custom Service",
      service_id: "custom-srv-windows-slos",
    }
  );
new google.monitoringSlo.MonitoringSlo(this, "windows_based", {
  display_name: "Terraform Test SLO with window based SLI",
  goal: 0.9,
  rolling_period_days: 20,
  service: googleMonitoringCustomServiceCustomsrv.serviceId,
  windows_based_sli: [
    {
      metric_mean_in_range: [
        {
          range: [
            {
              max: 5,
            },
          ],
          time_series:
            '${join(" AND ", [\n        "metric.type=\\"agent.googleapis.com/cassandra/client_request/latency/95p\\"",\n        "resource.type=\\"gce_instance\\"",\n      ])}',
        },
      ],
      window_period: "600s",
    },
  ],
});

Example Usage - Monitoring Slo Windows Based Metric Sum

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleMonitoringCustomServiceCustomsrv =
  new google.monitoringCustomService.MonitoringCustomService(
    this,
    "customsrv",
    {
      display_name: "My Custom Service",
      service_id: "custom-srv-windows-slos",
    }
  );
new google.monitoringSlo.MonitoringSlo(this, "windows_based", {
  display_name: "Terraform Test SLO with window based SLI",
  goal: 0.9,
  rolling_period_days: 20,
  service: googleMonitoringCustomServiceCustomsrv.serviceId,
  windows_based_sli: [
    {
      metric_sum_in_range: [
        {
          range: [
            {
              max: 5000,
            },
          ],
          time_series:
            '${join(" AND ", [\n        "metric.type=\\"monitoring.googleapis.com/uptime_check/request_latency\\"",\n        "resource.type=\\"uptime_url\\"",\n      ])}',
        },
      ],
      window_period: "400s",
    },
  ],
});

Example Usage - Monitoring Slo Windows Based Ratio Threshold

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleMonitoringCustomServiceCustomsrv =
  new google.monitoringCustomService.MonitoringCustomService(
    this,
    "customsrv",
    {
      display_name: "My Custom Service",
      service_id: "custom-srv-windows-slos",
    }
  );
new google.monitoringSlo.MonitoringSlo(this, "windows_based", {
  display_name: "Terraform Test SLO with window based SLI",
  goal: 0.9,
  rolling_period_days: 20,
  service: googleMonitoringCustomServiceCustomsrv.serviceId,
  windows_based_sli: [
    {
      good_total_ratio_threshold: [
        {
          performance: [
            {
              distribution_cut: [
                {
                  distribution_filter:
                    '${join(" AND ", [\n            "metric.type=\\"serviceruntime.googleapis.com/api/request_latencies\\"",\n            "resource.type=\\"consumed_api\\"",\n          ])}',
                  range: [
                    {
                      max: 9,
                      min: 1,
                    },
                  ],
                },
              ],
            },
          ],
          threshold: 0.1,
        },
      ],
      window_period: "100s",
    },
  ],
});

Argument Reference

The following arguments are supported:

  • goal - (Required) The fraction of service that must be good in order for this objective to be met. 0 < goal <= 0.999

  • service - (Required) ID of the service to which this SLO belongs.


  • displayName - (Optional) Name used for UI elements listing this SLO.

  • rollingPeriodDays - (Optional) A rolling time period, semantically "in the past X days". Must be between 1 to 30 days, inclusive.

  • calendarPeriod - (Optional) A calendar period, semantically "since the start of the current ". Possible values are day, week, fortnight, and month.

  • userLabels - (Optional) This field is intended to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.

  • basicSli - (Optional) Basic Service-Level Indicator (SLI) on a well-known service type. Performance will be computed on the basis of pre-defined metrics. SLIs are used to measure and calculate the quality of the Service's performance with respect to a single aspect of service quality. Exactly one of the following must be set: basicSli, requestBasedSli, windowsBasedSli Structure is documented below.

  • requestBasedSli - (Optional) A request-based SLI defines a SLI for which atomic units of service are counted directly. A SLI describes a good service. It is used to measure and calculate the quality of the Service's performance with respect to a single aspect of service quality. Exactly one of the following must be set: basicSli, requestBasedSli, windowsBasedSli Structure is documented below.

  • windowsBasedSli - (Optional) A windows-based SLI defines the criteria for time windows. good_service is defined based off the count of these time windows for which the provided service was of good quality. A SLI describes a good service. It is used to measure and calculate the quality of the Service's performance with respect to a single aspect of service quality. Exactly one of the following must be set: basicSli, requestBasedSli, windowsBasedSli Structure is documented below.

  • sloId - (Optional) The id to use for this ServiceLevelObjective. If omitted, an id will be generated instead.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The basicSli block supports:

  • method - (Optional) An optional set of RPCs to which this SLI is relevant. Telemetry from other methods will not be used to calculate performance for this SLI. If omitted, this SLI applies to all the Service's methods. For service types that don't support breaking down by method, setting this field will result in an error.

  • location - (Optional) An optional set of locations to which this SLI is relevant. Telemetry from other locations will not be used to calculate performance for this SLI. If omitted, this SLI applies to all locations in which the Service has activity. For service types that don't support breaking down by location, setting this field will result in an error.

  • version - (Optional) The set of API versions to which this SLI is relevant. Telemetry from other API versions will not be used to calculate performance for this SLI. If omitted, this SLI applies to all API versions. For service types that don't support breaking down by version, setting this field will result in an error.

  • latency - (Optional) Parameters for a latency threshold SLI. Structure is documented below.

  • availability - (Optional) Availability based SLI, dervied from count of requests made to this service that return successfully. Structure is documented below.

The latency block supports:

  • threshold - (Required) A duration string, e.g. 10s. Good service is defined to be the count of requests made to this service that return in no more than threshold.

The availability block supports:

  • enabled - (Optional) Whether an availability SLI is enabled or not. Must be set to true. Defaults to true.

The requestBasedSli block supports:

  • goodTotalRatio - (Optional) A means to compute a ratio of goodService to totalService. Defines computing this ratio with two TimeSeries monitoring filters Must specify exactly two of good, bad, and total service filters. The relationship good_service + bad_service = total_service will be assumed. Exactly one of distributionCut or goodTotalRatio can be set. Structure is documented below.

  • distributionCut - (Optional) Used when good_service is defined by a count of values aggregated in a Distribution that fall into a good range. The total_service is the total count of all values aggregated in the Distribution. Defines a distribution TimeSeries filter and thresholds used for measuring good service and total service. Exactly one of distributionCut or goodTotalRatio can be set. Structure is documented below.

The goodTotalRatio block supports:

  • goodServiceFilter - (Optional) A TimeSeries monitoring filter quantifying good service provided. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. Exactly two of goodServiceFilter,badServiceFilter,totalServiceFilter must be set (good + bad = total is assumed).

  • badServiceFilter - (Optional) A TimeSeries monitoring filter quantifying bad service provided, either demanded service that was not provided or demanded service that was of inadequate quality. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. Exactly two of goodServiceFilter,badServiceFilter,totalServiceFilter must be set (good + bad = total is assumed).

  • totalServiceFilter - (Optional) A TimeSeries monitoring filter quantifying total demanded service. Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE. Exactly two of goodServiceFilter,badServiceFilter,totalServiceFilter must be set (good + bad = total is assumed).

The distributionCut block supports:

  • distributionFilter - (Required) A TimeSeries monitoring filter aggregating values to quantify the good service provided. Must have ValueType = DISTRIBUTION and MetricKind = DELTA or MetricKind = CUMULATIVE.

  • range - (Required) Range of numerical values. The computed good_service will be the count of values x in the Distribution such that range.min <= x <= range.max. inclusive of min and max. Open ranges can be defined by setting just one of min or max. Structure is documented below.

The range block supports:

  • min - (Optional) Min value for the range (inclusive). If not given, will be set to "-infinity", defining an open range "< range.max"

  • max - (Optional) max value for the range (inclusive). If not given, will be set to "infinity", defining an open range ">= range.min"

The windowsBasedSli block supports:

  • windowPeriod - (Optional) Duration over which window quality is evaluated, given as a duration string "{X}s" representing X seconds. Must be an integer fraction of a day and at least 60s.

  • goodBadMetricFilter - (Optional) A TimeSeries monitoring filter with ValueType = BOOL. The window is good if any true values appear in the window. One of goodBadMetricFilter, goodTotalRatioThreshold, metricMeanInRange, metricSumInRange must be set for windowsBasedSli.

  • goodTotalRatioThreshold - (Optional) Criterion that describes a window as good if its performance is high enough. One of goodBadMetricFilter, goodTotalRatioThreshold, metricMeanInRange, metricSumInRange must be set for windowsBasedSli. Structure is documented below.

  • metricMeanInRange - (Optional) Criterion that describes a window as good if the metric's value is in a good range, averaged across returned streams. One of goodBadMetricFilter, goodTotalRatioThreshold, metricMeanInRange, metricSumInRange must be set for windowsBasedSli. Average value X of timeSeries should satisfy rangeMin <=X <=RangeMax for a good window. Structure is documented below.

  • metricSumInRange - (Optional) Criterion that describes a window as good if the metric's value is in a good range, summed across returned streams. Summed value x of timeSeries should satisfy rangeMin <=X <=RangeMax for a good window. One of goodBadMetricFilter, goodTotalRatioThreshold, metricMeanInRange, metricSumInRange must be set for windowsBasedSli. Structure is documented below.

The goodTotalRatioThreshold block supports:

  • threshold - (Optional) If window performance >= threshold, the window is counted as good.

  • performance - (Optional) Request-based SLI to evaluate to judge window quality. Structure is documented below.

  • basicSliPerformance - (Optional) Basic SLI to evaluate to judge window quality. Structure is documented below.

The performance block supports:

  • goodTotalRatio - (Optional) A means to compute a ratio of goodService to totalService. Defines computing this ratio with two TimeSeries monitoring filters Must specify exactly two of good, bad, and total service filters. The relationship good_service + bad_service = total_service will be assumed. Structure is documented below.

  • distributionCut - (Optional) Used when good_service is defined by a count of values aggregated in a Distribution that fall into a good range. The total_service is the total count of all values aggregated in the Distribution. Defines a distribution TimeSeries filter and thresholds used for measuring good service and total service. Structure is documented below.

The goodTotalRatio block supports:

  • goodServiceFilter - (Optional) A TimeSeries monitoring filter quantifying good service provided. Exactly two of good, bad, or total service filter must be defined (where good + bad = total is assumed) Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.

  • badServiceFilter - (Optional) A TimeSeries monitoring filter quantifying bad service provided, either demanded service that was not provided or demanded service that was of inadequate quality. Exactly two of good, bad, or total service filter must be defined (where good + bad = total is assumed) Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.

  • totalServiceFilter - (Optional) A TimeSeries monitoring filter quantifying total demanded service. Exactly two of good, bad, or total service filter must be defined (where good + bad = total is assumed) Must have ValueType = DOUBLE or ValueType = INT64 and must have MetricKind = DELTA or MetricKind = CUMULATIVE.

The distributionCut block supports:

  • distributionFilter - (Required) A TimeSeries monitoring filter aggregating values to quantify the good service provided. Must have ValueType = DISTRIBUTION and MetricKind = DELTA or MetricKind = CUMULATIVE.

  • range - (Required) Range of numerical values. The computed good_service will be the count of values x in the Distribution such that range.min <= x <= range.max. inclusive of min and max. Open ranges can be defined by setting just one of min or max. Structure is documented below.

The range block supports:

  • min - (Optional) Min value for the range (inclusive). If not given, will be set to "-infinity", defining an open range "< range.max"

  • max - (Optional) max value for the range (inclusive). If not given, will be set to "infinity", defining an open range ">= range.min"

The basicSliPerformance block supports:

  • method - (Optional) An optional set of RPCs to which this SLI is relevant. Telemetry from other methods will not be used to calculate performance for this SLI. If omitted, this SLI applies to all the Service's methods. For service types that don't support breaking down by method, setting this field will result in an error.

  • location - (Optional) An optional set of locations to which this SLI is relevant. Telemetry from other locations will not be used to calculate performance for this SLI. If omitted, this SLI applies to all locations in which the Service has activity. For service types that don't support breaking down by location, setting this field will result in an error.

  • version - (Optional) The set of API versions to which this SLI is relevant. Telemetry from other API versions will not be used to calculate performance for this SLI. If omitted, this SLI applies to all API versions. For service types that don't support breaking down by version, setting this field will result in an error.

  • latency - (Optional) Parameters for a latency threshold SLI. Structure is documented below.

  • availability - (Optional) Availability based SLI, dervied from count of requests made to this service that return successfully. Structure is documented below.

The latency block supports:

  • threshold - (Required) A duration string, e.g. 10s. Good service is defined to be the count of requests made to this service that return in no more than threshold.

The availability block supports:

  • enabled - (Optional) Whether an availability SLI is enabled or not. Must be set to trueDefaultsTotrue`.

The metricMeanInRange block supports:

  • timeSeries - (Required) A monitoring filter specifying the TimeSeries to use for evaluating window The provided TimeSeries must have ValueType = INT64 or ValueType = DOUBLE and MetricKind = GAUGE. Mean value x should satisfy rangeMin <=X <=RangeMax under good service.

  • range - (Required) Range of numerical values. The computed good_service will be the count of values x in the Distribution such that range.min <= x <= range.max. inclusive of min and max. Open ranges can be defined by setting just one of min or max. Mean value x of timeSeries values should satisfy rangeMin <=X <=RangeMax for a good service. Structure is documented below.

The range block supports:

  • min - (Optional) Min value for the range (inclusive). If not given, will be set to "-infinity", defining an open range "< range.max"

  • max - (Optional) max value for the range (inclusive). If not given, will be set to "infinity", defining an open range ">= range.min"

The metricSumInRange block supports:

  • timeSeries - (Required) A monitoring filter specifying the TimeSeries to use for evaluating window quality. The provided TimeSeries must have ValueType = INT64 or ValueType = DOUBLE and MetricKind = GAUGE. Summed value x should satisfy rangeMin <=X <=RangeMax for a good window.

  • range - (Required) Range of numerical values. The computed good_service will be the count of values x in the Distribution such that range.min <= x <= range.max. inclusive of min and max. Open ranges can be defined by setting just one of min or max. Summed value x should satisfy rangeMin <=X <=RangeMax for a good window. Structure is documented below.

The range block supports:

  • min - (Optional) Min value for the range (inclusive). If not given, will be set to "-infinity", defining an open range "< range.max"

  • max - (Optional) max value for the range (inclusive). If not given, will be set to "infinity", defining an open range ">= range.min"

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format {{name}}

  • name - The full resource name for this service. The syntax is: projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

Slo can be imported using any of these accepted formats:

$ terraform import google_monitoring_slo.default {{name}}

User Project Overrides

This resource supports User Project Overrides.