123DevOps··19 min read

Incident analysis for DevOps and helpdesk with Python: MTTA, MTTR, Pareto, and recurrence

How to measure incidents and tickets with pandas without fooling yourself: MTTA and MTTR with median and p90, backlog, reopen rate, FCR, a heatmap, Pareto, recurrence detection with TF-IDF and KMeans, and anomalies in daily volume.

Data

Every ticketing tool shows an “MTTR” on its dashboard. Few say what the R means, whether the math uses the mean or the median, and what happens to tickets that are still open. In this guide you’ll compute the metrics with pandas, with explicit definitions, and use scikit-learn to find recurring tickets and anomalous days. The data is synthetic and the outputs are real.

This article pairs with SLA control with data, which reuses the same generator to measure deadlines in business hours.

Define the metrics before computing them

There is no single standard for these metrics; the definitions below are industry convention. What matters is writing yours down and keeping the same math in every report.

Metric Definition used here Pitfall
MTTA Opening to first human acknowledgement A queue with no night on-call inflates the p90
MTTR Opening to resolution (R = resolve) The R can also mean repair, recover, or respond
Backlog Open tickets at a point in time, with age buckets Looking only at the total hides old tickets
Reopen rate % of resolved tickets that were reopened Some tools turn a reopen into a “new ticket”
FCR % resolved on first contact, with no reopen Needs a reliable interactions field

MTTR is the most ambiguous one. Restore (the service is back for users) is different from resolve (cause addressed and ticket closed). Even DORA replaced the old “time to restore service” with failed deployment recovery time. Pick one meaning, write it in the dashboard footer, and don’t mix them.

A synthetic ticket dataset

The generator creates 90 days of tickets with a fixed seed and mimics real patterns: more volume on workdays, no night on-call for P3/P4, Brazilian national holidays via the holidays package, noisy text, and one big incident on October 6. There is no personal data.

Tested on November 25, 2026 with Python 3.15, pandas 3.1.1, numpy 2.5.5, scikit-learn 1.9.1, and holidays 0.109.

import holidays
import numpy as np
import pandas as pd

START = pd.Timestamp("2026-08-27")
NOW = pd.Timestamp("2026-11-25")  # 90 days later: the analysis "now"
HOLIDAYS = holidays.Brazil(years=2026)

# category: (weight, team, possible services, description templates)
CATEGORIES = {
    "access-password": (0.24, "service-desk", ["ad", "erp", "customer-portal"], [
        "User locked out of {s} after password attempts",
        "Requests password reset for {s}",
        "Password expired, cannot log in to {s}",
        "MFA code not arriving on phone to access {s}"]),
    "vpn": (0.15, "network", ["vpn"], [
        "VPN disconnects every few minutes",
        "Cannot connect to the VPN from home",
        "VPN connects but cannot reach the erp",
        "VPN client asks for an update and fails"]),
    "email": (0.12, "service-desk", ["email"], [
        "Mailbox full, not receiving messages",
        "Email to external customer bounces with error",
        "Outlook does not sync the shared mailbox",
        "Requests creation of a distribution list"]),
    "application": (0.11, "platform", ["customer-portal", "payments-api", "erp"], [
        "Error 500 when saving an order in {s}",
        "Reports screen slow in {s}",
        "Export button does not work in {s}",
        "TLS certificate expired when calling payments-api"]),
    "printer": (0.08, "service-desk", ["printing"], [
        "Third floor printer does not print",
        "Print queue stuck",
        "Printer out of toner",
        "Requests printer installation"]),
    "network": (0.07, "network", ["branch-network", "wifi"], [
        "Meeting room Wi-Fi without internet",
        "Slow network at the branch office",
        "Network jack not working",
        "Packet loss on the branch link"]),
    "database": (0.06, "dba", ["erp", "payments-api"], [
        "Connection timeout on the {s} database",
        "Slow query on the {s} database",
        "Connection pool exhausted on {s}",
        "Requests read access to the {s} database"]),
    "deploy": (0.06, "platform", ["customer-portal", "payments-api"], [
        "Deploy of {s} failed in the pipeline",
        "Rollback needed after {s} deploy",
        "Pipeline for {s} stuck at the test stage",
        "Environment variable missing after {s} deploy"]),
    "hardware": (0.06, "service-desk", ["workstation"], [
        "Laptop does not turn on",
        "Monitor flickering",
        "Keyboard keys failing",
        "Requests mouse replacement"]),
    "monitoring": (0.05, "infra", ["backup", "customer-portal", "payments-api"], [
        "Disk full alert on the backup server",
        "High CPU alert on {s}",
        "TLS certificate expiring on {s}",
        "Queue backlog alert on {s}"]),
}
NOISE = ["URGENT: ", " - again", " since yesterday", " after update"]
PRIORITIES = ["P1", "P2", "P3", "P4"]
CHANNELS = ["portal", "email", "phone", "chat"]
# median resolution in hours by priority, and a factor per team
MEDIAN_H = {"P1": 2, "P2": 6, "P3": 20, "P4": 40}
TEAM_FACTOR = {"service-desk": 0.6, "network": 1.2, "platform": 1.0, "dba": 1.6, "infra": 0.9}
HOUR_WEIGHT = np.array([1, 1, 1, 1, 1, 2, 3, 6, 12, 16, 16, 14, 9, 12, 15, 15, 13, 10, 6, 4, 3, 2, 1, 1], float)


