Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Lesson 01 · 35 minutes

Measure a week of alerts and choose the tasks for an AI helper

After this lesson you can
  • Turn a week of alerts into workload numbers
  • Sort the tasks of a SOC into those a model can help with and those it must not decide
  • Measure how many real incidents a team reaches with no AI, as a baseline
Lab files of this lesson (4)

The lab folder as it stands after this lesson. Unzip it in ~/krlab.

More

The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.

Scenario

You are the new lead analyst of the SOC at Harbourline Logistics (an invented company). A SOC (security operations centre) is the team that watches the alerts of the security tools, decides which ones are real, and responds. The manager says: "We get a thousand alerts a week and one analyst on shift. Management wants an AI helper. Tell me where it can help, and what we lose today." You have one week of alerts, and each alert has a true label that the team added later. You measure the week before you buy anything. ("Security operations basics" teaches the SOC work by hand, and this course adds a model to it.)

The idea

An alert is a message from a tool that says "this may be an attack". Most alerts are harmless. A person must triage each one: read it, add context, and decide if it is a real incident. An alert travels from a sensor to an analyst. A model suits some of the tasks on the way better than others.

Where an AI helper sits in a SOC
Security toolsSOCCompanySensorsAlert queueAI helperAnalystCritical asset1234Security toolsSOCCompanySensorsAlert queueAI helperAnalystCritical asset1234
  1. Sensors → Alert queue: 1,000 alerts in a week
  2. Alert queue → AI helper: sort and summarise
  3. AI helper → Analyst: proposes, never decides
  4. Analyst → Critical asset: contains and fixes
TaskDoes a model suit it?Why
Sort alerts by riskYesMuch history with labels. A wrong order costs time, not safety.
Summarise a log or an alertYes, with a checkSaves reading. A wrong summary can hide a fact (lesson 3).
Add context (owner, address reputation)Mostly codeA lookup is exact. A model adds nothing.
Point at unusual behaviourYes, as a leadIt finds what rules miss, and it raises false alarms (lesson 4).
Close an alert without readingOnly within a measured limitA missed incident has a real cost (lesson 2).
Decide that an incident is real, and actNoA person is accountable. The cost of an error is high.

The rule for this course: a model proposes, and a person or an approved rule decides. To follow it, you must measure what a model finds and what it misses. Precision and recall (lesson 6 of "How AI works") are the measures. Before you add a model, measure the baseline: the result of the team with no model. A model is worth its cost only if it beats the baseline.

Worked example

1. Look at one alert

gen.alerts(5) returns the fixed week as a list of dictionaries. python3 -c "..." runs one line of Python. The field label is 1 for a real incident.

python3 -c "
from gen import alerts
a = alerts(5)[0]
print(a['text'])
print({k: a[k] for k in ('id', 'day', 'rule', 'severity', 'label')})
"
dns-odd-domain on wks-18 for quinn from 10.20.1.216 at 14:00, count 3, 20 MB out, severity 3
{'id': 'W5-0001', 'day': 'Mon', 'rule': 'dns-odd-domain', 'severity': 3, 'label': 0}
The text of one alert
dns-odd-domainthe rule that firedwks-18the machinequinnthe user10.20.1.216source address14:00timecount 3events counted20 MB outdata sent outseverity 3the tool's ratingdns-odd-domainthe rule that firedwks-18the machinequinnthe user10.20.1.216source address14:00timecount 3events counted20 MB outdata sent outseverity 3the tool's rating

The text is what an analyst reads. The label is not visible to the analyst on the day. It comes later, from the investigation.

2. Count the week

Save workload.py. Counter (from the standard library) counts how often each value appears. most_common() lists the counts from the biggest. A time per alert of 6 minutes is an assumption of this lab: you read the alert, look up the address and write one line. One analyst works 8 hours on a day, so CAPACITY is 80 alerts.

Two Python words are new. sorted(items, key=f) puts the items in the order of the value that f returns, and where two items have the same value it keeps their first order. lambda a: a["id"] is a short function with no name that returns the id of a. A key such as (-a["severity"], a["id"]) is a pair: it sorts by the highest severity first, and by the id (the arrival order) when the severity is equal. Two more fields of an alert are used below. asset is 1 for a workstation, 2 for a business server and 3 for the finance and payroll team, so a larger number is a more critical machine. new_source is 1 when the alert comes from an address that is new for this user.

In the table, an f-string pads and aligns: {x:20} pads x to 20 characters, {x:>6} aligns it to the right in 6 characters, and {x:.2f} shows two decimals.

workload.py

"""workload.py: the week of alerts as numbers, and the baseline with no AI."""
from collections import Counter

from gen import DAYS, alerts

MINUTES_PER_ALERT = 6          # time of one analyst for one alert
HOURS_PER_DAY = 8              # one analyst on shift
CAPACITY = HOURS_PER_DAY * 60 // MINUTES_PER_ALERT       # alerts that one analyst can read in a day


def reached(week, order):
    """Read the first CAPACITY alerts of each day, in the order that `order` gives. Return the real ones."""
    found = []
    for day in DAYS:
        todays = sorted((a for a in week if a["day"] == day), key=order)
        found += [a for a in todays[:CAPACITY] if a["label"]]
    return found


