---
title: "A regression, or the same weekly pattern as last week? | Proofline"
description: "A metric that rose on Monday morning after a weekend deploy fits a regression and the normal weekly peak equally well, because both arrive on Monday."
url: https://proofline.sh/learn/regression-or-weekly-traffic-pattern/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# A regression, or the same weekly pattern as last week?

A metric that rose on Monday morning after a weekend deploy fits a regression and the normal weekly peak equally well, because both arrive on Monday. Compare the value with the same hour on the same weekday one and two weeks earlier, not with the hour or the day before. The weekly peak gives a ratio near 1; a regression gives a ratio above 1 by about its own size.

Capacity overruns The Proofline team November 24, 2026 7 min read

## The symptom and the explanations

The example is illustrative. A fictional `catalog-api` deployed on Saturday at 10:00 UTC, when traffic was light and nothing moved. On Monday at 09:00, the p95 latency was 279 ms, more than twice Sunday's value at the same hour, and the latency alert fired. The author of Saturday's change was asked to revert it.

-   It is a regression. Saturday's change made requests slower, and the weekend's light traffic hid it until Monday's load arrived.
-   It is the weekly pattern. Monday mornings are always the busiest hours of the week, and latency rises with load. Last Monday looked the same.

There is a third explanation worth one query: this Monday is busier than usual, from a campaign or a large customer's import. It predicts more requests than last Monday at the same hour. [Choose the observation where explanations disagree](/learn/which-observation-separates-two-explanations/)

## What each explanation predicts

| Observation | Regression | Weekly pattern | Unusually busy Monday |
| --- | --- | --- | --- |
| p95 at 09:00 against Sunday 09:00 | much higher | much higher | much higher |
| p95 at 09:00 against Friday 09:00, before the deploy | higher | higher if Mondays are busier than Fridays | higher |
| p95 at 09:00 against Monday 09:00 one and two weeks ago | above 1 by the regression's size | about 1 | above 1 |
| Requests per second at 09:00 against the same hour a week ago | about 1 | about 1 | above 1 |

The day-over-day comparison, which is what most dashboards show by default, rises under every explanation. Against Friday the answer depends on how much busier Mondays are, which is the thing in question. The week-over-week ratio separates a regression from the pattern, and the request-rate ratio separates both from a busy week.

## The lab: three weeks of hourly latency

The script builds three weeks of hourly p95 latency from a load curve with a daytime peak, Mondays 15% busier than other weekdays and weekends at 35%. Latency grows with the square of load, plus 5% noise. In the `regression` world every request after Saturday 10:00 is 20% slower; in the `seasonal` world nothing changes. It then compares Monday 09:00 with five baselines. It needs Python 3.9 or later.

```
import math, random, statistics, sys
from datetime import datetime, timedelta, timezone

START = datetime(2026, 11, 2, tzinfo=timezone.utc)     # a Monday; three weeks of hourly p95
DEPLOY = datetime(2026, 11, 21, 10, tzinfo=timezone.utc)  # Saturday
NOW = datetime(2026, 11, 23, 9, tzinfo=timezone.utc)      # Monday 09:00

def load(t):
    day = 0.15 + 0.85 * math.exp(-((t.hour - 10) / 4.0) ** 2)   # daytime peak around 10:00
    week = {0: 1.15, 5: 0.35, 6: 0.35}.get(t.weekday(), 1.0)     # busy Mondays, quiet weekends
    return day * week

def p95(t, world, rng):
    ms = (90 + 120 * load(t) ** 2) * rng.uniform(0.95, 1.05)
    if world == "regression" and t >= DEPLOY:
        ms *= 1.20                                               # every request 20% slower
    return ms

if len(sys.argv) not in (2, 3) or sys.argv[1] not in ("seasonal", "regression"):
    sys.exit("usage: python3 weekly.py seasonal|regression [seed]")
world = sys.argv[1]
rng = random.Random(int(sys.argv[2]) if len(sys.argv) > 2 else 8)
series = {}
t = START
while t <= NOW:
    series[t] = p95(t, world, rng)
    t += timedelta(hours=1)

now = series[NOW]
print(f"world={world}: Monday 09:00 p95 = {now:.0f} ms")
for label, delta in (("an hour earlier (08:00)", timedelta(hours=1)),
                     ("Sunday 09:00", timedelta(days=1)),
                     ("Friday 09:00, before deploy", timedelta(days=3)),
                     ("Monday 09:00, 1 week ago", timedelta(weeks=1)),
                     ("Monday 09:00, 2 weeks ago", timedelta(weeks=2))):
    print(f"  ratio to {label:28s} {now / series[NOW - delta]:5.2f}")
baseline = statistics.mean(series[NOW - timedelta(weeks=k)] for k in (1, 2))
print(f"  ratio to mean of the same hour, 1w and 2w ago   {now / baseline:5.2f}")
```

Save it as `weekly.py`. Before running it, write down the ratio you expect for each baseline in each world. The prediction is that the first two ratios are the same in both worlds, and that the week-over-week ratios are about 1.0 for `seasonal` and about 1.2 for `regression`.

```
python3 weekly.py seasonal
python3 weekly.py regression
```

Python 3.11 printed:

```
world=seasonal: Monday 09:00 p95 = 232 ms
  ratio to an hour earlier (08:00)       1.22
  ratio to Sunday 09:00                  2.23
  ratio to Friday 09:00, before deploy   1.15
  ratio to Monday 09:00, 1 week ago      1.01
  ratio to Monday 09:00, 2 weeks ago     1.02
  ratio to mean of the same hour, 1w and 2w ago    1.01
world=regression: Monday 09:00 p95 = 279 ms
  ratio to an hour earlier (08:00)       1.22
  ratio to Sunday 09:00                  2.23
  ratio to Friday 09:00, before deploy   1.38
  ratio to Monday 09:00, 1 week ago      1.21
  ratio to Monday 09:00, 2 weeks ago     1.22
  ratio to mean of the same hour, 1w and 2w ago    1.22
```

Against the previous hour and against Sunday, the two worlds gave identical ratios, 1.22 and 2.23, because the deploy happened before both baselines and scales them as much as it scales Monday. Against Friday, the seasonal world still showed a 15% rise from busy Mondays alone, close enough to a real regression to start an argument. The same hour one and two weeks back gave 1.01 and 1.02 without a regression and 1.21 and 1.22 with one.

The prediction would have failed if the week-over-week ratio had moved in the seasonal world. Change the seed with `python3 weekly.py seasonal 3`, or change `1.20` to `1.05` to see how small a regression the comparison still shows: with 5% noise in each hour, a 5% regression sits at the edge, and averaging several Monday hours helps.

## Read it on a real system

In PromQL, the `offset` modifier shifts a selector back in time, and it must follow the selector directly, inside `rate`, not after an aggregation. This ratio of p95 now to p95 a week ago is the third row of the table. [offset modifier](https://prometheus.io/docs/prometheus/latest/querying/basics/)

```
histogram_quantile(0.95,
  sum by (le) (rate(http_server_request_duration_seconds_bucket{service="catalog-api"}[30m])))
/
histogram_quantile(0.95,
  sum by (le) (rate(http_server_request_duration_seconds_bucket{service="catalog-api"}[30m] offset 1w)))
```

Repeat with `offset 2w` to catch a last week that was unusual itself. The fourth row is the same comparison for request rate:

```
sum(rate(http_server_request_duration_seconds_count{service="catalog-api"}[30m]))
/
sum(rate(http_server_request_duration_seconds_count{service="catalog-api"}[30m] offset 1w))
```

On AWS, request the same statistic for two windows exactly one week apart. For an Application Load Balancer, `TargetResponseTime` is the time from the request leaving the load balancer to the target starting its response, and `get-metric-statistics` takes percentiles through `--extended-statistics`. [ALB metrics](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html) · [get-metric-statistics](https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html)

```
for start in 2026-11-23T08:00:00Z 2026-11-16T08:00:00Z 2026-11-09T08:00:00Z; do
  aws cloudwatch get-metric-statistics --profile PROFILE --region REGION \
    --namespace AWS/ApplicationELB --metric-name TargetResponseTime \
    --dimensions Name=LoadBalancer,Value=app/catalog-api/0123456789abcdef \
    --start-time "$start" --end-time "$(date -u -d "$start + 2 hours" +%FT%TZ)" \
    --period 3600 --extended-statistics p95 \
    --query 'Datapoints[].[Timestamp,ExtendedStatistics.p95]' --output text --no-cli-pager
done
```

CloudWatch anomaly detection models hourly, daily and weekly patterns from up to two weeks of data, and lets you exclude periods such as deploys from training. It also re-trains as the metric changes, so a regression that persists for long enough becomes part of the expected band. Read the band on the first Monday after a deploy, not the third. [Anomaly detection](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Anomaly_Detection.html)

## Where the comparison misleads

Last week can be wrong as a baseline. A holiday, an incident or a campaign on the previous Monday makes the ratio meaningless; use two or three earlier weeks and take the median, and check the request-rate ratio for each.

Weekly peaks follow the users' clocks, and dashboards usually run on UTC. In the weeks when your users' clocks have moved for daylight saving time and UTC has not, the Monday peak arrives an hour earlier or later in UTC, and a ratio at a fixed UTC hour compares different points of the curve. Compare the peak hours, or a window wide enough to hold both.

Latency depends on load, often more than linearly. If this Monday carried 10% more requests than last Monday, a latency ratio of 1.2 can come from load alone. Compare at equal load, or per request where the metric allows it. [Two metrics rose together](/learn/two-metrics-rose-together-common-cause/)

A ratio near 1 says this Monday looks like last Monday. It does not say the deploy changed nothing: a regression on a route that carries little traffic hides inside the total. Split by route before concluding. [Did a recent deploy cause the latency spike?](/learn/deploy-latency-spike/)

## Questions

### How do I compare a metric with the same time last week in Prometheus?

Add `offset 1w` directly after the selector, inside the function, as in `rate(metric[5m] offset 1w)`, and divide the current expression by the shifted one. The modifier is not allowed after an aggregation such as `sum(...)`.

### Why does day-over-day comparison mislead after a weekend deploy?

Because the baseline day had different traffic. Sunday to Monday rises every week, and when the deploy happened before both days it scales the baseline as well, so the ratio carries no information about the deploy.

### How much higher than last week counts as a regression?

More than the week-to-week variation at that hour. Read the ratio for the same hour over several earlier weeks without a deploy; if those ranged from 0.95 to 1.05, a ratio of 1.2 stands out and 1.04 does not.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [How can we tell whether a recent deploy caused a latency spike?](/learn/deploy-latency-spike/)
    
    Capacity overruns The Proofline team November 19, 2026 1 min read
    
-   ### [Two metrics rose together. Does one cause the other?](/learn/two-metrics-rose-together-common-cause/)
    
    Capacity overruns The Proofline team November 24, 2026 8 min read
