LogLens/hdfs

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.

PCA on event counts0.964F1, 95% interval 0.960 to 0.968
Best LSTM0.870F1, 95% interval 0.862 to 0.877
PCA minus LSTM+9.4F1 points, paired interval +8.7 to +10.1
Random-split inflation+4.2F1 points for the LSTM, -0.8 for PCA
T01T01T09T01T03T04T03T04T03T04T02T02T13T02T14T01T11T12T02T05T06T06T06T05T05T05END

blk_-4787183101855032419 · labelled anomalous · PCA missed it · the LSTM fired at event 13 of 27

01

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.

LightGBM (sees labels)
0.989
PCA, Xu et al. 2009
0.964
LogBERT-lite + END, log-prob
0.926
Sequence lookup + novelty
0.884
LSTM + END, tuned, log-prob
0.870
LSTM + END, log-prob
0.852
LogBERT-lite, top-g
0.845
LSTM + END, top-g
0.750
Isolation Forest
0.666
Any WARN line
0.617
DeepLog LSTM, top-g
0.609
0.50.60.70.80.91.0

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
ModelF195% intervalPR-AUCPrecisionRecallFalse alarms
LightGBM (sees labels)0.9890.986 to 0.9911.0000.9790.99879
PCA, Xu et al. 20090.9640.960 to 0.9680.9300.9980.9327
LogBERT-lite + END, log-prob0.9260.920 to 0.9330.8730.8690.992559
Sequence lookup + novelty0.8840.877 to 0.8910.7920.7921.000975
LSTM + END, tuned, log-prob0.8700.862 to 0.8770.9270.7980.957902
LSTM + END, log-prob0.8520.845 to 0.8600.9350.7421.0001,291
LogBERT-lite, top-g0.8450.835 to 0.8540.7660.9330.771205
LSTM + END, top-g0.7500.738 to 0.7600.6550.8280.685531
Isolation Forest0.6660.652 to 0.6790.7510.8060.568510
Any WARN line0.6170.602 to 0.6320.4581.0000.4460
DeepLog LSTM, top-g0.6090.595 to 0.6240.5280.7650.506577
  • Count model
  • Sequence model
  • Supervised reference
  • Rule or lookup
02

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

PCA, Xu et al. 2009
-0.8
Isolation Forest
+0.6
LightGBM (sees labels)
+0.8
DeepLog LSTM, top-g
+3.4
LSTM + END, top-g
+8.0
LSTM + END, log-prob
+4.1
LSTM + END, tuned, log-prob
+4.2
LogBERT-lite, top-g
-5.0
LogBERT-lite + END, log-prob
+0.8
-6-4-2+0+2+4+6+8+10

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

PCA, Xu et al. 2009
0.844
LightGBM (sees labels)
0.944
Isolation Forest
0.678
Sequence lookup + novelty
0.598
DeepLog LSTM, top-g
0.758
LSTM + END, tuned, log-prob
0.692
LogBERT-lite, top-g
0.800
LogBERT-lite + END, log-prob
0.740
0.50.60.70.80.91.0
  • 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.

Deleting block
92% → 60%
Served block
40% → 0%
Got exception while serving
37% → 0%
Verification succeeded
22% → 2%
  • Training sessions
  • Test sessions
03

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

  1. <IP>:Transmitted block <BLK> to <IP>84.1xin 24% of these sessions vs 0.3% of normal test sessions
  2. Received block <BLK> src: <IP> dest: <IP> of size <NUM>84.1xin 24% of these sessions vs 0.3% of normal test sessions
  3. BLOCK* ask <IP> to replicate <BLK> to datanode(s) <IP>83.6xin 24% of these sessions vs 0.3% of normal test sessions
  4. <IP> Starting thread to transfer block <BLK> to <IP>83.6xin 24% of these sessions vs 0.3% of normal test sessions
  5. 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

  1. <IP> Served block <BLK> to <IP>>100xin 100% of these sessions vs 0.0% of normal test sessions
  2. BLOCK* NameSystem.delete: <BLK> is added to invalidSet of <IP>1.7xin 100% of these sessions vs 59.4% of normal test sessions
  3. 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.

