> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeycomb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Service Level Indicator (SLI) Formulas

> Copy and adapt example SLI formulas to define good and bad request criteria for common reliability scenarios in your Honeycomb datasets.

<Badge className="hny-badge-enterprise">Ent</Badge><Badge className="hny-badge-pro">Pro</Badge>

<Note>
  This feature is available as part of the [Honeycomb Enterprise and Pro plans](https://www.honeycomb.io/pricing/).
</Note>

These examples show how to identify different types of criteria and qualifiers when creating SLIs.

Each example includes how to formulate the SLI when using the [**Build Query** mode](/notify/slos/create/sli/#define-your-sli-with-a-query) or the [**Write Formula** mode](/notify/slos/create/sli/#define-your-sli-with-a-formula).

## No Qualifier

For all events, return `true` if `duration_ms < 1000`.

### Build Query

| Total (Valid) Events | Successful Events    |
| -------------------- | -------------------- |
|                      | duration\_ms \< 1000 |

### Write Formula as a Calculated Field

```honeycomb theme={}
LT($duration_ms, 1000)
```

## Qualifier is trace roots

A trace root does not have a parent.
This SLI returns `true` for trace roots whose response duration is under 100, `false` for trace roots whose duration is over 100, and `null` for non-roots.

### Build Query

| Total (Valid) Events            | Successful Events   |
| ------------------------------- | ------------------- |
| trace.parent\_id does-not-exist | duration\_ms \< 100 |

### Write Formula as a Calculated Field

```honeycomb theme={}
IF(
  NOT(EXISTS($trace.parent_id)),
  LT($duration_ms, 100)
)
```

## Criterion is Based on Both Duration and Error

Our qualifier here is whether `request.path` is `/home`.
If it is, then this SLI only returns `true` if **both** `duration_ms` is under 100, **and** there is no error message.

### Build Query

| Total (Valid) Events | Successful Events                                   |
| -------------------- | --------------------------------------------------- |
| request.path = /home | duration\_ms \< 100 <br /> app.error does-not-exist |

### Write Formula as a Calculated Field

```honeycomb theme={}
IF(
  EQUALS($request.path, "/home"),
  AND(
    LT($duration_ms, 100),
    NOT(EXISTS($app.error)),
  )
)
```

## Complex Criterion, Complex Qualifier

The qualifier here is events that hit the `/main` endpoint, using the method `POST`, and are not marked as error code `401`.

The criterion is that events must have a status code of `200`.
In addition, if they are part of a batch, then data processing must have taken less than 5 ms per item.

### Build Query

This example is not supported in the Build Query mode because the `DIV()` and `IF()` operators are only supported within a calculated field.

### Write Formula as a Calculated Field

```honeycomb theme={}
IF(
  AND(
    EQUALS($request.path, "main"),
    EQUALS($request.method, "POST"),
    NOT(EQUALS($response.status_code, 401))
  ),
  AND(
    EQUALS($response.status_code, 200),
    LT(
      DIV(
        $duration_ms,
        IF($app.batch, $app.batch_total_datapoints, 5)
      ),
      5
    )
  )
)
```