if __name__ == "__main__":
    week = alerts(5)
    real = [a for a in week if a["label"]]
    print("alerts:", len(week), " real incidents:", len(real))
    print("analyst time needed:", len(week) * MINUTES_PER_ALERT // 60, "hours; time on shift:", HOURS_PER_DAY * 7, "hours")
    print("alerts a day:", dict(Counter(a["day"] for a in week)))
    print()
    print(f"{'rule':20}{'alerts':>7}{'real':>6}{'share real':>12}")
    by_rule, real_rule = Counter(a["rule"] for a in week), Counter(a["rule"] for a in real)
    for rule, n in by_rule.most_common():
        print(f"{rule:20}{n:>7}{real_rule[rule]:>6}{real_rule[rule] / n:>12.2f}")
    print()
    print("reading order       incidents reached of", len(real))
    print("arrival order      ", len(reached(week, lambda a: a["id"])))
    print("severity first     ", len(reached(week, lambda a: (-a["severity"], a["id"]))))
    print("asset first        ", len(reached(week, lambda a: (-a["asset"], a["id"]))))
python3 workload.py
alerts: 1000  real incidents: 59
analyst time needed: 100 hours; time on shift: 56 hours
alerts a day: {'Mon': 160, 'Tue': 160, 'Wed': 160, 'Thu': 160, 'Fri': 160, 'Sat': 100, 'Sun': 100}

rule                 alerts  real  share real
failed-login-burst      230     6        0.03
port-scan               195     7        0.04
dns-odd-domain          165     5        0.03
phishing-report         115     8        0.07
malware-signature       107     8        0.07
large-upload             92    11        0.12
impossible-travel        60     5        0.08
new-admin-account        36     9        0.25

reading order       incidents reached of 59
arrival order       32
severity first      37
asset first         46

3. Read the numbers

The week holds 1,000 alerts and 59 real incidents, so 94 alerts in 100 are noise. Reading them all needs 100 hours. One analyst on shift has 56 hours. The team cannot read the whole week, and nobody has decided which alerts to skip: those that arrive late on a busy day are skipped by chance.

The table by rule shows where the real incidents hide. new-admin-account is rare, and one alert in four is real. failed-login-burst is the most common alert and only 3 in 100 are real. A rule with a low share of real alerts is a good place for help from a model, but not a place to stop reading.

4. Measure the baseline

The last three lines of the output are the baselines. The analyst reads the first 80 alerts of each day in the order that the line names, and reached counts the real incidents among them. In arrival order the team reaches 32 of 59 incidents. That means 27 real incidents were never read in the week. Severity first uses the severity that the tool gave. It reaches 37, only a little better, because the severity of a tool is a weak signal.

Real incidents reached, of 59
Arrival order32Severity first37Asset first46Arrival order32Severity first37Asset first46

A rule can do better than the tool. Asset first puts the alerts on critical assets first, with the key (-a["asset"], a["id"]), and it reaches 46. This is the number that a model has to beat, and a simple rule is the right yardstick: if a model reaches 40 and the rule reaches 46, the model is not worth its cost.

Your turn

Use workload.py and the data of week 5. The lead has three questions. Change the order in reached, and read the new count. You write the changes.

  1. With the original capacity of 80, read the alerts with new_source equal to 1 first (ties in arrival order). How many incidents does the team reach?
  2. Set CAPACITY to 60 (an analyst who is on shift for 6 hours). Read the alerts on critical assets first, as in the worked example. How many incidents does the team reach?
  3. How many alerts arrive on Monday, and on which day do the most real incidents arrive?

Last, write one sentence for the manager: which task of the table would you give to a model first, and why?

Check yourself

Why does the team reach only 32 incidents when it reads 560 of 1,000 alerts?

Arrival order is blind to risk. Each day the team reads the first 80 alerts, and a real incident that arrives after the 80th is not read. About 56 percent of the alerts are read, and 54 percent of the incidents (32 of 59) are reached: this is what chance gives.

A vendor says that its model "reads all 1,000 alerts". Which question do you ask first?

What does it do with them, and how often is it wrong? Reading is not the goal. The goal is that real incidents reach a person, and the number of incidents that the model lets pass is the number to ask for (lesson 2 measures it).

Why is "decide that an incident is real, and act" not on the list for a model?

A model has no accountability and it can be wrong in ways that nobody sees. A wrong decision to act (a blocked account, a stopped server) costs money. A wrong decision not to act lets an attack go on. A person or an approved rule stays in charge (lesson 9).

Severity first reached 37 and asset first reached 46. What does the difference teach?

A field that comes from your own knowledge of the business (which assets matter) can beat a field that a tool sets. Always compare a model with a simple rule built on such a field.

Field notes

  • Measure time per alert for real: sample 30 alerts and time the analyst. The 6 minutes of this lab is an assumption, and every hour figure in a report depends on it.
  • Alerts without a label are the usual case. The labels of this lab come from the investigation, which means that a model trained on them learns what your analysts found, not what is true. Quiet incidents are missing from the data that the model learns from.
  • The NIST publication SP 800-61 Revision 3 (2025) places detection, response and recovery in one cycle of incident response. Take the current text from NIST. This course works in the detection step, at the start of that cycle.
  • Report the cost of a miss as well as the number: which assets, which data, what clean-up. A count of 27 missed incidents means little to a manager until each one has a price.
  • A backlog is a risk in itself. Write down the rule that decides which alerts are skipped, so that it is a decision and not an accident.