mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-03 00:52:32 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
3.4 KiB
3.4 KiB
Query server/infrastructure metrics (OTel- or Prometheus-ingested) as bucketed time series. The response is a list of series — {labels, points: [{time, value}], metric_name, clause} — where every series shares one time grid (missing buckets are zero-filled). A single ungrouped query returns exactly one series with empty labels.
All parameters are nested inside a query object. Two request forms:
- Single metric (shorthand): set
metricName(+aggregation,filters,groupBy). - Multi-clause / formula: set
clauses: [{name, metricName, aggregation, quantile?, filters?, groupBy?}, ...]and optionallyformula(e.g."(a - b) / a"over clause names;+ - * /and parentheses; division by zero yields 0). With a formula set, only the formula result series are returned.
Workflow — follow this order every time
- Discover names first. Call
metric-names-listwith a substring (value) before querying — metric names must match exactly, and the returnedmetric_typetells you the right aggregation. - Pick the aggregation by metric type:
sumcounters (usually_total): userate(per-second) orincrease— both are counter-reset safe and temporality-aware. Do NOT usesum/avgon cumulative counters; absolute counter values are meaningless.gauge:avg(typical),p95,sum.histogram:histogram_quantilewithquantile(e.g. 0.95). All selected series must share one bucket layout — narrow withfiltersif you get a bounds-mismatch error.
- Narrow with filters.
filters: [{key, op, value, scope?}], ANDed. Ops:eq,neq,regex,not_regex(RE2). Leavescopeat its defaultautounless you know whether the attribute is per-target (resource) or per-datapoint (attribute). Negative ops also match rows lacking the key, like Prometheus negative matchers. - Split with groupBy.
groupBy: [{key}]returns one series per label value (capped at the 100 largest). The service name is always available —service_nameandservice.nameboth resolve to it in metrics (logs only accept the dottedservice.name); discover other keys from a sample query's labels or ask the user. - Control the grid with
interval. One ofsecond, minute, minute_5, minute_15, hour, hour_6, day, week. Omit to auto-pick (~60 buckets across the range). Use the same interval when comparing windows.
Investigating an anomaly ("metric X is rising — why?")
- Query the metric over a window that includes the anomaly AND an equal-length healthy baseline before it (one call, auto interval).
- Find the onset: the first bucket where the value clearly departs from the baseline range.
- Re-query grouped by
service_name(then by other candidate keys) over the same window to see WHICH series moved — a single label value moving points at the culprit; all moving together points at something shared (upstream dependency, infra). - Use
formulafor normalized comparisons, e.g. error ratioerrors / requestsinstead of raw error counts. - Correlate the onset window across signals: query logs (
query-logs, filtered to the sameservice.nameand time window, severity error) and traces (APM span tools, same service/window) to find the cause and its blast radius.
CRITICAL: be minimalist — only include filters/settings essential to the question. Time ranges: dateFrom is required, ISO 8601; dateTo defaults to now.