Log anomaly detection · HDFS_v1 · 11,175,629 lines · chronological evaluation
A 2009 PCA baseline still beats a DeepLog-style LSTM once the test set comes from the future.
Sessions are split by time: train on the first 60%, choose every threshold on the next 10%, test on the last 30%. Under that rule, principal component analysis on event counts flags anomalous HDFS blocks with an F1 of 0.964. The best LSTM reaches 0.870: it actually catches more anomalies (95.7% against 93.2%), but raises 902 false alarms to PCA's 7.
blk_-4787183101855032419 · labelled anomalous · PCA missed it · the LSTM fired at event 13 of 27
Which detector wins on future data?
Eleven detectors, one chronological test set of 172,519 sessions (3,723 labelled anomalous). Every threshold was chosen on the validation period and applied unchanged. A small LogBERT-style transformer, which reads the events on both sides of the one it judges, does better than every LSTM and still trails PCA.
Bars are 95% bootstrap intervals (1,000 resamples of the 172,519 test sessions). LSTM and LogBERT rows are seed 0, whose per-event scores are saved; the README gives 3-seed means, and LogBERT's seeds spread widely (0.864 to 0.926 for its END variant). Scores below the axis start are pinned to its left edge.
Table
| Model | F1 | 95% interval | PR-AUC | Precision | Recall | False alarms |
|---|---|---|---|---|---|---|
| LightGBM (sees labels) | 0.989 | 0.986 to 0.991 | 1.000 | 0.979 | 0.998 | 79 |
| PCA, Xu et al. 2009 | 0.964 | 0.960 to 0.968 | 0.930 | 0.998 | 0.932 | 7 |
| LogBERT-lite + END, log-prob | 0.926 | 0.920 to 0.933 | 0.873 | 0.869 | 0.992 | 559 |
| Sequence lookup + novelty | 0.884 | 0.877 to 0.891 | 0.792 | 0.792 | 1.000 | 975 |
| LSTM + END, tuned, log-prob | 0.870 | 0.862 to 0.877 | 0.927 | 0.798 | 0.957 | 902 |
| LSTM + END, log-prob | 0.852 | 0.845 to 0.860 | 0.935 | 0.742 | 1.000 | 1,291 |
| LogBERT-lite, top-g | 0.845 | 0.835 to 0.854 | 0.766 | 0.933 | 0.771 | 205 |
| LSTM + END, top-g | 0.750 | 0.738 to 0.760 | 0.655 | 0.828 | 0.685 | 531 |
| Isolation Forest | 0.666 | 0.652 to 0.679 | 0.751 | 0.806 | 0.568 | 510 |
| Any WARN line | 0.617 | 0.602 to 0.632 | 0.458 | 1.000 | 0.446 | 0 |
| DeepLog LSTM, top-g | 0.609 | 0.595 to 0.624 | 0.528 | 0.765 | 0.506 | 577 |
- Count model
- Sequence model
- Supervised reference
- Rule or lookup
Does a random split flatter the models?
Only the sequence models. The count models barely notice, because HDFS repeats itself: 99.0% of chronological test sessions replay an event sequence already seen in training (97.7% under a random split).
Extra F1 from a random split, at the same anomaly rate
The random test set has more anomalies (2.94% against 2.16%), which lifts precision for any detector, so each random-split score is rescaled to the chronological rate before subtracting. LSTM and LogBERT rows are 3-seed means. The WARN rule and the lookup are left out: they get worse under a random split, because the noisiest warnings only occur early in the log.
The honest test: sequences never seen in training
- F1 on every test session
- F1 on the 1,699 never-seen sequences
A time-ordered test set is also the end of the log
The test period is the last 5 hours of a 38.7-hour log, and HDFS blocks are often deleted hours after they are written. So 40% of test sessions end before their delete events, and the read traffic of the early hours has stopped. Every model is judged on these cut-off sessions; a normal session that was merely cut off looks just like one that stopped early.
- Training sessions
- Test sessions
What does each model miss?
Each square is one of the 3,723 anomalous test sessions. PCA judges how often events happen; DeepLog judges what comes next, and the two miss almost completely different anomalies. Adding an END event lets the LSTM see sessions that stop early, and then it catches nearly everything PCA does.
Published DeepLog and PCA
- 1,637 Both catch it
- 1,834 Only PCA
- 246 Only DeepLog
- 6 Neither
LSTM with an END event and PCA
- 3,469 Both catch it
- 2 Only PCA
- 94 Only the LSTM
- 158 Neither
What the LSTM's 902 false alarms contain
- <IP>:Transmitted block <BLK> to <IP>84.1xin 24% of these sessions vs 0.3% of normal test sessions
- Received block <BLK> src: <IP> dest: <IP> of size <NUM>84.1xin 24% of these sessions vs 0.3% of normal test sessions
- BLOCK* ask <IP> to replicate <BLK> to datanode(s) <IP>83.6xin 24% of these sessions vs 0.3% of normal test sessions
- <IP> Starting thread to transfer block <BLK> to <IP>83.6xin 24% of these sessions vs 0.3% of normal test sessions
- Deleting block <BLK> file <PATH>1.1xin 66% of these sessions vs 59.7% of normal test sessions
What PCA's 7 false alarms contain
- <IP> Served block <BLK> to <IP>>100xin 100% of these sessions vs 0.0% of normal test sessions
- BLOCK* NameSystem.delete: <BLK> is added to invalidSet of <IP>1.7xin 100% of these sessions vs 59.4% of normal test sessions
- Deleting block <BLK> file <PATH>1.7xin 100% of these sessions vs 59.7% of normal test sessions
Ranked by how much more often a template appears in these sessions than in normal test sessions. PCA's few false alarms all carry read traffic ("Served block"), which almost vanished from the test period. The LSTM's false alarms lean on replication events. Both models' misses are replication sessions too: the replication templates appear in every missed anomaly against 17% of all anomalies. One anomaly in five simply stops early, which is why the LSTM needs the END event at all.
What would it be like to run?
Over the 5.1 test hours, PCA raises about 688 alerts an hour and almost all are real. Speed is a different story: a count model has to wait for a session to finish, and HDFS sessions can stay open for hours.
Alerts per hour
- Alerts on real anomalies
- False alarms
Alerts and labelled anomalies, hour by hour
By the hour each session started. The log ends 16 minutes into its last hour, so that hour is left out.
Time from a session's first event to its alert
- Median time from a session's first event to the alert
- 10th to 90th percentile
A live system never knows a session has ended; it can only assume so after a stretch of silence. Normal HDFS blocks routinely go quiet for hours before they are deleted, so that stretch has to be 12.3 h (the 99th percentile of the longest pause inside normal training sessions). Count models, and the LSTM whenever it fires on the END event, can only alert after that wait. Published DeepLog fires on the event itself: median 6 s against 12.5 h for PCA.
How much training data, and how clean?
Less than you would think, but PCA gets fragile. With 1% of the training period (3,450 sessions, about what DeepLog was trained on), PCA's F1 ranges from 0.724 to 0.964 depending on which sessions it happens to see; LightGBM barely moves, and the LSTM scores 0.902.
Test F1 against the share of training sessions used
Shaded bands are the range over 5 random draws of the training sessions for the baselines; the LSTM is one draw per size.
Pipeline
- Raw log11,175,629lines, 38.7 hours of a 200+ node Hadoop cluster
- Bronze0lines quarantined; raw = bronze + quarantine
- Silver50templates, 99.84% grouping accuracy vs LogHub's ground truth
- Gold575,061block sessions, only 18,375 distinct sequences
- Checks13/13pipeline checks passed on the full data
Tagging 11.2M lines with templates
Same templates, three matchers; all three agree on every line.
Why the parser threshold matters
At Drain3's default similarity threshold (0.4), "PacketResponder N for block X terminating" (1.7M normal lines) and "... Interrupted" (49 failure lines) became one template, hiding a failure signal inside the most common event. Grouping accuracy was 83.4%; at the validation-chosen 0.9 it is 99.78% on test.
Every learned template
| Event | Template (learned by Drain3) | Lines | Sessions containing it | Of those, anomalous |
|---|---|---|---|---|
| T01 | Receiving block <BLK> src: <IP> dest: <IP> | 1,723,232 | 575,061 | 2.9% |
| T09 | BLOCK* NameSystem.allocateBlock: <PATH> <BLK> | 575,061 | 575,061 | 2.9% |
| T03 | PacketResponder <NUM> for block <BLK> terminating | 1,706,679 | 568,880 | 1.9% |
| T02 | BLOCK* NameSystem.addStoredBlock: blockMap updated: <IP> is added to <BLK> size <NUM> | 1,719,741 | 568,854 | 1.9% |
| T04 | Received block <BLK> of size <NUM> from <IP> | 1,706,514 | 568,854 | 1.9% |
| T05 | Deleting block <BLK> file <PATH> | 1,402,047 | 466,647 | 2.2% |
| T06 | BLOCK* NameSystem.delete: <BLK> is added to invalidSet of <IP> | 1,396,174 | 465,015 | 2.2% |
| T07 | <IP> Served block <BLK> to <IP> | 428,726 | 137,434 | 2.6% |
| T08 | <IP>:Got exception while serving <BLK> to <IP>: | 356,207 | 129,295 | 2.5% |
| T10 | Verification succeeded for <BLK> | 120,036 | 82,705 | 2.5% |
| T15 | Unexpected error trying to delete block <BLK>. BlockInfo not found in volumeMap. | 5,545 | 5,345 | 95.9% |
| T11 | Received block <BLK> src: <IP> dest: <IP> of size <NUM> | 7,097 | 5,243 | 66.1% |
| T12 | <IP>:Transmitted block <BLK> to <IP> | 6,937 | 5,243 | 66.1% |
| T13 | BLOCK* ask <IP> to replicate <BLK> to datanode(s) <IP> | 6,837 | 5,192 | 65.9% |
| T14 | <IP> Starting thread to transfer block <BLK> to <IP> | 6,837 | 5,192 | 65.9% |
| T16 | writeBlock <BLK> received exception java.io.IOException: Could not read from stream | 3,226 | 3,226 | 100.0% |
| T17 | BLOCK* NameSystem.addStoredBlock: addStoredBlock request received for <BLK> on <IP> size <NUM> But it does not belong to any file. | 1,288 | 1,259 | 99.1% |
| T19 | BLOCK* NameSystem.addStoredBlock: Redundant addStoredBlock request received for <BLK> on <IP> size <NUM> | 975 | 974 | 99.7% |
| T18 | Receiving empty packet for block <BLK> | 1,464 | 488 | 100.0% |
| T20 | <IP> Starting thread to transfer block <BLK> to <IP>, <IP> | 165 | 101 | 74.3% |
| T21 | BLOCK* ask <IP> to replicate <BLK> to datanode(s) <IP> <IP> | 165 | 101 | 74.3% |
| T22 | Exception in receiveBlock for block <BLK> java.io.IOException: Connection reset by peer | 75 | 54 | 100.0% |
| T23 | writeBlock <BLK> received exception java.io.IOException: Connection reset by peer | 75 | 54 | 100.0% |
| T24 | PacketResponder <NUM> for block <BLK> Interrupted. | 49 | 46 | 100.0% |
| T30 | PendingReplicationMonitor timed out block <BLK> | 47 | 46 | 100.0% |
| T25 | Changing block file offset of block <BLK> from <NUM> to <NUM> meta file offset to <NUM> | 65 | 38 | 100.0% |
| T26 | Exception in receiveBlock for block <BLK> java.io.EOFException | 48 | 37 | 100.0% |
| T27 | writeBlock <BLK> received exception java.io.EOFException | 47 | 36 | 100.0% |
| T28 | <IP>:Exception writing block <BLK> to mirror <IP> | 34 | 26 | 100.0% |
| T33 | PacketResponder <BLK> <NUM> Exception java.io.InterruptedIOException: Interruped while waiting for IO on channel java.nio.channels.SocketChannel[connected local=<IP> remote=<IP>]. <NUM> millis timeout left. | 33 | 23 | 100.0% |
| T32 | PacketResponder <BLK> <NUM> Exception java.net.SocketTimeoutException: <NUM> millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=<IP> remote=<IP>] | 22 | 22 | 100.0% |
| T29 | PacketResponder <BLK> <NUM> Exception java.io.EOFException | 19 | 19 | 100.0% |
| T36 | writeBlock <BLK> received exception java.net.SocketTimeoutException: <NUM> millis timeout while waiting for channel to be ready for <*> ch : java.nio.channels.SocketChannel[connected local=<IP> remote=<IP>] | 15 | 15 | 100.0% |
| T37 | Exception in receiveBlock for block <BLK> java.io.InterruptedIOException: Interruped while waiting for IO on channel java.nio.channels.SocketChannel[connected local=<IP> remote=<IP>]. <NUM> millis timeout left. | 16 | 15 | 100.0% |
| T31 | writeBlock <BLK> received exception java.net.SocketTimeoutException | 13 | 13 | 100.0% |
| T42 | PacketResponder <BLK> <NUM> Exception java.io.IOException: Connection reset by peer | 11 | 11 | 100.0% |
| T40 | PacketResponder <BLK> <NUM> Exception java.nio.channels.ClosedByInterruptException | 10 | 10 | 100.0% |
| T48 | writeBlock <BLK> received exception java.io.IOException: Interrupted receiveBlock | 11 | 10 | 100.0% |
| UNK | (unknown template) | 0 | 10 | 100.0% |
| T34 | writeBlock <BLK> received exception java.io.IOException: Block <BLK> is valid, and cannot be written to. | 9 | 9 | 100.0% |
| T35 | <IP>:Failed to transfer <BLK> to <IP> got java.io.IOException: Connection reset by peer | 9 | 9 | 100.0% |
| T45 | Exception in receiveBlock for block <BLK> java.nio.channels.ClosedByInterruptException | 8 | 8 | 100.0% |
| T38 | writeBlock <BLK> received exception java.io.InterruptedIOException: Interruped while waiting for IO on channel java.nio.channels.SocketChannel[connected local=<IP> remote=<IP>]. <NUM> millis timeout left. | 7 | 7 | 100.0% |
| T46 | writeBlock <BLK> received exception java.nio.channels.ClosedByInterruptException | 7 | 7 | 100.0% |
| T39 | PacketResponder <BLK> <NUM> Exception java.io.IOException: Broken pipe | 6 | 6 | 100.0% |
| T43 | writeBlock <BLK> received exception java.io.IOException: Broken pipe | 5 | 5 | 100.0% |
| T44 | Exception in receiveBlock for block <BLK> java.net.SocketTimeoutException: <NUM> millis timeout while waiting for channel to be ready for write. ch : java.nio.channels.SocketChannel[connected local=<IP> remote=<IP>] | 5 | 5 | 100.0% |
| T49 | PacketResponder <BLK> <NUM> Exception java.io.InterruptedIOException: Interruped while waiting for IO on channel java.nio.channels.SocketChannel[closed]. <NUM> millis timeout left. | 5 | 5 | 100.0% |
| T41 | BLOCK* Removing block <BLK> from neededReplications as it does not belong to any file. | 4 | 4 | 100.0% |
| T47 | Reopen Block <BLK> | 5 | 4 | 100.0% |
| T50 | writeBlock <BLK> received exception java.net.NoRouteToHostException: No route to host | 1 | 1 | 100.0% |
Does it hold on another system?
Not on BGL, 4.7M lines from a Blue Gene/L supercomputer over 215 days, and the reason is time rather than any model. The failures change: 42% of test-period alert lines belong to categories that never occur in training. Under a time-ordered split, a one-line rule (flag any FATAL or FAILURE line) beats every model.
Every model, both ways of cutting the log into windows
- F1 on a time-ordered split
- F1 on a random split
BGL has no natural sessions, so the log is cut into 1-hour windows or 20-line windows; a window is anomalous if any line in it carries an alert tag. Each scheme has its own split and its own parser, fitted only on its training period. LSTM rows are 3-seed means. On 20-line windows the rule scores 0.622; every model falls below it once the test data comes from later months.
The benchmark recipe, one step at a time
The same supervised model on the same 20-line windows. Shuffling the windows lets it train on the failures it will be tested on; fitting the parser on the whole log also hands it the test period's vocabulary. Together they turn 0.114 into 0.993, the kind of number published BGL results report.
The failures change
| Alert category | Training period | Validation | Test period |
|---|---|---|---|
| KERNDTLB | 66% | 0% | 0% |
| KERNSTOR | 27% | none | 0% |
| APPSEV | 0% | 26% | 49% |
| KERNMNTF new after training | none | 23% | 28% |
| KERNTERM | 2% | 37% | 8% |
| KERNREC new after training | none | none | 7% |
| APPREAD | 3% | none | none |
| KERNRTSP | 1% | 2% | 1% |
| APPRES new after training | none | 0% | 3% |
| APPUNAV | 0% | 3% | none |
Share of each period's alert lines, on the 20-line scheme's split. KERNDTLB alone is 66% of the training period's alerts and almost disappears afterwards.
So does the vocabulary
Share of lines that match no template learned on the training period. On its own training period the 20-line parser's grouping accuracy against Loghub-2.0's ground truth is 90%; on the test period it is 20%, because whole new kinds of message appear later in the log and an unknown line can never be grouped correctly.
What does it take to run at scale?
All 211,212,192 Thunderbird lines (31.8 GB) go from raw text to hourly windows in 3.6 hours on one laptop. Ten times the lines of the 10% run cost 27 times the time, because the template vocabulary keeps growing with the log (9,037 templates at 10%, 69,831 at full size) and every unknown message is checked against it. Spark is the right tool once the input is past a million lines or so; below that its start-up cost loses to plain pandas.
Spark against pandas on HDFS, raw text to a finished session table
Same work in both: split each line, mask it, tag it with a learned template, group lines into block sessions with count vectors. pandas runs in one process on 1M-line chunks; Spark runs in local mode on 16 cores. At 112K lines pandas is 5x faster, because Spark spends most of the run starting up; at the full 11.2M lines Spark is 2.1x faster, and pandas has grown to 3.6 GB of memory.
Where the time goes
- Read and split
- Learn templates
- Tag templates
- Build sessions
Each stage writes Parquet, so every stage is really computed. Each bar is that run's own time, split by stage. Thunderbird learns its templates inside the run, on the first 60% of each input; HDFS reuses the templates learned earlier.
Storage matters too
HDFS at full size. Reading through the Windows bind mount, as the rest of the pipeline does, costs about 1.7x on the read stage; the Thunderbird runs read from a Docker volume.
How much each layer keeps
| Log | Raw text | Bronze Parquet | Silver | Gold | Raw / bronze |
|---|---|---|---|---|---|
| HDFS | 1.6 GB | 279.0 MB | 284.3 MB | 18.7 MB | 5.7x |
| Thunderbird | 31.8 GB | 3.1 GB | 3.0 GB | 4.6 MB | 10.3x |
Columnar Parquet with dictionary encoding: repetitive log text compresses several-fold before any modelling.
What happens when it runs live?
The 3,134,146 raw lines of the 5.3-hour test period, replayed through Spark Structured Streaming with the same parser and templates, take 33 minutes on the laptop, 9.5 times faster than the log was written. At the end of the log every DeepLog and PCA verdict matches the offline run, and the END LSTM differs only on 2 sessions that sit exactly on its threshold. What changes is when the verdicts arrive: with the 12.3 h idle timeout, PCA catches 0 of the 3,723 anomalies before the log ends; with a 2.0 h timeout it catches 2,414 at F1 0.951.
Every detector at every idle timeout, in log time
| Detector | Idle timeout | F1 | Caught before the log ended | Median time to alert | Live false alarms per hour |
|---|---|---|---|---|---|
| DeepLog, top-g | every event | 0.609 | 51% | 6 s | 109.7 |
| LSTM + END, tuned | 5 min | 0.656 | 61% | 24 s | 183.2 |
| LSTM + END, tuned | 30 min | 0.678 | 62% | 30 s | 163.3 |
| LSTM + END, tuned | 2.0 h | 0.858 | 86% | 1.2 h | 170.5 |
| LSTM + END, tuned | 12.3 h | 0.870 | 77% | 1.2 h | 171.4 |
| PCA | 5 min | 0.708 | 56% | 5 min | 10.3 |
| PCA | 30 min | 0.728 | 53% | 30 min | 2.1 |
| PCA | 2.0 h | 0.951 | 65% | 2.1 h | 0.6 |
| PCA | 12.3 h | 0.964 | 0% | 12.5 h | 0.0 |
A block closes after its idle timeout of silence, and the count model and the END event judge it then; DeepLog judges each event as it arrives, so it needs no timeout. "Before the log ended" counts alerts dated before the last line of the test period. F1 is over all 172,519 test sessions; at short timeouts it covers each block as it stood when it first went quiet. DeepLog fires a median 6 s after an anomalous block's first event.
Each micro-batch carries 5 minutes of log and took a median 18 s (90th percentile 49 s) across 67 batches, so the same job would keep up with the live log with room to spare. Per-block state (recent events, counts, verdicts so far) lives in Spark's state store, and an event-time watermark decides when a quiet block has timed out.
Read the sessions yourself
Real test sessions, as event sequences. Each event is shaded by how surprised the LSTM was to see it; the outlined event is where it fired. Hover an event for its log template.