04

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

PCA, Xu et al. 2009
688
LightGBM (sees labels)
751
Isolation Forest
519
Sequence lookup + novelty
929
DeepLog LSTM, top-g
486
LSTM + END, tuned, log-prob
883
  • Alerts on real anomalies
  • False alarms

Alerts and labelled anomalies, hour by hour

05001,0001,50006:0007:0008:0009:0010:00LSTM alertsLabelled anomaliesPCA alerts05001,0001,50006:0008:0010:00LSTM alertsLabelled anomaliesPCA alerts

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

idle timeout 12.3 h
PCA, Xu et al. 2009
12.5 h
LightGBM (sees labels)
12.7 h
LogBERT-lite + END, log-prob
12.7 h
DeepLog LSTM, top-g
6 s
LSTM + END, tuned, log-prob
1.2 h
1 s1 min10 min1 h6 h24 h
  • 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.

05

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

0.50.60.70.80.91.01%10%50%100%LightGBM 0.989PCA 0.964LSTM + END 0.852Isolation Forest 0.6660.50.60.70.80.91.01%10%50%100%LightGBM 0.989PCA 0.964LSTM + END 0.852Isolation Forest 0.666

Shaded bands are the range over 5 random draws of the training sessions for the baselines; the LSTM is one draw per size.

Pipeline

  1. Raw log11,175,629lines, 38.7 hours of a 200+ node Hadoop cluster
  2. Bronze0lines quarantined; raw = bronze + quarantine
  3. Silver50templates, 99.84% grouping accuracy vs LogHub's ground truth
  4. Gold575,061block sessions, only 18,375 distinct sequences
  5. Checks13/13pipeline checks passed on the full data

Tagging 11.2M lines with templates

Spark SQL regex
34 s
Drain3 in a pandas UDF
50 s
Lookup join
65 s

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

EventTemplate (learned by Drain3)LinesSessions containing itOf those, anomalous
T01Receiving block <BLK> src: <IP> dest: <IP>1,723,232
575,061
2.9%
T09BLOCK* NameSystem.allocateBlock: <PATH> <BLK>575,061
575,061
2.9%
T03PacketResponder <NUM> for block <BLK> terminating1,706,679
568,880
1.9%
T02BLOCK* NameSystem.addStoredBlock: blockMap updated: <IP> is added to <BLK> size <NUM>1,719,741
568,854
1.9%
T04Received block <BLK> of size <NUM> from <IP>1,706,514
568,854
1.9%
T05Deleting block <BLK> file <PATH>1,402,047
466,647
2.2%
T06BLOCK* 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%
T10Verification succeeded for <BLK>120,036
82,705
2.5%
T15Unexpected error trying to delete block <BLK>. BlockInfo not found in volumeMap.5,545
5,345
95.9%
T11Received 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%
T13BLOCK* 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%
T16writeBlock <BLK> received exception java.io.IOException: Could not read from stream3,226
3,226
100.0%
T17BLOCK* 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%
T19BLOCK* NameSystem.addStoredBlock: Redundant addStoredBlock request received for <BLK> on <IP> size <NUM>975
974
99.7%
T18Receiving 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%
T21BLOCK* ask <IP> to replicate <BLK> to datanode(s) <IP> <IP>165
101
74.3%
T22Exception in receiveBlock for block <BLK> java.io.IOException: Connection reset by peer75
54
100.0%
T23writeBlock <BLK> received exception java.io.IOException: Connection reset by peer75
54
100.0%
T24PacketResponder <NUM> for block <BLK> Interrupted.49
46
100.0%
T30PendingReplicationMonitor timed out block <BLK>47
46
100.0%
T25Changing block file offset of block <BLK> from <NUM> to <NUM> meta file offset to <NUM>65
38
100.0%
T26Exception in receiveBlock for block <BLK> java.io.EOFException48
37
100.0%
T27writeBlock <BLK> received exception java.io.EOFException47
36
100.0%
T28<IP>:Exception writing block <BLK> to mirror <IP>34
26
100.0%
T33PacketResponder <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%
T32PacketResponder <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%
T29PacketResponder <BLK> <NUM> Exception java.io.EOFException19
19
100.0%
T36writeBlock <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%
T37Exception 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%
T31writeBlock <BLK> received exception java.net.SocketTimeoutException13
13
100.0%
T42PacketResponder <BLK> <NUM> Exception java.io.IOException: Connection reset by peer11
11
100.0%
T40PacketResponder <BLK> <NUM> Exception java.nio.channels.ClosedByInterruptException10
10
100.0%
T48writeBlock <BLK> received exception java.io.IOException: Interrupted receiveBlock11
10
100.0%
UNK(unknown template)0
10
100.0%
T34writeBlock <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 peer9
9
100.0%
T45Exception in receiveBlock for block <BLK> java.nio.channels.ClosedByInterruptException8
8
100.0%
T38writeBlock <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%
T46writeBlock <BLK> received exception java.nio.channels.ClosedByInterruptException7
7
100.0%
T39PacketResponder <BLK> <NUM> Exception java.io.IOException: Broken pipe6
6
100.0%
T43writeBlock <BLK> received exception java.io.IOException: Broken pipe5
5
100.0%
T44Exception 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%
T49PacketResponder <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%
T41BLOCK* Removing block <BLK> from neededReplications as it does not belong to any file.4
4
100.0%
T47Reopen Block <BLK>5
4
100.0%
T50writeBlock <BLK> received exception java.net.NoRouteToHostException: No route to host1
1
100.0%
06

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

1-hour windows
20-line windows
20-line windows, parser fitted on the whole log
Any FATAL or FAILURE line
0.854
0.622
0.622
PCA, Xu et al. 2009
0.326
0.167
0.409
Isolation Forest
0.596
0.139
0.139
LightGBM (sees labels)
0.657
0.114
0.114
DeepLog LSTM, log-prob
0.347
0.176
0.244
0.00.51.0
0.00.51.0
0.00.51.0
  • 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

Parser fitted on training data, time-ordered split
0.114
Parser fitted on training data, random split
0.830
Parser fitted on the whole log, random split
0.993

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 categoryTraining periodValidationTest 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

1-hour windows · training
0%
1-hour windows · validation
15%
1-hour windows · test
41%
20-line windows · training
0%
20-line windows · validation
40%
20-line windows · test
69%

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.

07

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

112K lines Spark
25 s
pandas
5 s
1.1M lines Spark
20 s
pandas
55 s
11.2M lines Spark
282 s
pandas
597 s

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

HDFS 11.2M lines
4.7 min
Thunderbird 2.1M lines
60 s
Thunderbird 21.1M lines
7.8 min
Thunderbird 211.2M lines
3.6 h
  • 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

Read and split, Docker volume
35 s
Read and split, Windows bind mount
61 s
Whole chain, Docker volume
282 s
Whole chain, Windows bind mount
341 s

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

LogRaw textBronze ParquetSilverGoldRaw / bronze
HDFS1.6 GB279.0 MB284.3 MB18.7 MB5.7x
Thunderbird31.8 GB3.1 GB3.0 GB4.6 MB10.3x

Columnar Parquet with dictionary encoding: repetitive log text compresses several-fold before any modelling.

08

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

DetectorIdle timeoutF1Caught before the log endedMedian time to alertLive false alarms per hour
DeepLog, top-gevery event0.60951%6 s109.7
LSTM + END, tuned5 min0.65661%24 s183.2
LSTM + END, tuned30 min0.67862%30 s163.3
LSTM + END, tuned2.0 h0.85886%1.2 h170.5
LSTM + END, tuned12.3 h0.87077%1.2 h171.4
PCA5 min0.70856%5 min10.3
PCA30 min0.72853%30 min2.1
PCA2.0 h0.95165%2.1 h0.6
PCA12.3 h0.9640%12.5 h0.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.

09

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.