def next_business_time(t):
    """First business instant (Mon-Fri, 8am-6pm, no holiday) from t on."""
    while True:
        if t.weekday() < 5 and t.date() not in HOLIDAYS:
            if t.hour < 8:
                return t.normalize() + pd.Timedelta(hours=8)
            if t.hour < 18:
                return t
        t = t.normalize() + pd.Timedelta(days=1, hours=8)


def generate_tickets(seed=42):
    rng = np.random.default_rng(seed)
    names = list(CATEGORIES)
    weights = np.array([c[0] for c in CATEGORIES.values()])
    rows = []
    for day in pd.date_range(START, NOW - pd.Timedelta(days=1), freq="D"):
        workday = day.weekday() < 5 and day.date() not in HOLIDAYS
        n = rng.poisson(31 if workday else 6)
        extra = 45 if day == pd.Timestamp("2026-10-06") else 0  # incident day
        hours = rng.choice(24, size=n + extra, p=HOUR_WEIGHT / HOUR_WEIGHT.sum())
        for i, h in enumerate(hours):
            opened = day + pd.Timedelta(hours=int(h), minutes=int(rng.integers(60)))
            if i < n:
                cat = names[rng.choice(len(names), p=weights / weights.sum())]
                _, team, services, templates = CATEGORIES[cat]
                service = services[rng.integers(len(services))]
                desc = templates[rng.integers(len(templates))].format(s=service)
                if rng.random() < 0.4:  # real text is messy: prefixes and suffixes
                    r = NOISE[rng.integers(len(NOISE))]
                    desc = r + desc if r.endswith(": ") else desc + r
            else:  # incident: payments-api down
                cat, team, service = "application", "platform", "payments-api"
                desc = "payments-api returns error 502 at checkout"
            prio = rng.choice(PRIORITIES, p=[0.04, 0.14, 0.47, 0.35])
            if i >= n:
                prio = "P1" if rng.random() < 0.3 else "P2"
            channel = "alert" if cat == "monitoring" else CHANNELS[rng.integers(4)]

            # acknowledgement: P1/P2 have 24x7 on-call; P3/P4 wait for business hours
            wait = rng.exponential({"P1": 5, "P2": 15, "P3": 45, "P4": 90}[prio])
            base = opened if prio in ("P1", "P2") else next_business_time(opened)
            acknowledged = base + pd.Timedelta(minutes=float(wait))

            res_hours = rng.lognormal(np.log(MEDIAN_H[prio] * TEAM_FACTOR[team]), 0.9)
            resolved = acknowledged + pd.Timedelta(hours=float(res_hours))
            synchronous = channel in ("phone", "chat") and team == "service-desk"
            interactions = rng.geometric(0.65 if synchronous else 0.35)  # 1, 2, 3...
            reopened = rng.random() < (0.12 if cat == "vpn" else 0.05)
            rows.append({
                "opened_at": opened, "acknowledged_at": acknowledged,
                "resolved_at": resolved if resolved < NOW else pd.NaT,
                "priority": prio, "category": cat, "service": service,
                "channel": channel, "team": team, "reopened": bool(reopened),
                "interactions": int(interactions), "description": desc,
            })
    df = pd.DataFrame(rows).sort_values("opened_at", ignore_index=True)
    df.loc[df["resolved_at"].isna(), "reopened"] = False
    df.loc[df["acknowledged_at"] >= NOW, "acknowledged_at"] = pd.NaT
    for col in ["opened_at", "acknowledged_at", "resolved_at"]:
        df[col] = df[col].dt.floor("s")
    df.insert(0, "id", [f"INC-{i:05d}" for i in range(1, len(df) + 1)])
    return df


