Skip to content

SLI (v1)

SLI defines a derived reliability indicator and the queries used to calculate it for an SLO.

Examples

apiVersion: openslo/v1
kind: SLI
metadata:
  name: api-success-rate
  displayName: API Success Rate
spec:
  description: Ratio of successful API requests to total requests
  ratioMetric:
    good:
      metricSource:
        type: Prometheus
        spec:
          query: sum(rate(http_requests_total{status=~"2.."}[5m]))
    total:
      metricSource:
        type: Prometheus
        spec:
          query: sum(rate(http_requests_total[5m]))
apiVersion: openslo/v1
kind: SLI
metadata:
  name: api-latency
  displayName: API Latency
spec:
  description: 95th percentile API response time
  thresholdMetric:
    metricSource:
      type: Prometheus
      spec:
        query: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))
apiVersion: openslo/v1
kind: SLO
metadata:
  name: api-availability
  displayName: API Availability
spec:
  service: api-service
  indicator:
    metadata:
      name: api-success-rate
      displayName: API Success Rate
    spec:
      ratioMetric:
        good:
          metricSource:
            type: Prometheus
            spec:
              query: sum(rate(http_requests_total{status=~"2.."}[5m]))
        total:
          metricSource:
            type: Prometheus
            spec:
              query: sum(rate(http_requests_total[5m]))
  timeWindow:
    - duration: 30d
      isRolling: true
  budgetingMethod: Occurrences
  objectives:
    - displayName: 99.9% availability
      target: 0.999

Properties

apiVersion

string required

Version represents a version of the OpenSLO specification.

Allowed values: openslo/v1

Validation rules

Rule
property is required
must be equal to openslo/v1

kind

string required

Kind represents all the object kinds defined by OpenSLO specification. Keep in mind not all specification versions support every Kind.

Allowed values: SLI

Validation rules

Rule
property is required
must be equal to SLI

metadata

struct required reference

See the metadata definition in the overview.

Validation rules

Rule
property is required

spec

struct

SLISpec defines the query or queries used to calculate an SLI.

Validation rules

Rule
exactly one of thresholdMetric and ratioMetric must be set

spec.description

string

Description summarizes the SLI.

Validation rules

Rule
property is optional
length must be less than or equal to 1050

spec.thresholdMetric

struct

ThresholdMetric defines a query that returns raw values. SLOObjective.Operator compares each value with SLOObjective.Value.

SLIMetricSpec defines one query used to read metric data for an SLI.

Validation rules

Rule
property is optional

spec.thresholdMetric.metricSource

struct required

SLIMetricSource identifies a metrics backend and supplies the configuration needed to retrieve a metric.

Validation rules

Rule
property is required

spec.thresholdMetric.metricSource.metricSourceRef

string

MetricSourceRef names an existing DataSource.

Validation rules

Rule Details Examples
property is optional
length must be between 1 and 63
string must match regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ an RFC-1123 compliant label name must consist of lower case alphanumeric characters or -, and must start and end with an alphanumeric character my-name
123-abc

spec.thresholdMetric.metricSource.type

string

Type identifies the implementation-defined metric-source type. When SLIMetricSource.MetricSourceRef is set, OpenSLO infers Type from the referenced DataSource.

spec.thresholdMetric.metricSource.spec

map[string]interface required

Spec contains source-specific query or metric-retrieval configuration.

Validation rules

Rule
property is required
length must be greater than or equal to 1

spec.thresholdMetric.metricSource.spec.*~

string

spec.thresholdMetric.metricSource.spec.*

interface

spec.ratioMetric

struct

SLIRatioMetric defines an indicator from good divided by total or (total minus bad) divided by total. It can instead use a precomputed success or failure ratio identified by SLIRatioMetric.RawType. For example, 99 good events out of 100 produce a ratio of 0.99. One bad event out of 100 produces the same ratio.

Validation rules

Rule Applies when
property is optional
exactly one of total and raw must be set
properties are mutually exclusive: bad, good, raw
one of [bad, good] properties must be set, none was provided total is set

spec.ratioMetric.counter

bool

Counter reports whether the queried good, bad, and total metrics are monotonically increasing. It has no effect when Raw is used.

spec.ratioMetric.good

struct

Good supplies the numerator for a good-over-total ratio.

SLIMetricSpec defines one query used to read metric data for an SLI.

Validation rules

Rule Applies when
property is optional total is set
and
good is set

spec.ratioMetric.good.metricSource

struct conditionally required

SLIMetricSource identifies a metrics backend and supplies the configuration needed to retrieve a metric.

Validation rules

Rule Applies when
property is required total is set
and
good is set

spec.ratioMetric.good.metricSource.metricSourceRef

string

MetricSourceRef names an existing DataSource.

Validation rules

Rule Applies when Details Examples
property is optional total is set
and
good is set
length must be between 1 and 63 total is set
and
good is set
string must match regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ total is set
and
good is set
an RFC-1123 compliant label name must consist of lower case alphanumeric characters or -, and must start and end with an alphanumeric character my-name
123-abc

spec.ratioMetric.good.metricSource.type

string

