DEV Community

Cover image for Site Reliability Guardian tutorial: validate every release against your SLOs (Dynatrace SaaS)
Span Observer
Span Observer

Posted on Originally published at span.observer

Site Reliability Guardian tutorial: validate every release against your SLOs (Dynatrace SaaS)

A release passes CI, integration tests and code review. Ten minutes after deployment, p95 latency doubles and the error rate climbs. Nobody notices before users do. This Site Reliability Guardian tutorial tackles that problem: the Dynatrace SaaS app evaluates a release automatically against objectives measured in production and returns a clear verdict.

The goal: create a guardian with three DQL objectives, trigger it from a Workflow after each deployment, then use the verdict to continue or roll back. You shorten the time between introducing a regression and detecting it, which cuts MTTR and error budget consumption.

Scope: Site Reliability Guardian relies on Grail, DQL and AutomationEngine. It is available on Dynatrace SaaS (latest platform) only. It does not exist on Dynatrace Managed: the alternative is a scripted check through the API, covered in the article on the error budget as a release gate.

The problem: green tests, red production

Tests validate expected behaviour, not real behaviour under load. An N+1 query, an undersized connection pool or a badly tuned timeout only show up in production. Without an automatic post-deployment check, detection depends on a threshold alert or a customer ticket. A guardian closes that loop in minutes.

Prerequisites

  • A Dynatrace SaaS environment with Grail and the Site Reliability Guardian app installed (from the Hub if it is missing).
  • Services monitored by OneAgent or OpenTelemetry, with request and failure metrics available in DQL.
  • Permissions to create guardians and Workflows. Exact permission names change over time: see the Site Reliability Guardian documentation.
  • A CI/CD pipeline able to send a deployment event to Dynatrace.

Step 1: pick objectives that reflect the user

A guardian objective is a DQL query returning a single value, compared with a warning threshold and a failure threshold. Pick three signals, not fifteen:

  • Error rate of the deployed service;
  • p95 latency of requests;
  • Status of an existing SLO, if you have one.

To choose the right indicators, use the method for choosing SLIs in DQL.

Step 2: write the DQL objective queries

Error rate of the checkout service, as a percentage:

timeseries total = sum(dt.service.request.count),
           failed = sum(dt.service.request.failure_count),
           filter: { dt.entity.service == "SERVICE-1234567890ABCDEF" }
| fieldsAdd error_rate = 100 * arraySum(failed) / arraySum(total)
| fields error_rate
Enter fullscreen mode Exit fullscreen mode

p95 latency, in milliseconds:

timeseries p95 = percentile(dt.service.request.response_time, 95),
           filter: { dt.entity.service == "SERVICE-1234567890ABCDEF" }
| fieldsAdd p95_ms = arrayAvg(p95) / 1000
| fields p95_ms
Enter fullscreen mode Exit fullscreen mode

Key lines: the query must end with a single record and a single numeric field, otherwise the objective cannot be evaluated. Response time is stored in microseconds, hence the division by 1000. The timeframe is not written in the query: the validation supplies it. Replace the service ID with yours.

Step 3: create the guardian

  1. Open the Site Reliability Guardian app and create a new guardian, for example checkout-release.
  2. Add one objective per query. For error rate: comparison « lower than or equal », warning at 1, failure at 2.
  3. For p95 latency: warning at 400, failure at 600.
  4. For an existing SLO, the app usually offers a dedicated objective type: check the option available in your version.
  5. Save. The guardian evaluates nothing until a validation is triggered.

If you manage SLOs as code, keep the same approach for guardians: see Dynatrace SLOs with Terraform. Check the Dynatrace provider’s Terraform registry page to see whether a guardian resource exists in your version.

Step 4: send the deployment event from CI

CI tells Dynatrace that the deployment has finished. With a platform token or an OAuth client allowed to ingest events, a call like the one below works. Confirm the exact endpoint and schema in your environment’s OpenPipeline ingest documentation:

curl -sS -X POST "https://${DT_ENV}.live.dynatrace.com/platform/ingest/v1/events.sdlc" \
  -H "Authorization: Bearer ${DT_PLATFORM_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "event.kind": "SDLC_EVENT",
    "event.category": "task",
    "event.type": "deployment",
    "event.status": "finished",
    "event.provider": "gitlab-ci",
    "service.name": "checkout",
    "release.version": "2.14.0"
  }'
Enter fullscreen mode Exit fullscreen mode

Step 5: trigger validation from a Workflow

  1. Create a Workflow with an event trigger filtering the event above, for example event.type == "deployment" and event.status == "finished" and service.name == "checkout".
  2. Add a wait task first, or schedule the run, so traffic has time to produce data (15 minutes is a good start).
  3. Add the Site Reliability Guardian validation action, select checkout-release and a relative timeframe, for example the last 15 minutes.
  4. Add a conditional task on the result: a Slack or Teams notification on failure, a call to your deployment tool’s API for a rollback.

Workflows are covered in module 7 of the SaaS course.

How to check it works

Send the deployment event by hand with the curl command above. Then:

  • in the Workflows app, the run should appear with every task successful;
  • in the Site Reliability Guardian app, the guardian shows a validation with an overall status (pass, warning or fail) and per-objective details;
  • validation results are also stored as events in Grail. A query like this one finds them; events table, validation type:
fetch events, from: now()-24h
| filter event.kind == "SDLC_EVENT"
| filter event.provider == "dynatrace.site.reliability.guardian"
| filter event.type == "validation"
| fields timestamp, validation.result, dt.srg.name, event.version
| sort timestamp desc
| limit 20
Enter fullscreen mode Exit fullscreen mode

To test failure, temporarily lower the latency threshold below the real value and rerun: the Workflow should take the failure branch.

Site Reliability Guardian tutorial: best practices

  • Few, well-chosen objectives: three user-facing objectives beat fifteen technical metrics that raise ignored warnings.
  • Thresholds from history: start from the p95 observed on the previous version, with a margin, rather than an arbitrary number.
  • Timeframe matched to traffic: a low-traffic service needs a longer window for a meaningful result.
  • Actionable verdict: a failure must trigger a specific action (pause the canary, roll back), or the guardian becomes yet another chart.
  • Blameless review: each failure is data about the delivery process, not an individual fault.

Frequently asked questions

Does Site Reliability Guardian work on Dynatrace Managed?

No. It depends on Grail, DQL and AutomationEngine, which belong to the SaaS platform. On Managed, query SLOs through API v2 from CI and decide in the pipeline.

Can you compare the new version with the previous one?

Yes, by setting thresholds from the previous version, or by using the comparison options offered by the app if your version includes them. Check the official documentation before relying on them.

Does the guardian replace burn rate alerts?

No. The guardian checks one moment, the release. Burn rate alerts watch the budget continuously. They complement each other.

Conclusion

A guardian turns your SLOs into an automatic delivery check. Three DQL queries, a deployment event and a Workflow are enough to catch a regression in fifteen minutes instead of hours. Start with one critical service, watch the verdicts for two weeks, then wire in the automatic rollback.

span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of its owner.


Originally published on span.observer. French version: https://span.observer/fr/site-reliability-guardian-release-slo/.

Top comments (0)