Observers
Interface
quickrib.observers.observer.Observer
Bases: Protocol
Base class and structural type for everything attached to a RIBTable.
The three update_* hooks run inside the replay loop, once per BGP
message, so keep them O(1) and allocation-free; push aggregation into
:meth:dump. See the performance notes in AGENTS.md.
RIBTable ignores whatever the hooks return, but they are typed as
returning something so an observer can hand a result to a subclass, as
:class:~quickrib.observers.update_tagger.UpdateTagsCounter does with the
tagger's flags.
Source code in src/quickrib/observers/observer.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
name = name
class-attribute
instance-attribute
Identifies the observer; :meth:RIBTable.compare pairs observers by it.
update_rib(bgpelem)
A RIB-dump entry, replayed while the table is being built.
Source code in src/quickrib/observers/observer.py
51 52 53 | |
update_announcement(bgpelem, data, old_data)
An announcement.
data is the prefix's new node .data; old_data is a snapshot of
the previous one, or None when the peer did not have this prefix.
Comparing the two is how an observer tells a real change from a
re-announcement that only moved an attribute it does not care about.
Source code in src/quickrib/observers/observer.py
55 56 57 58 59 60 61 62 63 64 65 | |
update_withdrawal(bgpelem, data)
A withdrawal. data is the withdrawn node .data, or None if
the peer did not have the prefix, in which case nothing was counted and
there is nothing to take back.
Source code in src/quickrib/observers/observer.py
67 68 69 70 71 | |
dump(ts)
Emit the result for the window ending at ts, and return it.
ts is the window boundary (start_time + k * dump_res), not the
message that happened to cross it. Every elapsed boundary is reported
even across a gap in the stream, so a series has one entry per window
however busy the collectors were.
Source code in src/quickrib/observers/observer.py
73 74 75 76 77 78 79 80 81 | |
compare(other)
Report how this observer differs from one built on a ground-truth RIB.
Source code in src/quickrib/observers/observer.py
83 84 85 | |
set_rib(rib)
Receive a back-reference to the subject, once the RIB is built.
The escape hatch for observers that genuinely cannot work from the notifications alone; treat the reference as read-only.
Source code in src/quickrib/observers/observer.py
87 88 89 90 91 92 93 | |
set_full_feed_peers(ff_peers)
Receive the pipeline's full-feed selection, before any replay.
Source code in src/quickrib/observers/observer.py
95 96 97 | |
AS Hegemony
quickrib.observers.hegemony.HegemonyObserver
Bases: Observer
Incremental edge AS-hegemony.
For every vantage point (collector, peer ASN, peer IP) the observer keeps
edge_paths_count[vp][edge]: the summed IP-space weight of the prefixes routed by that VP whose AS path containsedge;num_total_paths[vp]: the VP's total routed IP space, which normalises its betweenness centrality.
Both are updated in update_rib / update_announcement /
update_withdrawal at a cost of O(path length) (plus O(#more-specifics)
per update in deaggregate mode). :meth:dump turns the current counts
into a :class:~quickrib.observers._gdecomp.Graph of per-edge hegemony
(per-VP betweenness, then :func:trim_mean across VPs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Trimmed-mean cut fraction passed to :func: |
0.2
|
deaggregate
|
bool
|
|
False
|
min_hegemony
|
float
|
Edges whose trimmed-mean hegemony is at or below this are dropped from the dumped graph. Zero by default: only weightless edges go. Opt in to a real cut only if a smaller graph is worth what it costs, which is more than it looks. See the note below. |
0.0
|
Relation to :func:edge_hegemony
deaggregate=True reproduces :func:edge_hegemony exactly (up to
floating-point accumulation order): same per-VP betweenness weighted by
deaggregation-aware prefix size, same normalisation by the VP's covered
address count, same :func:trim_mean across VPs.
deaggregate=False skips deaggregation: a prefix and each of its
more-specifics both count their full block, so num_total_paths[vp] sums
overlapping space. Cheaper and exactly reversible; absolute magnitudes
differ from :func:edge_hegemony while rankings stay close.
Why min_hegemony defaults to zero
A non-zero cut decides graph membership by comparing a float to a threshold, and consumers downstream are not continuous in membership: the MAD detector pads the edge vector to a power of two, so one edge entering or leaving can re-bin every wavelet coefficient. With a cut at 1e-15 an edge sitting on the threshold flipped on a last-bit difference, which made mathematically-equivalent changes look like regressions (see AGENTS.md, "A MAD score is not reproducible to the last bit").
At zero, membership is decided by sign rather than by comparison with a small number: an edge is in the graph exactly when its hegemony is strictly positive. A sum of non-negative terms is positive or it is not, whatever order it is accumulated in, so no rounding can add or remove an edge.
Zero is also the only cut at which the incremental and post-hoc paths agree
on membership. An edge carrying no weight is absent from
edge_paths_count, which never stores a zero, but present in the post-hoc
walk. In deaggregate mode this happens whenever a prefix is entirely
covered by its own more-specifics, leaving it an effective size of zero. Dropping it on both sides is what
keeps deaggregate=True equal to :func:edge_hegemony.
Note
This observer never needs a back-reference to the RIBTable: it is
warm-started automatically because QuickRIB.build_rib replays every RIB
entry through update_rib before the first dump, so set_rib is a
no-op even though the pipeline does call it.
Source code in src/quickrib/observers/hegemony.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
dump(ts)
Return the current per-edge hegemony as a :class:Graph (bidirectional).
Source code in src/quickrib/observers/hegemony.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
quickrib.observers.hegemony.RibHegemonyObserver
Bases: Observer
Post-hoc edge hegemony as an observer.
A thin wrapper around :func:edge_hegemony: :meth:dump recomputes the
entire edge-hegemony graph from the current RIB (mirroring what
examples/hegemony.py does by hand). update_* are no-ops: the
observer holds no incremental state, it just needs a reference to the
RIBTable. QuickRIB.build_rib hands it one through
:meth:set_rib once the table is built; passing rib= to the constructor
is only needed outside the pipeline.
Slower than the incremental :class:HegemonyObserver (a full RIB walk per
dump) but the two agree when the latter runs with deaggregate=True.
Source code in src/quickrib/observers/hegemony.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
quickrib.observers.hegemony.node_hegemony(rib, alpha=0.2)
Per-ASN hegemony over a reconstructed RIB.
Each ASN is credited once per path (set(as_path)), where
:func:edge_hegemony credits each consecutive link and so counts a link
twice if a path traverses it twice. Paths that revisit an ASN are the only
case where the two differ, and they are rare enough in real data that the
asymmetry has never been worth the cost of de-duplicating edges per path.
Source code in src/quickrib/observers/hegemony.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
quickrib.observers.hegemony.edge_hegemony(rib, alpha=0.2)
Per-link hegemony over a reconstructed RIB. See :func:node_hegemony for
how the two treat a path that revisits an ASN.
Source code in src/quickrib/observers/hegemony.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
quickrib.observers.hegemony.trim_mean(data, alpha, force_trim=True)
Mean of data with its most extreme values cut from both ends.
Kept as the single-sample entry point (and the reference the vectorised
:func:_trim_across_vps is tested against); it no longer goes through
scipy.stats.trim_mean, whose per-call overhead dominated when hegemony
called it once per edge.
Source code in src/quickrib/observers/hegemony.py
399 400 401 402 403 404 405 406 407 408 409 410 | |
IODA Signal
quickrib.observers.ioda.IODAObserver
Bases: Observer
Incremental IODA signal.
The observer is told which peers are full-feed before the RIB build.
QuickRIB.initialize_processing has already made that selection and hands
it over through :meth:set_full_feed_peers, so the observer can count how
many of them see each prefix directly in update_rib and never needs to
read the RIB back. The first dump turns those counts into the visible set and the
per-AS trees; from then on the update_* hot path maintains them in O(1)
per element and a dump only recomputes the block count of the ASes whose
visible set actually changed.
The state is a chain, each level derived from the one above it::
_pfx_peers prefix -> how many full-feed peers currently see it
_pfx_origins prefix -> origin ASN -> how many of them report that origin
_visible the prefixes whose peer count is above the quorum
_trees origin ASN -> radix holding *its* visible prefixes
_totals origin ASN -> block count of that radix, i.e. the signal
An update touches the top two directly. Only a change that crosses the
quorum, or that adds or drops an origin for an already-visible prefix,
reaches _trees, and even then it only marks the AS dirty rather than
recounting it. The block count is paid once per dump, not once per message.
Because the criterion is QuickRIB's own, running the pipeline with
fullfeed_only=True is not just allowed but cheaper: the peers the
observer would ignore never enter the RIB in the first place.
The full-feed population is fixed at that hand-over rather than recomputed
every bin as IODA does. Peer table sizes move by a fraction of a percent over
a few hours, so the membership does not drift; :meth:full_feed_drift
reports it against a RIB if it ever does.
Source code in src/quickrib/observers/ioda.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
set_full_feed_peers(ff_peers)
Adopt the full-feed selection, as (collector, peer_asn, peer_ip).
Called by :class:~quickrib.rib_table.RIBTable once QuickRIB has
made its selection, which is before any element is replayed.
Source code in src/quickrib/observers/ioda.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
full_feed_drift(rib)
Vantage points whose full-feed status in rib differs from the pinned set.
Empty in a well-behaved run. A non-empty result means the window is long enough that a per-bin re-evaluation would have picked a different peer population than the one pinned before the build.
Source code in src/quickrib/observers/ioda.py
350 351 352 353 354 355 356 357 358 | |
quickrib.observers.ioda.RibIODAObserver
Bases: Observer
Post-hoc IODA signal: recompute :func:visible_slash24s at every dump.
The reference observer. It rescans the whole RIB each time, which is
O(peers x prefixes) per dump: correct, but far too slow to run at IODA's
5-minute cadence over a long window. Use :class:IODAObserver for that.
Source code in src/quickrib/observers/ioda.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
set_full_feed_peers(ff_peers)
Receive the pipeline's full-feed selection (see :class:IODAObserver).
Source code in src/quickrib/observers/ioda.py
228 229 230 | |
quickrib.observers.ioda.visible_slash24s(rib_data, *, ip_version=4, ff_peers=None, visible_ratio=VISIBLE_RATIO, full_feed_ratio=FULL_FEED_RATIO)
The IODA BGP signal: origin ASN -> number of visible /24s (or /48s).
ff_peers pins the full-feed population instead of deriving it from
rib_data; :class:IODAObserver uses that to keep the two
implementations comparable at a shared instant.
Source code in src/quickrib/observers/ioda.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
quickrib.observers.ioda.full_feed_peers(rib_data, *, ratio=FULL_FEED_RATIO)
The full-feed vantage points of rib_data, by QuickRIB's rule.
A peer is full-feed if it carries more than ratio times the number of
unique prefixes its collector saw, across both address families. This is the
same computation QuickRIB.initialize_processing performs on the RIB-dump
stream. Deriving it here is the post-hoc path; a pipeline run hands the
already-computed selection to the observer instead.
Source code in src/quickrib/observers/ioda.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
Outage detection
quickrib.observers.ioda.evaluate_series(series, *, step=IODA_STEP, history=ALERT_HISTORY, threshold=ALERT_THRESHOLD)
Score one entity's time series bin by bin against its own recent past.
Returns one record per bin that has a full history behind it, with
the value, the historyValue (the median baseline) and the resulting
level. Bins without enough history are skipped, exactly as IODA cannot
alert before it has a baseline.
A bin that is itself alerting does not feed the baseline: otherwise a
long outage erodes its own median and silently declares itself normal while
still down. Matching the API's historyValue on real series is what
settles this; tests/test_ioda.py pins the agreement.
Source code in src/quickrib/observers/ioda.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | |
quickrib.observers.ioda.detect_alerts(series, **kwargs)
IODA-shaped alerts for one entity: the bins where its level changes.
Mirrors /v2/outages/alerts, which reports transitions rather than every
bin. The first evaluated bin is reported only if it is already alerting.
Source code in src/quickrib/observers/ioda.py
632 633 634 635 636 637 638 639 640 641 642 643 644 | |
quickrib.observers.ioda.detect_events(series, *, location='', location_name='', datasource='bgp', step=IODA_STEP, **kwargs)
IODA-shaped outage events for one entity, as /v2/outages/events returns them.
An event spans from a bin turning critical to the bin that turns
normal again; one still alerting at the end of the series is closed on
its last bin. score follows IODA's formula, 500 * sum(1 - value /
historyValue) over the event's bins.
Source code in src/quickrib/observers/ioda.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | |
BGPlay
quickrib.observers.bgplay.BGPlayObserver
Bases: Observer
Collect the BGPlay view of one resource while the pipeline replays BGP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
str | Iterable[str]
|
Prefix, IP address, |
required |
start_time
|
datetime
|
The |
required |
end_time
|
Optional[datetime]
|
The |
None
|
resolve_owners
|
bool
|
Fill |
False
|
Notes
The hot path is one set lookup on the prefix plus, in AS mode, one on the
path origin, and nothing is allocated before an element matches. All the
formatting (ISO timestamps, integer paths, community filtering, sorting)
happens once in :meth:to_dict.
A withdrawal carries no AS path, so it can only be matched by the prefix
filter. In pure AS mode the payload therefore has no W events at all,
which is exactly what the API returns.
Source code in src/quickrib/observers/bgplay.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
as_numbers(events=None)
Every ASN on an initial_state or announcement path.
events lets :meth:to_dict pass the list it has already sorted
rather than have it sorted again.
Source code in src/quickrib/observers/bgplay.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
to_dict(resolve_owners=None)
Render the collected data as the API's data object.
Source code in src/quickrib/observers/bgplay.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
dump(ts)
Return the BGPlay payload accumulated so far.
Unlike a windowed observer this is cumulative: initial_state is the
table at start_time and events grows for the whole run, which is
exactly what one API response holds. Use :meth:write_json to persist
it.
Source code in src/quickrib/observers/bgplay.py
456 457 458 459 460 461 462 463 464 | |
compare(other)
Log how this payload differs from other (another observer or a payload).
Source code in src/quickrib/observers/bgplay.py
466 467 468 469 470 471 472 473 474 475 | |
quickrib.observers.bgplay.diff_bgplay(ours, theirs)
Compare two BGPlay data objects, ours against a reference.
seq and nodes[].owner are ignored (see the module docstring), and
each section is compared as a multiset, so a lost or invented duplicate
event shows up instead of collapsing. The same peer re-announcing the same
path in the same second is real, and the API does report it twice.
Communities are compared as sets, since the two sides may order them
differently.
Returns, per section, only_ours / only_theirs (Counter of keys),
mismatched (a set of keys present on both sides with differing content)
and a jaccard similarity. Event ordering within one second is not
compared; see the module docstring.
Source code in src/quickrib/observers/bgplay.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
quickrib.observers.bgplay.is_equivalent(report)
True when :func:diff_bgplay found no difference at all.
Source code in src/quickrib/observers/bgplay.py
568 569 570 571 572 573 | |
quickrib.observers.bgplay.format_diff(report)
Render :func:diff_bgplay output as human-readable lines.
Source code in src/quickrib/observers/bgplay.py
576 577 578 579 580 581 582 583 584 585 586 | |
Update Classification
quickrib.observers.update_tagger.UpdateTagFlags
Bases: IntFlag
Non-exclusive BGP update tags. One update can have multiple flags simultaneously.
Source code in src/quickrib/observers/update_tagger.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
quickrib.observers.update_tagger.UpdateTagger
Bases: Observer
Tags every update with the BLT classification flags it satisfies.
The tags are returned, not printed: a subclass such as
:class:UpdateTagsCounter accumulates them, and the calling program decides
what to do with the result. Set log_tags to trace individual messages
through logging.DEBUG. That is one record per BGP message, so it is off
by default and belongs on a narrow filter, not a full replay.
Source code in src/quickrib/observers/update_tagger.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
update_announcement(bgpelem, data, old_data)
Calculates non-exclusive tags for an announcement.
Source code in src/quickrib/observers/update_tagger.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
quickrib.observers.update_tagger.UpdateTagsCounter
Bases: UpdateTagger
Counts how often each tag fires, and reports the totals once per window.
Source code in src/quickrib/observers/update_tagger.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
dump(ts)
Return this window's tag totals, and start the next window empty.
Every tag is present, including the ones that did not fire: a caller reading a series wants a zero, not a missing key.
Source code in src/quickrib/observers/update_tagger.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
Anomaly Detection
quickrib.observers.mad.MADConfig
pydantic-model
Bases: BaseModel
Hyper-parameters for a MAD observer.
Show JSON schema:
{
"description": "Hyper-parameters for a MAD observer.",
"properties": {
"window_size": {
"description": "Number of historical snapshots in the window",
"title": "Window Size",
"type": "integer"
},
"H_stats_dampening": {
"default": 0.01,
"description": "Denominator floor for the scoring statistic",
"title": "H Stats Dampening",
"type": "number"
},
"mode": {
"default": "mZ-score",
"description": "Statistic used to compare a snapshot's coefficients to its history",
"enum": [
"Z-score",
"mZ-score"
],
"title": "Mode",
"type": "string"
}
},
"required": [
"window_size"
],
"title": "MADConfig",
"type": "object"
}
Fields:
-
window_size(int) -
H_stats_dampening(float) -
mode(Literal['Z-score', 'mZ-score'])
Source code in src/quickrib/observers/mad.py
124 125 126 127 128 129 130 131 132 133 134 | |
window_size
pydantic-field
Number of historical snapshots in the window
H_stats_dampening = 0.01
pydantic-field
Denominator floor for the scoring statistic
mode = 'mZ-score'
pydantic-field
Statistic used to compare a snapshot's coefficients to its history
quickrib.observers.mad.MADObserver
Bases: Observer
Whole-graph MAD (MADglob).
Source code in src/quickrib/observers/mad.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
dump(ts)
The whole-graph anomaly score for this window, or None until the
history window is full.
Typed as Any because the family disagrees on the shape of a result:
:class:MADStarObserver returns one score per AS. Each subclass says
what it returns.
Source code in src/quickrib/observers/mad.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
quickrib.observers.mad.MADStaticObserver
Bases: MADObserver
Fast approximation (MADstatic): the edge dictionary is frozen at the
first window, so later snapshots are only projected onto that fixed basis
(edges that appear later are ignored).
Source code in src/quickrib/observers/mad.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
dump(ts)
The anomaly score for this window, or None while the window is not
full (or before a non-empty first window has fixed the basis).
Source code in src/quickrib/observers/mad.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
quickrib.observers.mad.MADStarObserver
Bases: MADObserver
Per-AS star sub-graphs (MADstar): an anomaly score per AS per window.
Source code in src/quickrib/observers/mad.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
dump(ts)
This window's anomaly score per AS, empty until the window is full.
Source code in src/quickrib/observers/mad.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
Testing
quickrib.observers.tester.TesterObserver
Bases: Observer
Source code in src/quickrib/observers/tester.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |