Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in documentation for Service Level Agreements #16663

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@
"v3/automate/events/events",
"v3/automate/events/automations-triggers",
"v3/automate/events/custom-triggers",
"v3/automate/events/webhook-triggers"
"v3/automate/events/webhook-triggers",
"v3/automate/events/slas"
],
"version": "v3"
},
Expand Down
40 changes: 0 additions & 40 deletions docs/v3/automate/events/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,46 +74,6 @@ from other systems and translate them into events within your workspace.
Webhooks can emit [pre-defined static events](/v3/automate/events/webhook-triggers/#static-webhook-events),
dynamic events that [use portions of the incoming HTTP request](/v3/automate/events/webhook-triggers/#dynamic-webhook-events), or events derived from [CloudEvents](/v3/automate/events/webhook-triggers/#accepting-cloudevents).

## Resources

Every event has a primary resource, which describes the object that emitted an event.
Resources are used as quasi-stable identifiers for sources of events, and are constructed as dot-delimited strings.
For example:

```
prefect-cloud.automation.5b9c5c3d-6ca0-48d0-8331-79f4b65385b3.action.0
acme.user.kiki.elt_script_1
prefect.flow-run.e3755d32-cec5-42ca-9bcd-af236e308ba6
```

Resources can optionally have additional arbitrary labels which can be used in event aggregation queries.
For example:

```json
"resource": {
"prefect.resource.id": "prefect-cloud.automation.5b9c5c3d-6ca0-48d0-8331-79f4b65385b3",
"prefect-cloud.action.type": "call-webhook"
}
```

Events can optionally contain related resources, used to associate the event with other resources.
For example, a primary resource can act on or with another resource.
Here is an example of a related resource:

```json
"resource": {
"prefect.resource.id": "prefect-cloud.automation.5b9c5c3d-6ca0-48d0-8331-79f4b65385b3.action.0",
"prefect-cloud.action.type": "call-webhook"
},
"related": [
{
"prefect.resource.id": "prefect-cloud.automation.5b9c5c3d-6ca0-48d0-8331-79f4b65385b3",
"prefect.resource.role": "automation",
"prefect-cloud.name": "webhook_body_demo",
"prefect-cloud.posture": "Reactive"
}
]
```

## Events in the UI

Expand Down
74 changes: 74 additions & 0 deletions docs/v3/automate/events/slas.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Measure reliability with Service Level Agreements
description: Service Level Agreements (SLAs) are a way to define the performance expectations for your flows and to enable automated alerts when those expectations are not met.
---
<Warning> <b>Experimental:</b> This feature is experimental and may change in the future.</Warning>

## Prerequisites
- Prefect Client Version 3.1.12 or later
- Prefect Cloud account (SLAs are only available in Prefect Cloud)

## Service Level Agreements

<span class="badge cloud"></span> Service Level Agreements (SLAs) help you set and monitor performance standards for your data stack. By establishing specific thresholds for flow runs on your Deployments, you can automatically detect when your system isn't meeting expectations.
When you set up an SLA, you define specific performance criteria - such as a maximum runtime of 10 minutes for a flow. If a flow run exceeds this threshold, the system generates an alert event. You can then use these events to trigger automated responses, whether that's sending notifications to your team or initiating other corrective actions through automations.

## Defining SLAs

To define an SLA you can add them to the Deployment either through the `prefect.yaml` file, through using a `.deploy` method, or the CLI:
<AccordionGroup>

<Accordion title="Defining SLAs in your prefect.yaml file">
```yaml prefect.yaml SLA
deployments:
my-deployment:
sla:
- name: "my-sla"
duration: 10
severity: "high"
```
</Accordion>

<Accordion title="Defining SLAs using a .deploy method">
```python .deploy SLA
flow.from_source(
source=source,
entrypoint="my_file.py:my_flow",
).deploy(
name="private-bitbucket-deploy",
work_pool_name="my_pool",
sla=[
{
"name": "my-sla",
"duration": 10,
"severity": "high"
}
]
)
```
</Accordion>

<Accordion title="Defining SLAs with the Prefect CLI">
```bash CLI SLA
prefect deploy --sla '{"name": "my-sla", "duration": 10, "severity": "high"}'
```
</Accordion>
</AccordionGroup>
## Monitoring SLAs

You can monitor SLAs in the Prefect Cloud UI. On the runs page you can see the SLA status in the top level metrics:

![SLA status](/v3/img/ui/sla-overview.png)


## Setting up an automation

To set up an automation to notify a team or to take other actions when an SLA is triggered, you can use the [automations](/v3/automate/events/automations-triggers/) feature. To create the automation first you'll need to create a trigger.

1. Choose trigger type 'Custom'.
2. Choose any event matching: `prefect.sla.sla-violation`
3. For "From the Following Resources" choose: `prefect.flow-run.*`

![Create an automation](/v3/img/ui/sla-trigger-automation.png)

After creating the trigger, you can create an automation to notify a team or to take other actions when an SLA is triggered using the [automations](/v3/automate/events/automations-triggers/) feature.
1 change: 1 addition & 0 deletions docs/v3/automate/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ This **Automate** section explains how create workflows that run automatically a
- [Trigger actions on events](/v3/automate/events/automations-triggers/) shows how to use events to trigger actions.
- [Define custom event triggers](/v3/automate/events/custom-triggers/) discusses advanced trigger options.
- [Receive events with webhooks](/v3/automate/events/webhook-triggers/) explains how to use webhooks to receive events from external systems with Prefect Cloud.
- [Measure reliability with Service Level Agreements](/v3/automate/events/slas/) explains how to use SLAs to measure the reliability of your data stack.
Binary file added docs/v3/img/ui/sla-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/v3/img/ui/sla-trigger-automation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading