# SLO

Service Level Objectives [(SLOs)](slo) let users set performance thresholds on collected service metrics. If a service performs worse than the set threshold (i.e. if memory utilization is 60 MB but we have set a SLO for 100 MB), then an SLO violation is recorded and displayed in the Service Summary page. The dashboard supports the following SLO types:

* _Aggregate_: SLOs applying to the metrics for all proxies averaged together. For instance, an aggregate SLO for latency of greater than 0.05ms will throw a violation if the average latency across all proxies of a service is more than 0.05ms.
* _Route:_ SLOs specific to each route. For example, setting an SLO for latency greater than 0.05s for the route "/" will trigger a violation if the average latency of requests going to the route "/" is greater than 0.05ms, averaged across all proxies of the service.

To set an SLO, select the down arrow of the SLO type and fill out the SLO information in the boxes provided. Note that there are two types of SLOs for each metric: violations and warnings. Warnings are triggered when a service approaches unsafe levels, although this is user-defined and varies from deployment to deployment.

After the information is filled out, click the check box to enable the SLO and then click the green "Save" icon on the top right. To undo changes, click the circular arrow button to the left of the save button. The SLO should now be visible on the Service Summary page overlaid on the respective metric chart. For example, after setting an SLO of 100 MB for a service's memory utilization, you should see how the SLO compares with the service's actual memory utilization on the Memory Utilization chart. To delete an objective, click the red trash can icon next to the SLO name.

![Service Level Objectives](https://2512473607-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsNFVozLgvw3NDMzxBg%2Fsync%2Fc37bce114f87f7f3541e144fbabc9a41a741c914.png?generation=1605196238367951\&alt=media)

## API

### Route `/objectives`

#### Method: `GET`

Returns a list of all Objectives.

Query parameters:

* `serviceName`
* `serviceVersion`

Examples:

* `GET /objectives`
* `GET /objectives/{id}` to get a specific objective with id `{id}`

#### Response 200 (application/json)

```javascript
[
  {
    "id": 2,
    "days": "sun, mon, tue, wed, thu, fri, sat",
    "metricKey": "cpu",
    "operator": "gte",
    "serviceName": "Example Service",
    "serviceVersion": "1.0",
    "target": "average",
    "threshold": 1024.35,
    "timeStart": 2400,
    "timeEnd": 2400,
    "title": "CPU Utilization should be below 1024 mb",
    "unit": "percent",
    "violationActive": true,
    "warningActive": true,
    "warningThreshold": 234.26
  },
  ...
]
```

#### Method: `POST`

Create a new Objective.

Examples:

* `POST /objectives -H 'Content-Type: application/json' -d "@request_body.json"`

**Request (application/json)**

```javascript
{
"metricKey": "cpu",
"operator": "gte",
"serviceName": "Example Service",
"serviceVersion": "1.0",
"target": "average",
"threshold": 1024.35,
"title": "CPU Utilization should be below 1024 mb",
"unit": "percent",
"violationActive": true,
"warningThreshold": 234.26,
"warningActive": true,
"timeStart": 2400,
"timeEnd": 2400,
"days": "sun, mon, tue, wed, thu, fri, sat"
}
```

**Response 200 (application/json)**

```javascript
{
  "id": 2,
  "days": "sun, mon, tue, wed, thu, fri, sat",
  "metricKey": "cpu",
  "operator": "gte",
  "serviceName": "Example Service",
  "serviceVersion": "1.0",
  "target": "average",
  "threshold": 1024.35,
  "timeStart": 2400,
  "timeEnd": 2400,
  "title": "CPU Utilization should be below 1024 mb",
  "unit": "percent",
  "violationActive": true,
  "warningActive": true,
  "warningThreshold": 234.26
}
```

#### Method: `PATCH`

Patch a specific Objective.

Examples:

* `PATCH /objectives/{id} -H 'Content-Type: application/json' -d "@patch_body.json"`

**Request (application/json)**

```javascript
{
"metricKey": "cpu",
"operator": "gte",
"serviceName": "Example Service",
"serviceVersion": "1.0",
"target": "average",
"threshold": 1024.35,
"title": "CPU Utilization should be below 1024 mb",
"unit": "percent",
"violationActive": true,
"warningThreshold": 234.26,
"warningActive": true,
"timeStart": 2400,
"timeEnd": 2400,
"days": "sun, sat"
}
```

**Response 200 (application/json)**

```javascript
{
  "id": 2,
  "days": "sun, sat",
  "metricKey": "cpu",
  "operator": "gte",
  "serviceName": "Example Service",
  "serviceVersion": "1.0",
  "target": "average",
  "threshold": 1024.35,
  "timeStart": 2400,
  "timeEnd": 2400,
  "title": "CPU Utilization should be below 1024 mb",
  "unit": "percent",
  "violationActive": true,
  "warningActive": true,
  "warningThreshold": 234.26
}
```

#### Method: `DELETE`

Delete a specific Objective.

Examples:

* `DELETE /objectives/{id}`

#### Response 200 (application/json; charset=utf-8)

```javascript
"{id}"%
```

### Route `/businessImpact` (Deprecated)

> Note: This endpoint is **deprecated** and will be removed in the 2.0 release.

#### Method: `GET`

> Note: This endpoint is deprecated and will be removed in the 2.0 release.

Returns a list of all Business Impacts.

**Response 200 (application/json)**

```javascript
[
  {
    "businessImpact": "critical",
    "serviceName": "Grey Matter Catalog",
    "serviceVersion": "1.2",
    "id": 3
  }
]
```

#### Method: `POST`

> Note: This endpoint is deprecated and will be removed in the 2.0 release.

Create a Business Impact.

Examples:

* `POST /businessImpact -H 'Content-Type: application/json' -d "@request_body.json"`

**Request (application/json)**

```javascript
{
  "businessImpact": "critical",
  "serviceName": "Grey Matter Catalog",
  "serviceVersion": "1.2"
}
```

**Response 200 (application/json)**

```javascript
{
  "businessImpact": "critical",
  "serviceName": "Grey Matter Catalog",
  "serviceVersion": "1.2",
  "id": 3
}
```

#### Method: `PUT`, `PATCH`

> Note: This endpoint is deprecated and will be removed in the 2.0 release.

Update an existing business impact with either a PUT or PATCH request.

Examples:

* `PUT /businessImpact -H 'Content-Type: application/json' -d "@put_body.json"`
* `PATCH /businessImpact -H 'Content-Type: application/json' -d "@patch_body.json"`

**Request (application/json)**

```javascript
{
  "businessImpact": "critical",
  "serviceName": "Grey Matter Catalog",
  "serviceVersion": "1.3"
}
```

**Response 200 (application/json)**

```javascript
{
  "businessImpact": "critical",
  "serviceName": "Grey Matter Catalog",
  "serviceVersion": "1.2",
  "id": 3
}
```

#### Method: `DELETE`

> Note: This endpoint is deprecated and will be removed in the 2.0 release.

Delete an existing Business Impact.

Query parameters (required):

* `serviceName`
* `serviceVersion`

Examples:

* `DELETE /businessImpact?serviceName={service-name}&serviceVersion={service-version}`

**Response 200 (application/json)**

```bash
"Deleted Grey Matter Catalog v1.2"%
```
