Sensors: per-service and container sensors, pattern-limited tokens, fleet query, steady sampler
- service.<unit>.active|state for services that are enabled, up or failed - containers.* and container.<name>.running|state|health|mem|cpu (cgroup reads, no docker stats) - sensors:read tokens can be limited to ID patterns, enforced on every endpoint and, through the hub's filter header, on managed machines; the header can only narrow - /api/fleet/sensors/query: one shaped query, every machine, one request - the sampler waits what's left of the interval, so 250 ms means 4 a second - Monitors asks for the families it draws instead of * - unpowered hwmon sentinels (-93 °C) are not temperatures Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
4ddf10be51
commit
4c2eb57ea6
@@ -4,7 +4,7 @@ import Sparkline from './Sparkline'
|
||||
import { Loading, Spinner, toast } from './ui'
|
||||
import { fmtMs, useRefreshMs } from './prefs'
|
||||
import { fetchCatalog, fetchHistories, useSensorStream } from './sensors'
|
||||
import { Catalog, MONITOR_HISTORY, MONITOR_SHAPE, Values, sampleOf, seriesOf, stale } from './sampleAdapter'
|
||||
import { Catalog, MONITOR_HISTORY, MONITOR_SHAPE, Values, mergeValues, sampleOf, seriesOf, stale } from './sampleAdapter'
|
||||
import { Widget, WidgetData, WidgetSpec, shapeOf } from './widgets'
|
||||
import WidgetPicker from './WidgetPicker'
|
||||
|
||||
@@ -302,7 +302,7 @@ export default function Dashboard() {
|
||||
// thresholds; one batch of histories to seed the curves; one stream for the values.
|
||||
const catalog = useRef<Catalog>(new Map())
|
||||
const refetching = useRef(false)
|
||||
const stock = useSensorStream<{ v: Values }>(MONITOR_SHAPE, { full: false, everyMs: refreshMs })
|
||||
const stock = useSensorStream<unknown[]>(MONITOR_SHAPE, { full: false, everyMs: refreshMs })
|
||||
const seed = useCallback(async () => {
|
||||
try {
|
||||
catalog.current = new Map((await fetchCatalog()).map((x) => [x.id, x]))
|
||||
@@ -312,8 +312,8 @@ export default function Dashboard() {
|
||||
}, [])
|
||||
useEffect(() => { seed() }, [seed, stock.resumed]) // on load, and again after the page was hidden: the curves have a gap to refill
|
||||
useEffect(() => {
|
||||
const v = stock.data?.v
|
||||
if (!v || catalog.current.size === 0) return
|
||||
if (!stock.data || catalog.current.size === 0) return
|
||||
const v: Values = mergeValues(stock.data)
|
||||
if (stale(v, catalog.current) && !refetching.current) { // something appeared (a disk, an interface): learn its labels
|
||||
refetching.current = true
|
||||
fetchCatalog().then((c) => { catalog.current = new Map(c.map((x) => [x.id, x])) }).catch(() => {}).finally(() => window.setTimeout(() => { refetching.current = false }, 10000))
|
||||
|
||||
Reference in New Issue
Block a user