Home: one time range across the health block, and failures that follow it
The health screen was fixed at 24 hours everywhere except its lists, which were fixed at nothing: `failuresQueryOptions` read the newest 100 rows and `HealthActivity` filtered them client-side, so on a busy engine the failures list covered whatever few minutes 100 rows happened to span while the chart beside it spanned a day — and pinning an older minute showed an empty card. One `RangePicker` now sits on the Health heading and governs the whole block: the tiles, the flow table, both charts and both lists. Presets are 1h / 6h / 24h / 7d — the collector prunes at `OBS_RETENTION_DAYS` (30), so a week is behind the last one. The longer windows ask for coarser buckets, since a week of minute rollups is ten thousand points nobody can see. Failures get the escape hatch the runs already had: a pinned minute is asked for with `since`/`until` rather than filtered out of what is held, and the list itself is bound to the selected range. `RUN_DEPTH`/`EVENT_DEPTH` become one `LIST_DEPTH`, which now buys coverage of the window on screen instead of a fixed newest-N — narrowing the range is what makes the same rows reach the whole of it. The "Failures (24h)" tile counts errors over the selected window from the rollups the table is drawn from, so tile, column and chart agree. The node-panel and edge trend curves get no picker. They are a Redis ring of the last 120 values per message with no window to ask for, so hovering one reveals what it actually shows — how many readings, and the span they cover.
This commit is contained in:
@@ -3,6 +3,7 @@ import { ChevronDown, ChevronRight, X } from "lucide-react"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import type { EventRow, HistoryPoint } from "@/client"
|
||||
import type { Range } from "@/components/Common/RangePicker"
|
||||
import { UplotChart } from "@/components/Common/UplotChart"
|
||||
import { useEngineEvents } from "@/components/Flow/liveStore"
|
||||
import { PANEL_SECTION } from "@/components/Flow/SidePanel"
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
deadLetterQueryOptions,
|
||||
failuresQueryOptions,
|
||||
healthKeys,
|
||||
minuteFailuresQueryOptions,
|
||||
minuteOf,
|
||||
minuteRunsQueryOptions,
|
||||
runsQueryOptions,
|
||||
@@ -175,22 +177,27 @@ function Failure({ event }: { event: EventRow }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* What the engine has been doing, as charts over a day and the records behind
|
||||
* them.
|
||||
* What the engine has been doing over the selected window, as charts and the
|
||||
* records behind them.
|
||||
*
|
||||
* The two charts each drive the list beside them: throughput picks the runs of
|
||||
* a minute, failures and timing picks that minute's failures.
|
||||
* a minute, failures and timing picks that minute's failures. The window comes
|
||||
* from the health block's one range control, so the lists cover the same span
|
||||
* the charts are drawn from rather than however far their newest rows reach.
|
||||
*/
|
||||
export function HealthActivity() {
|
||||
export function HealthActivity({ range }: { range: Range }) {
|
||||
const live = useEngineEvents()
|
||||
const queryClient = useQueryClient()
|
||||
const runsAt = useMoment()
|
||||
const failuresAt = useMoment()
|
||||
|
||||
const { data: series } = useQuery(timeseriesQueryOptions())
|
||||
const { data: runs } = useQuery(runsQueryOptions())
|
||||
const { data: series } = useQuery(timeseriesQueryOptions(range))
|
||||
const { data: runs } = useQuery(runsQueryOptions(range))
|
||||
const { data: pinnedRuns } = useQuery(minuteRunsQueryOptions(runsAt.pinned))
|
||||
const { data: failures } = useQuery(failuresQueryOptions())
|
||||
const { data: failures } = useQuery(failuresQueryOptions(range))
|
||||
const { data: pinnedFailures } = useQuery(
|
||||
minuteFailuresQueryOptions(failuresAt.pinned),
|
||||
)
|
||||
const { data: audit } = useQuery(auditQueryOptions())
|
||||
const { data: dead } = useQuery(deadLetterQueryOptions())
|
||||
|
||||
@@ -219,8 +226,8 @@ export function HealthActivity() {
|
||||
|
||||
// A pin is read back from the server, so it reaches a minute the recent list
|
||||
// is nowhere near deep enough to hold. A hover stays the client-side preview
|
||||
// it is: scrubbing a day's chart would otherwise be a request per minute the
|
||||
// pointer rests on.
|
||||
// it is: scrubbing a whole window's chart would otherwise be a request per
|
||||
// minute the pointer rests on.
|
||||
const shownRuns =
|
||||
runsAt.pinned !== null
|
||||
? (pinnedRuns ?? [])
|
||||
@@ -228,9 +235,13 @@ export function HealthActivity() {
|
||||
? (runs ?? []).slice(0, RUNS_SHOWN)
|
||||
: (runs ?? []).filter((run) => minuteOf(run.started_at) === runsAt.at)
|
||||
const shownFailures =
|
||||
failuresAt.at === null
|
||||
? (failures ?? []).slice(0, FAILURES_SHOWN)
|
||||
: (failures ?? []).filter((event) => minuteOf(event.ts) === failuresAt.at)
|
||||
failuresAt.pinned !== null
|
||||
? (pinnedFailures ?? [])
|
||||
: failuresAt.at === null
|
||||
? (failures ?? []).slice(0, FAILURES_SHOWN)
|
||||
: (failures ?? []).filter(
|
||||
(event) => minuteOf(event.ts) === failuresAt.at,
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -329,8 +340,10 @@ export function HealthActivity() {
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{failuresAt.at === null
|
||||
? "Nothing has failed in the last day."
|
||||
: "Nothing failed in this minute."}
|
||||
? `Nothing has failed in the last ${range.label}.`
|
||||
: failuresAt.pinned !== null
|
||||
? "Nothing failed in this minute."
|
||||
: "No failure from this minute is in the recent list."}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user