Skip to content

Show the real alert total and make dashboard updates visible - #109

Draft
DrisDary wants to merge 1 commit into
mainfrom
fix/eventhubs-dashboard-totals
Draft

Show the real alert total and make dashboard updates visible#109
DrisDary wants to merge 1 commit into
mainfrom
fix/eventhubs-dashboard-totals

Conversation

@DrisDary

Copy link
Copy Markdown
Contributor

Motivation

Two problems surfaced while demonstrating the Event Hubs sample, both of which make the dashboard actively misleading rather than merely plain.

The fraud alert count sat at 25 and never moved, no matter how many alerts were generated. It was not a stuck counter: the headline number was rendering the length of the recent-alerts list below it, which is capped at 25. So the sample's central claim — that fraud alerts accumulate as suspicious payments arrive — silently stopped being demonstrable exactly when it got interesting.

Second, a refresh that changed something looked identical to one that changed nothing. With the page polling on a timer, there was no way to tell which numbers had moved, or whether the pipeline was doing anything at all.

Changes

  • Added hub_total(), which reads the true event count for a hub from partition runtime metadata (summing last_enqueued_sequence_number + 1 across partitions). This does not consume events and is not bounded by any page size — counting by reading the hub would not scale and would reintroduce the same class of bug. The overview payload now carries total_alerts from it, so the headline figure is the real total.
  • The "Fraud alerts" card header now reads "(25 most recent)", making explicit that the list is a page while the headline stat is the total. That distinction is what was missing.
  • Headline numbers flash when they change and show a +N delta badge for a few seconds, via a small setStat() helper and two CSS rules. Cause and effect are now visible during a demo without watching logs.

Tests

Verified by hand against the running sample: alerts climb past 25 and keep climbing, the total matches the number of alerts actually published, and the flash plus delta badge fire only on refreshes where a value genuinely moved.

hub_total() follows the same except Exception: return <empty> idiom as the four other helpers in app.py, so a transient Event Hubs error degrades the affected figure instead of breaking the page.

Related

Follow-up to the Event Hubs fraud detection sample (#104).

SMF-790

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant