# Stability windowing

A windowing policy of type *stability* discards temporal intervals in which a given metric is not stable, and selects, among the remaining intervals, the ones in which another target metric is maximized or minimized. Stability windowing can be sample-based or time-frame based.

The stability windowing has the following structure:

| Field                   | Type                     | Value restrictions                                                                                                                                                                     | Is required | Default value   | Description                                                                                                                                                                                                                                                                                                           |
| ----------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`                  | string                   | {stability}                                                                                                                                                                            | TRUE        | <p><br><br></p> | The type of windowing.                                                                                                                                                                                                                                                                                                |
| `stability->metric`     | string                   | It should match the name of an existing metric monitored by AKAMAS                                                                                                                     | TRUE        | <p><br><br></p> | The metric whose stability is going to be verified to exclude some temporal intervals over the duration of a trial.                                                                                                                                                                                                   |
| `stability->labels`     | set of key-value pairs   | <p><br><br></p>                                                                                                                                                                        | FALSE       | <p><br><br></p> | A set of key-value pairs that represent filtering conditions for retrieving the value of the `metric`. This conditions can be used to consider the right metric of the right component, you can in fact filter by *componentName* or by other custom properties defined in the components of the system of the study. |
| `stability->resolution` | string                   | <p>Valid values are in the form <code>30s</code> <code>40m</code> <code>2h</code></p><p>where <code>s</code> refers to seconds, <code>m</code> to minutes, <code>h</code> to hours</p> | FALSE       | 0s              | The temporal resolution at which Akamas aggregate data points to determine feasible windows.                                                                                                                                                                                                                          |
| `stability->width`      | <p>integer<br>string</p> | <p><code>stability->width</code> > 1<br>Valid values are in the form <code>30s</code> <code>40m</code> <code>2h</code> as specified in <code>stability->resolution</code></p>          | TRUE        |                 | <p>The width of temporal intervals over the duration trial which are checked for the stability of the <code>metric</code>.<br>Width can be sample-based (integer) or time frame-based (string).</p>                                                                                                                   |
| `stability->maxStdDev`  | double                   | <p><br><br></p>                                                                                                                                                                        | TRUE        | <p><br><br></p> | The stability condition, i.e, the maximum amount of standard deviation among the value of the data point of the metric tolerated for a temporal interval of size `width`, otherwise, the temporal interval will be discarded                                                                                          |

and for the comparison metric section

| Field    | Type                   | Value restrictions                                                 | Is required | Default value   | Description                                                                                                                                                                                                                                                                                                           |
| -------- | ---------------------- | ------------------------------------------------------------------ | ----------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metric` | string                 | It should match the name of an existing metric monitored by Akamas | TRUE        | <p><br><br></p> | The metric whose value is analyzed to include or exclude temporal intervals over the duration of a trial, when another reference metric is stable.                                                                                                                                                                    |
| `labels` | set of key-value pairs | <p><br><br></p>                                                    | FALSE       | <p><br><br></p> | A set of key-value pairs that represent filtering conditions for retrieving the value of the `metric`. This conditions can be used to consider the right metric of the right component, you can in fact filter by *componentName* or by other custom properties defined in the components of the system of the study. |
| `is`     | string                 | {min,max}                                                          | TRUE        | <p><br><br></p> | If the value of the metric should be maximum or minimum to include or exclude temporal intervals over the duration of a trial when another reference metric is stable.                                                                                                                                                |

### Example

The following fragment is an example of stability windowing (time-frame based):

```yaml
type: stability
stability:
  metric: throughput
  labels:
    componentName: DB
  resolution: "30s"
  width: 10
  maxStdDev: .6
  # Comparison metric section
  when:
    metric: response_time
    labels:
      componentName: FE
    is: min
```