Type identifies the implementation-defined metric-source type. When SLIMetricSource.MetricSourceRef is set, OpenSLO infers Type from the referenced DataSource.

spec.ratioMetric.good.metricSource.spec

map[string]interface conditionally required

Spec contains source-specific query or metric-retrieval configuration.

Validation rules

Rule Applies when
property is required total is set
and
good is set
length must be greater than or equal to 1 total is set
and
good is set

spec.ratioMetric.good.metricSource.spec.*~

string

spec.ratioMetric.good.metricSource.spec.*

interface

spec.ratioMetric.bad

struct

Bad supplies the number subtracted from Total for a failure-based ratio.

SLIMetricSpec defines one query used to read metric data for an SLI.

Validation rules

Rule Applies when
property is optional total is set
and
bad is set

spec.ratioMetric.bad.metricSource

struct conditionally required

SLIMetricSource identifies a metrics backend and supplies the configuration needed to retrieve a metric.

Validation rules

Rule Applies when
property is required total is set
and
bad is set

spec.ratioMetric.bad.metricSource.metricSourceRef

string

MetricSourceRef names an existing DataSource.

Validation rules

Rule Applies when Details Examples
property is optional total is set
and
bad is set
length must be between 1 and 63 total is set
and
bad is set
string must match regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ total is set
and
bad is set
an RFC-1123 compliant label name must consist of lower case alphanumeric characters or -, and must start and end with an alphanumeric character my-name
123-abc

spec.ratioMetric.bad.metricSource.type

string

Type identifies the implementation-defined metric-source type. When SLIMetricSource.MetricSourceRef is set, OpenSLO infers Type from the referenced DataSource.

spec.ratioMetric.bad.metricSource.spec

map[string]interface conditionally required

Spec contains source-specific query or metric-retrieval configuration.

Validation rules

Rule Applies when
property is required total is set
and
bad is set
length must be greater than or equal to 1 total is set
and
bad is set

spec.ratioMetric.bad.metricSource.spec.*~

string

spec.ratioMetric.bad.metricSource.spec.*

interface

spec.ratioMetric.total

struct

Total supplies the denominator for a Good- or Bad-based ratio.

SLIMetricSpec defines one query used to read metric data for an SLI.

Validation rules

Rule Applies when
property is optional total is set

spec.ratioMetric.total.metricSource

struct conditionally required

SLIMetricSource identifies a metrics backend and supplies the configuration needed to retrieve a metric.

Validation rules

Rule Applies when
property is required total is set

spec.ratioMetric.total.metricSource.metricSourceRef

string

MetricSourceRef names an existing DataSource.

Validation rules

Rule Applies when Details Examples
property is optional total is set
length must be between 1 and 63 total is set
string must match regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ total is set an RFC-1123 compliant label name must consist of lower case alphanumeric characters or -, and must start and end with an alphanumeric character my-name
123-abc

spec.ratioMetric.total.metricSource.type

string

Type identifies the implementation-defined metric-source type. When SLIMetricSource.MetricSourceRef is set, OpenSLO infers Type from the referenced DataSource.

spec.ratioMetric.total.metricSource.spec

map[string]interface conditionally required

Spec contains source-specific query or metric-retrieval configuration.

Validation rules

Rule Applies when
property is required total is set
length must be greater than or equal to 1 total is set

spec.ratioMetric.total.metricSource.spec.*~

string

spec.ratioMetric.total.metricSource.spec.*

interface

spec.ratioMetric.rawType

string conditionally required

RawType selects whether Raw is interpreted as a success or failure ratio when Raw is used.

SLIRawMetricType identifies how a precomputed raw ratio is interpreted.

Possible values: success, failure

The applicable values depend on the conditions in the validation rules below.

Validation rules

Rule Applies when
property is required raw is set
must be one of: success, failure raw is set

spec.ratioMetric.raw

struct

Raw defines a query for a precomputed success or failure ratio.

SLIMetricSpec defines one query used to read metric data for an SLI.

Validation rules

Rule Applies when
property is optional raw is set

spec.ratioMetric.raw.metricSource

struct conditionally required

SLIMetricSource identifies a metrics backend and supplies the configuration needed to retrieve a metric.

Validation rules

Rule Applies when
property is required raw is set

spec.ratioMetric.raw.metricSource.metricSourceRef

string

MetricSourceRef names an existing DataSource.

Validation rules

Rule Applies when Details Examples
property is optional raw is set
length must be between 1 and 63 raw is set
string must match regular expression: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ raw is set an RFC-1123 compliant label name must consist of lower case alphanumeric characters or -, and must start and end with an alphanumeric character my-name
123-abc

spec.ratioMetric.raw.metricSource.type

string

Type identifies the implementation-defined metric-source type. When SLIMetricSource.MetricSourceRef is set, OpenSLO infers Type from the referenced DataSource.

spec.ratioMetric.raw.metricSource.spec

map[string]interface conditionally required

Spec contains source-specific query or metric-retrieval configuration.

Validation rules

Rule Applies when
property is required raw is set
length must be greater than or equal to 1 raw is set

spec.ratioMetric.raw.metricSource.spec.*~

string

spec.ratioMetric.raw.metricSource.spec.*

interface