Sometimes an SLO mandate shows up and it just doesn’t make sense when you apply it to your data. I want to give you some reinforcement to push back and say “we can get higher quality alerts in a more reasonable fashion” when that is the case.
In SLOs are Accountability Incarnate I said some of the teams who push back on SLOs are right, because the math doesn’t work for their service. That post is about org charts so the math got a paragraph per team. This is the long version. I’ve walked through it in something like 30 meetings and figured it was out in the world somewhere. It wasn’t, so here it is.
I work at Honeycomb, so the examples use Honeycomb SLOs and Refinery. The arithmetic is the same anywhere.
The ratio
I want to pick apart 2 different types of SLOs real quick:
Event-based: These are where you look at every request. A good request goes into the numerator and denominator, a bad request goes into just the denominator.
Minute-based: These are where you look at the P95 of requests for a minute and declare it “good” or “bad”. A low-volume service can look healthy on these charts no matter what, because a health check or some synthetic gives every minute at least 1 success whether or not a real user got through.
I think the Good Minute/Total Minutes form of SLOs is misleading so I won’t talk about them anymore, but just wanted to throw that here in case you’re suffering under this paradigm and haven’t noticed there is an alternative.
For the event-based kind, pick a window, usually 30 days, and a target. Whatever is left over between the target and 100% is the budget.
| Requests per day | Requests in 30 days | Budget at 99% | Mike’s Name |
|---|---|---|---|
| 2 | 60 | 0.6 failures | Simply impossible |
| 200 | 6,000 | 60 failures | Infuriatingly flappy |
| 2,000 | 60,000 | 600 failures | Reasonable |
| 10,000,000 | 300,000,000 | 3,000,000 failures | Easy peasy, expensive? |
The bottom row is where SLOs are easy. If you have a thousand per minute, it’s gonna be very easy to steer product decisions based on this feed. Each row turns up in one of the teams below.
Low volume
I put an SLO on my address change endpoint and it never alerts when it should.
Address changes come in at maybe 200 a day. That’s the second row, a budget of 60 failures for the month at 99%. Tighten it to 99.9% and it’s six. One bad deploy after lunch eats it.
It also fails the other way. If the endpoint is completely down from 1am to 6am and nobody tried to change their address, there were zero requests and zero failures. The SLO sat at 100% through a five-hour outage. The first failure it records is a customer finding the outage for you.
So the burn alert is either screaming or never goes off. The team saying “this doesn’t work for us” is correct.
What works better here:
- A simple trigger of “any errors on this endpoint”. This is good for low-volume or incredibly high-value endpoints. It’s up to the developers to make sure “errors” are “errors” in the codebase.
- A longer window. 90 days triples the budget (180 failures at 99%, 18 at 99.9%), which is at least enough to have a trend. It’s still not usable for alerting.
- If the problem is the outage nobody was around for, send your own requests and alert on those failures. I wrote about doing that with the httpcheck receiver. Keep those out of the SLO itself or they turn into a competence ballast that hides the real traffic.
Wide surface area
We have 3000 endpoints and every one of them is business critical.
A variety of volume/speed/purpose endpoints, blended together, undermine an SLO by drawing on the same budget. If your system has 3000 endpoints and some have 2 requests per day and some customers only ever hit a dozen of them and another dozen get a million requests per day, the busy dozen decide the number. The endpoint that moves money can fail every request for a week and the ratio doesn’t move.
So you decompose the Service Level Objective. It’s not Service Level anymore, it’s endpoint-specific or tenant-bound or some other division. If the division shows up in the telemetry data, turning an SLO into 3 or 10 isn’t a big deal.
Turning it into 3000 is a big deal, and most of the pieces land in the top row of the table. Two requests a day is 60 a month, and a 99% target on 60 requests is a budget of 0.6 failures. You can’t fail 60% of one request, so the first failure overspends the month. At 99.9% it overspends by about 17x.
What works better here:
- Split along a line the business already uses. Tenant tier, product area, read vs write. Three to ten SLOs.
- Give the handful of endpoints that move money their own SLO or their own trigger, depending on which row of the table they’re in.
- Leave the long tail on triggers.
High volume
We keep 1% of our traces. The search numbers look great and the purchase numbers are noise.
If a team takes 10 million requests per day and saves all of the traces, and each trace is 2000 spans, that’s 20 billion events a day and 7.3 trillion per year. That’s a lot of processing and storage so you’re going to want to sample.
Most of that traffic is a publicly facing, unauthenticated search endpoint that is used by millions of people. Keep 1% of it and you still have 100,000 searches a day. You’ll have accuracy for that endpoint even if you do nothing else.
Now say 2000 of those requests are purchases where people are actually spending money. Sampled alongside the searches at 1%, you keep 20 a day and each one stands in for 100.
| Searches | Purchases | |
|---|---|---|
| Requests per day | ~10,000,000 | 2,000 |
| Kept at 1% | ~100,000 | 20 |
| 30-day budget at 99.9% | ~300,000 failures | 60 failures |
| What one kept failure counts as | 100 failures | 100 failures |
For searches, 100 failures against a budget of 300,000 is nothing. For purchases, one kept failure counts as 100 against a budget of 60. The SLO goes from untouched to blown on a single event. The other 99 out of 100 failed purchases never get kept, so most days it reads 100% while people are failing to give you money.
You can’t sample those alongside the searches. You can keep all of them.
The sampling rules are part of the SLO
This is part of what makes Refinery work alongside SLOs so well. Refinery is a sampling proxy that sits in the telemetry pipeline. It decides after the whole trace has arrived, so it can keep things based on what happened in the request.
The flat 1% that team is running is the DeterministicSampler, and I basically never use it. I always use the EMADynamicSampler with a goal sample rate. You give it a goal, like 1 in 100, and a FieldList of attributes to build a key from. It keeps a moving average of how many traces it sees for each key. Keys that show up constantly get sampled harder than the goal, rare keys get sampled lighter, and a key it hasn’t seen before gets kept. The average works out to the goal.
With a FieldList of route and status code, the example traffic sorts itself out like this:
| Key | How often it shows up | What the sampler does |
|---|---|---|
/search and 200 |
Nearly all of the 10 million | Samples it the hardest, past 1 in 100 |
/search and 500 |
Rare | Samples it lightly |
/purchase and 200 |
2000 a day | Samples it lightly |
/purchase and 500 |
Very rare | Keeps close to all of them |
Each kept event carries its sample rate, and Honeycomb multiplies by it, so the totals still come out right.
That handles the errors without writing a rule about errors. For the purchases, “sampled lightly” still isn’t “all of them”, and these are people spending money. So they get a rule in front of the dynamic sampler.
| Rule | Sampler |
|---|---|
| Purchases | Keep all of them |
| Everything else | EMADynamicSampler with a goal of 1 in 100, keyed on route and status code |
This can still be an issue if the SLO has a duration target. Say the SLO says a bad request is a success that took more than 2 seconds. A slow 200 has the same route and status code as a fast 200, so it lands in the busiest key and gets the heaviest sampling. When one does get kept, it shows up in the failures weighted with hundreds of additional events.
The fix is to isolate the successes from the failures in terms the sampler can see. There are two ways to do it.
Another rule: Searches over 2 seconds go to their own EMADynamicSampler. Now slow requests are only counted against other slow requests. While they’re rare they get kept at a low rate. During an incident there are thousands of them, the rate climbs toward the goal, and that’s fine because there are plenty.
RulesVersion: 2
Samplers:
production:
RulesBasedSampler:
Rules:
- Name: keep every purchase
SampleRate: 1
Conditions:
- Field: root.http.route
Operator: =
Value: /purchase
Datatype: string
- Name: slow searches get their own sampler
Conditions:
- Field: root.http.route
Operator: =
Value: /search
Datatype: string
- Field: root.duration_ms
Operator: '>='
Value: 2000
Datatype: float
Sampler:
EMADynamicSampler:
GoalSampleRate: 10
FieldList:
- root.http.response.status_code
- Name: everything else
Sampler:
EMADynamicSampler:
GoalSampleRate: 100
FieldList:
- root.http.route
- root.http.response.status_code
Another field: You’ll notice we’re headed for rule proliferation. Refinery can reach the same outcome with fewer samplers by putting the distinction into the FieldList, which isolates variables the same way but at scale. Have the service stamp an attribute like request.slow on the root span and add it to the key. Don’t put duration_ms itself in the FieldList. Every trace ends up with its own key and the sampler keeps everything.
Either way, at SLO evaluation time there isn’t a risk of a “slow” request showing up in the failures weighted with dozens or hundreds of additional events.
The definition of a bad request now lives in two places. The SLO has it as a derived column in Honeycomb, which Refinery never sees. The sampler has it as a rule or an attribute.
Regardless of the sampling tricks selected, it does mean that when SLO definitions change, the Refinery rules need to adapt to avoid undermining them. Same when the telemetry changes underneath both of them, which I wrote about in Avoid Stubbing Your Toe on Telemetry Changes.
Take two measurements
You can also pre-aggregate high-volume services to have a real number alongside the sampled events. A counter of every request and every failure costs almost nothing and doesn’t care what the sampler did. The sampled traces tell you why. They perform different jobs for the business so taking 2 measurements is reasonable.
The other “alternative measurement” for this could be routing specific spans around the sampler. If you keep one span from each request and send the full trace only when the sampler decides to keep it, you can ensure the ratios are correct while reducing the data volume by a factor of the length of each trace. In the example that’s 10 million spans a day in place of 20 billion. The thing to watch is double counting. The kept traces contain that same span with a sample rate on it, so the SLO has to read from the unsampled copies only. That usually means sending them to their own dataset or marking them with an attribute.
Which one are you?
| Your situation | What goes wrong | What to use |
|---|---|---|
| A couple hundred requests a day | The budget is a handful of failures, and an outage with no traffic records nothing | A trigger on any error, a longer window, your own synthetic requests |
| Thousands of endpoints on one budget | The busy endpoints decide the number | Three to ten SLOs along a line the business already uses, triggers for the long tail |
| Sampled traffic with rare, valuable requests in it | 1% of rare is too few to count | A sampling rule that keeps all of them, and a pre-aggregated count alongside |
Check which row of the first table a service is in before somebody puts it on the rollout spreadsheet.