if __name__ == "__main__":
    df = generate_tickets()
    print(df.shape)
    print(df.drop(columns="description").head(3).to_string())
    print(df["priority"].value_counts().sort_index().to_string())
    print("open now:", df["resolved_at"].isna().sum())

Output of python tickets.py:

(2134, 12)
          id           opened_at     acknowledged_at         resolved_at priority  category      service channel          team  reopened  interactions
0  INC-00001 2026-08-27 06:35:00 2026-08-27 06:35:35 2026-08-27 09:33:03       P1       vpn          vpn  portal       network     False             1
1  INC-00002 2026-08-27 07:00:00 2026-08-27 07:20:38 2026-08-27 08:08:08       P2     email        email   email  service-desk     False             4
2  INC-00003 2026-08-27 07:54:00 2026-08-27 09:03:47 2026-08-27 22:55:17       P3  hardware  workstation  portal  service-desk     False             6
priority
P1     93
P2    323
P3    994
P4    724
open now: 41

MTTA and MTTR: median and p90, not just the mean

Handling time has a long tail: a few tickets take very long and pull the mean up. That’s why the report uses the median (the typical ticket) and the p90 (the frequent worst case). The mean stays in the table only for comparison.

import pandas as pd

from tickets import generate_tickets

df = generate_tickets()
hours = pd.Timedelta(hours=1)
df["tta_min"] = (df["acknowledged_at"] - df["opened_at"]) / pd.Timedelta(minutes=1)
df["ttr_h"] = (df["resolved_at"] - df["opened_at"]) / hours  # R = resolve


def p90(s):
    return s.quantile(0.9)


summary = df.groupby("priority").agg(
    tickets=("id", "size"),
    mtta_median_min=("tta_min", "median"), mtta_p90_min=("tta_min", p90),
    mttr_mean_h=("ttr_h", "mean"), mttr_median_h=("ttr_h", "median"),
    mttr_p90_h=("ttr_h", p90),
)
print(summary.round(1).to_string(), "\n")

by_team = df[df["priority"] == "P3"].groupby("team")["ttr_h"].agg(
    ["count", "median", p90]).sort_values("median")
print("P3 MTTR by team (h)\n" + by_team.round(1).to_string(), "\n")

resolved = df[df["resolved_at"].notna()]
print(f"reopen rate: {resolved['reopened'].mean():.1%}")
print(resolved.groupby("category")["reopened"].mean()
      .sort_values(ascending=False).head(3).map("{:.1%}".format).to_string(), "\n")

sd = resolved[resolved["team"] == "service-desk"]
fcr = (sd["interactions"] == 1) & ~sd["reopened"]
print(f"service desk FCR: {fcr.mean():.1%}")
print(fcr.groupby(sd["channel"]).mean().map("{:.1%}".format).to_string())
          tickets  mtta_median_min  mtta_p90_min  mttr_mean_h  mttr_median_h  mttr_p90_h
priority
P1             93              3.4          11.5          3.2            2.1         6.1
P2            323             10.8          35.7          8.3            5.0        18.0
P3            994             47.0         884.2         31.5           21.2        75.3
P4            724             87.5        1087.6         59.2           38.8       128.0

P3 MTTR by team (h)
              count  median   p90
team
service-desk    500    14.4  53.4
infra            37    25.1  54.2
platform        162    26.0  93.3
network         211    28.3  91.8
dba              69    39.2  82.1

reopen rate: 5.6%
category
monitoring    10.4%
vpn            9.8%
printer        6.5%

service desk FCR: 47.8%
channel
chat      62.8%
email     33.5%
phone     60.5%
portal    32.7%

What the output shows:

  • P3 MTTA has a median of 47 minutes and a p90 of 884 minutes (almost 15 hours). Whoever opens a P3 at 8 p.m. waits until 8 a.m. the next day. The mean would hide that, and that’s the customer who complains.
  • MTTR by team only compares the same priority. Mixing P1 and P4 would reward whoever gets more easy tickets. For P3, the DBA team has the worst median (39.2 h), but platform and network have the worst p90 (above 90 h).
  • The 5.6% reopen rate hides the VPN, which reopens almost twice as often (9.8%). Monitoring shows up on top with only 99 tickets, so ten reopens already move the rate; check the sample size before acting.
  • Service desk FCR depends on the channel: about 60–63% by phone and chat, versus 33% through the portal and email. FCR here is computed only over resolved service desk tickets; including second-level teams would drag the number down without meaning anything.

Tickets that are still open don’t enter the MTTR. That’s a bias: the current week always looks better, because the slow cases haven’t closed yet. Show the backlog next to it.

Backlog and volume heatmap

import pandas as pd

from tickets import NOW, generate_tickets

df = generate_tickets()

# backlog: open tickets at the end of each Sunday, and how many are older than 3 days
snapshots = pd.date_range("2026-09-06 23:59", NOW, freq="W-SUN")
rows = []
for t in snapshots:
    is_open = (df["opened_at"] <= t) & ~(df["resolved_at"] <= t)
    age = (t - df.loc[is_open, "opened_at"]) / pd.Timedelta(days=1)
    rows.append({"snapshot": t.date(), "backlog": is_open.sum(),
                 "older_than_3_days": (age > 3).sum()})
print(pd.DataFrame(rows).set_index("snapshot").T.to_string(), "\n")

# heatmap: volume by weekday and 3-hour band
days = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
band = (df["opened_at"].dt.hour // 3 * 3).map("{:02d}h".format)
day = pd.Categorical(df["opened_at"].dt.day_of_week.map(dict(enumerate(days))), days)
print(pd.crosstab(day, band, rownames=["day"], colnames=["band"]).to_string(), "\n")
snapshot           2026-09-06  2026-09-13  2026-09-20  2026-09-27  2026-10-04  2026-10-11  2026-10-18  2026-10-25  2026-11-01  2026-11-08  2026-11-15  2026-11-22
backlog                    24          20          31          22          30          30          25          31          31          19          18          28
older_than_3_days           7           9           9           7          10           9           6           7          10           5           6           9

band  00h  03h  06h  09h  12h  15h  18h  21h
day
mon     8    3   44   90   78   89   17    6
tue    13   11   49  119  107   90   26    6
wed    10   16   49  104   90   82   28   14
thu    13    7   60  105   87  107   40    7
fri    12    7   55   88   91  109   29   15
sat     3    2    8   16   20   14    5    2
sun     2    4   17   18   17   16    6    3

The backlog moves between 18 and 31, and there are always 5 to 10 tickets older than three days: that group deserves a weekly review with an owner. The heatmap helps with staffing: the peak is Tuesday to Friday, 9 a.m. to 6 p.m., and there is a small but steady volume overnight.

Pareto: where the 80/20 is

Pareto analysis ranks categories and accumulates the percentage. The classic idea is that a few causes generate most of the volume, but that’s a heuristic, not a law.

import pandas as pd

from tickets import generate_tickets

df = generate_tickets()

# Pareto by category: volume and total hours to resolve
df["ttr_h"] = (df["resolved_at"] - df["opened_at"]) / pd.Timedelta(hours=1)
pareto = df.groupby("category").agg(tickets=("id", "size"), hours=("ttr_h", "sum"))
pareto = pareto.sort_values("tickets", ascending=False)
pareto["cum_%"] = pareto["tickets"].cumsum() / pareto["tickets"].sum() * 100
pareto["hours_%"] = pareto["hours"] / pareto["hours"].sum() * 100
print(pareto.round(1).to_string())
                 tickets    hours  cum_%  hours_%
category
access-password      510  13047.1   23.9     17.3
vpn                  313  14269.2   38.6     19.0
application          284  10721.3   51.9     14.2
email                251   6669.1   63.6      8.9
printer              156   4399.7   70.9      5.8
network              140   6997.1   77.5      9.3
database             135   7076.9   83.8      9.4
hardware             126   3443.8   89.7      4.6
deploy               120   5146.7   95.4      6.8
monitoring            99   3466.8  100.0      4.6

In the real data from this run, the 80/20 does not show up. The top three categories (30% of them) add up to 51.9% of tickets, and 80% is only crossed at the seventh (83.8%). Broad categories like “application” flatten the curve. The hours column changes the order: VPN is only second in volume, but first in effort (19% of the hours). To choose problem management targets, rank by impact (volume × time), not just by count.

Recurrence: TF-IDF, KMeans, and problem records

In ITIL, incident management aims to restore service quickly. Problem management looks for the common cause behind repeated incidents. The category field helps little here, because the same defect arrives as “application” one day and as “monitoring” the next. The description text carries more signal.

TF-IDF turns each description into a vector of terms, giving less weight to words that appear everywhere. KMeans groups similar vectors. Then each group gets business metrics: distinct weeks, categories, hours spent, and reopen rate.

import numpy as np
import pandas as pd
from sklearn.cluster import KMeans
from sklearn.feature_extraction.text import TfidfVectorizer

from tickets import generate_tickets

df = generate_tickets()
STOP = ["the", "to", "of", "on", "in", "at", "a", "an", "for", "from", "and", "but",
        "not", "does", "after", "every", "with", "without", "urgent", "again",
        "since", "yesterday"]

vectorizer = TfidfVectorizer(stop_words=STOP, ngram_range=(1, 2), min_df=3)
X = vectorizer.fit_transform(df["description"])
km = KMeans(n_clusters=40, n_init=10, random_state=42).fit(X)
df["cluster"] = km.labels_

# top terms per cluster: highest centroid weights
terms = np.array(vectorizer.get_feature_names_out())
top = {c: ", ".join(terms[np.argsort(center)[::-1][:3]])
       for c, center in enumerate(km.cluster_centers_)}

df["ttr_h"] = (df["resolved_at"] - df["opened_at"]) / pd.Timedelta(hours=1)
df["week"] = df["opened_at"].dt.to_period("W")
groups = df.groupby("cluster").agg(
    tickets=("id", "size"), weeks=("week", "nunique"),
    service=("service", lambda s: s.mode()[0]),
    categories=("category", "nunique"),
    hours=("ttr_h", "sum"), reopened=("reopened", "mean"),
)
groups["terms"] = groups.index.map(top)
groups = groups.sort_values("hours", ascending=False)
print(groups.head(8).round(2).to_string(), "\n")

# problem record candidates: recurring, not service requests, and with a
# common-cause signal (high reopen rate or spread over more than one category)
request = groups["terms"].str.contains("requests")
signal = (groups["reopened"] >= 0.08) | (groups["categories"] >= 2)
candidates = groups[(groups["weeks"] >= 8) & ~request & signal]
print(f"problem candidates: {len(candidates)} of {len(groups)} clusters")
print(candidates[["tickets", "weeks", "categories", "reopened", "hours", "terms"]]
      .round(2).to_string())

tls = candidates.index[candidates["terms"].str.contains("tls")][0]
print("\n" + df.loc[df["cluster"] == tls, "description"].value_counts().head(4).to_string())

spike = groups[groups["weeks"] <= 2]
print("\nconcentrated in 2 weeks or less:\n" + spike[["tickets", "weeks", "terms"]].to_string())
         tickets  weeks          service  categories    hours  reopened                                     terms
cluster
8             84     14              vpn           1  4110.72      0.06            reach, vpn connects, reach erp
0             78     14              vpn           1  3491.77      0.10               connect vpn, vpn home, home
5            136     14               ad           1  3421.22      0.04     mfa code, code arriving, phone access
3             80     13              vpn           1  3389.88      0.11           fails, asks update, client asks
16            80     14     payments-api           2  3328.89      0.02         tls, tls certificate, certificate
6             71     14              vpn           1  3276.80      0.11         few, vpn disconnects, disconnects
4            107     14              erp           1  3162.23      0.09  password reset, reset, requests password
2            124     14  customer-portal           1  2877.27      0.03     locked, locked out, password attempts

problem candidates: 7 of 40 clusters
         tickets  weeks  categories  reopened    hours                                terms
cluster
0             78     14           1      0.10  3491.77          connect vpn, vpn home, home
3             80     13           1      0.11  3389.88      fails, asks update, client asks
16            80     14           2      0.02  3328.89    tls, tls certificate, certificate
6             71     14           1      0.11  3276.80    few, vpn disconnects, disconnects
37            36     12           1      0.11  1343.45  alert, backlog alert, queue backlog
26            39     12           1      0.15  1095.31      queue stuck, print queue, stuck
21            37     14           1      0.11  1070.80          alert backup, backup, alert

description
TLS certificate expired when calling payments-api                 32
TLS certificate expired when calling payments-api - again          7
TLS certificate expired when calling payments-api after update     6
URGENT: TLS certificate expired when calling payments-api          5

concentrated in 2 weeks or less:
         tickets  weeks                           terms
cluster
23            45      1  checkout, returns, api returns

What’s worth taking to the problem review meeting:

  • Three VPN clusters (78, 80, and 71 tickets) show up in 13 or 14 weeks and reopen 10–11% of the time. That’s the obvious candidate: a problem record for VPN client stability.
  • The TLS certificate cluster joins two categories: application errors and monitoring alerts about the same certificate. By category you’d never add them up; by text, they are 80 tickets from a single problem, which calls for automatic renewal.
  • The 502 error on October 6 forms a 45-ticket cluster in a single week. That’s a major incident, which calls for a blameless postmortem; it’s not recurrence.

k=40 was chosen by reading the groups, because the synthetic texts come from templates. On real data, try a few values, read samples from each cluster, and treat the list as a suggestion for a human to validate. The cutoff rules (8 weeks, 8% reopen rate) belong to this example; with small clusters, 8% is two or three tickets. The English run finds 7 candidates and the Portuguese version of this article finds 9, because the texts differ: clustering depends on wording.

Anomalies in daily volume

A rolling z-score is enough to say “today is not normal”. Two precautions avoid false alarms: compare each day with the same weekday, and take holidays out of the baseline, because they are known events.

import pandas as pd

from tickets import HOLIDAYS, generate_tickets

df = generate_tickets()
daily = df.set_index("opened_at").resample("D")["id"].count().rename("tickets")
holiday = daily.index.map(lambda d: d.date() in HOLIDAYS)
base = daily.mask(holiday)  # a holiday is a known event: keep it out of the baseline

# 1) expected: mean of the same weekday over the previous 4 weeks
by_day = base.groupby(base.index.day_of_week)
expected = by_day.transform(lambda s: s.shift(1).rolling(4, min_periods=2).mean())

# 2) rolling z-score of the residual, using the std of the previous 28 days
residual = daily - expected
std = residual.mask(holiday).shift(1).rolling(28, min_periods=14).std()
z = residual / std

table = pd.DataFrame({"tickets": daily, "expected": expected.round(1),
                      "z": z.round(1), "holiday": holiday})
print(table[(table["z"].abs() >= 3) | table["holiday"]].to_string())
            tickets  expected    z  holiday
opened_at
2026-09-07        4       NaN  NaN     True
2026-10-05       44      24.3  3.8    False
2026-10-06       86      25.5  9.4    False
2026-10-12        5      29.2 -1.9     True
2026-11-02        3      36.7 -2.4     True
2026-11-15        3       8.8 -1.0     True
2026-11-18       17      32.8 -3.0    False
2026-11-20        7      32.2 -4.1     True

The October 6 incident shows up with z = 9.4. Holidays are flagged separately instead of firing an alert; November 20 would have scored z = −4.1. October 5 (3.8) and November 18 (−3.0) are statistical noise: with 90 days and a threshold of 3, a few false positives are expected. Use this as a signal to look at the queue, not to wake someone up. To page on-call, prefer symptom-based alerting.

A text dashboard

Before opening a BI tool, a dashboard that fits in the terminal or in a chat post already covers the weekly meeting:

import pandas as pd

from tickets import NOW, generate_tickets

BLOCKS = "▁▂▃▄▅▆▇█"


def sparkline(series):
    lo, hi = series.min(), series.max()
    return "".join(BLOCKS[int((v - lo) / (hi - lo or 1) * 7)] for v in series)


def kpis(df, start, end):
    window = df[(df["opened_at"] >= start) & (df["opened_at"] < end)]
    done = window[window["resolved_at"].notna()]
    ttr = (done["resolved_at"] - done["opened_at"]) / pd.Timedelta(hours=1)
    tta = (window["acknowledged_at"] - window["opened_at"]) / pd.Timedelta(minutes=1)
    sd = done[done["team"] == "service-desk"]
    return {
        "tickets": len(window),
        "P1+P2": window["priority"].isin(["P1", "P2"]).sum(),
        "MTTA p50 (min)": round(tta.median(), 1),
        "MTTR p50 (h)": round(ttr.median(), 1),
        "MTTR p90 (h)": round(ttr.quantile(0.9), 1),
        "reopen rate": f"{done['reopened'].mean():.1%}",
        "service desk FCR": f"{((sd['interactions'] == 1) & ~sd['reopened']).mean():.1%}",
    }


df = generate_tickets()
week = pd.Timedelta(days=7)
current, previous = kpis(df, NOW - week, NOW), kpis(df, NOW - 2 * week, NOW - week)
print(f"Incident dashboard | week ending {NOW:%m/%d/%Y}")
print(pd.DataFrame({"previous week": previous, "this week": current}).to_string())

daily = df.set_index("opened_at").resample("D")["id"].count().tail(28)
print(f"\ndaily volume, 28 days: {sparkline(daily)}  (max {daily.max()})")
print(f"backlog now: {df['resolved_at'].isna().sum()} open tickets")
Incident dashboard | week ending 11/25/2026
                 previous week this week
tickets                    189       153
P1+P2                       34        27
MTTA p50 (min)            33.7      55.2
MTTR p50 (h)              20.6      16.3
MTTR p90 (h)              80.6      68.0
reopen rate               5.9%     10.6%
service desk FCR         45.8%     44.1%

daily volume, 28 days: ▇▅▆▁▁▁▆▅▇▅▁▂▅▅▇█▆▁▁▆▆▃▇▁▂▁█▆  (max 41)
backlog now: 41 open tickets

The dashboard compares weeks, not loose numbers: the reopen rate went from 5.9% to 10.6% and the median MTTA from 33.7 to 55.2 minutes. The MTTR “improvement” is partly the bias of tickets still open.

This environment doesn’t have matplotlib; the chart version is one extra step, with pip install matplotlib. If you want it, build four panels: a daily volume line with anomalies marked, MTTR p50/p90 bars by priority, the heatmap with imshow, and the Pareto curve with a secondary axis for the cumulative percentage.

Personal data and next steps

Real ticket descriptions carry names, emails, phone numbers, and sometimes national ID numbers: personal data under privacy laws such as Brazil’s LGPD or the GDPR. Mask it before the analysis and follow your company’s data policy, especially before sending text to an LLM. Next steps:

To cut diagnosis time, also see MTTR with business context.

Checklist

  • I wrote the definition of MTTA, MTTR (which R?), backlog, reopen rate, and FCR in the dashboard footer
  • I report median and p90, and compare teams only within the same priority
  • I show the backlog with age buckets next to the MTTR, so open tickets aren’t hidden
  • I rank the Pareto by impact (volume × time), not just by count
  • I review recurring clusters weekly and open problem records for the validated ones
  • I take holidays out of the baseline and treat volume anomalies as a signal, not a page
  • I mask personal data in descriptions before any analysis or sending to AI

A good incident metric has a written definition and a visible tail: the mean tells one story, the p90 tells the one the customer lived.

Get updates on new posts and stay in the loop!