Make ottyl_seq/ottyl_ts usable in dashboard PromQL queries (ticket 055)
evaluate_promql previously resolved every metric name through bucket_values, which only returns data for a real MetricDeclaration — so a dashboard panel querying ottyl_seq/ottyl_ts/ottyl_fmt (already supported in the filter bar and alert conditions) silently returned an empty series. ottyl_seq/ottyl_ts are now synthesized directly from the ingested-log index instead of requiring a declaration; ottyl_fmt is categorical (json/logfmt/none) with no sensible numeric reading, so it's rejected up front with a clear error pointing back at the filter bar rather than returning nothing. GET /api/params now also lists the three reserved names (marked `reserved: true`, distinct from `auto_derived`) purely for discoverability — merged in at the API layer only, not the engine's internal ParamDeclarations query, so profile-switch removal and metric-param-promotion logic are unaffected. declare_param also now rejects declaring a param under one of these names. Docs.tsx and the Params panel are updated to reflect the new dashboard support and the reserved/non-editable listing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
d17cfe9b83
commit
ff56558b2e
@@ -105,6 +105,9 @@ const SECTIONS: DocSection[] = [
|
||||
<Code>ottyl_seq</Code>, <Code>ottyl_ts</Code>, and <Code>ottyl_fmt</Code> are reserved metric names present
|
||||
on every log line, so they're always filterable without declaring anything. <Code>ottyl_fmt</Code> holds the
|
||||
auto-detected format of the line's text — <Code>json</Code>, <Code>logfmt</Code>, or <Code>none</Code>.
|
||||
They also appear (flagged <Code>reserved</Code>) in <Code>GET /api/params</Code> for discoverability, though
|
||||
there's no UI to edit or remove them — see also <em>Dashboards</em> below for using{' '}
|
||||
<Code>ottyl_seq</Code>/<Code>ottyl_ts</Code> in a panel query.
|
||||
</p>
|
||||
<p className="font-semibold text-text">Date/time formats</p>
|
||||
<p>Timestamp comparisons accept three forms:</p>
|
||||
@@ -335,6 +338,14 @@ const SECTIONS: DocSection[] = [
|
||||
Dashboards are saved per profile, so they travel with it when you switch or copy it — an active profile is
|
||||
required to create or save one; pick or create one from the settings menu first.
|
||||
</p>
|
||||
<p>
|
||||
The reserved <Code>ottyl_seq</Code>/<Code>ottyl_ts</Code> names (see <em>Filtering</em> above) work in panel
|
||||
queries the same as any declared metric — e.g. <Code>count(ottyl_seq)</Code> for log volume, or{' '}
|
||||
<Code>rate(ottyl_ts[1m])</Code> for ingest rate — since every log line carries them without a metric
|
||||
declaration. <Code>ottyl_fmt</Code> is categorical (<Code>json</Code>/<Code>logfmt</Code>/<Code>none</Code>
|
||||
), not a number, so it's rejected in a panel query with an explicit error rather than silently charting
|
||||
nothing — filter on it in the filter bar instead.
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -49,6 +49,12 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
|
||||
// original (and anything referencing it by name) rather than renaming it.
|
||||
const [editingName, setEditingName] = useState<string | null>(null)
|
||||
|
||||
// `reserved` params (`ottyl_seq`/`ottyl_ts`/`ottyl_fmt`) are synthesized server-side purely for
|
||||
// discoverability (see `GET /api/params`) — they aren't real declarations, so they're kept out of
|
||||
// the editable/clickable list and shown separately, non-interactively.
|
||||
const declaredParams = useMemo(() => params.filter((p) => !p.reserved), [params])
|
||||
const reservedParams = useMemo(() => params.filter((p) => p.reserved), [params])
|
||||
|
||||
const isBoolean = kind === 'boolean'
|
||||
const isElapsedSinceLast = source === 'elapsed_since_last'
|
||||
// The message match regex doubles as a sample line here so a pasted JSON log line unlocks the
|
||||
@@ -264,8 +270,10 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="mb-1 text-xs text-text-subtle">Declared params</div>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{params.length === 0 && <span className="text-xs text-text-faint">No params declared yet.</span>}
|
||||
{params.map((p) => (
|
||||
{declaredParams.length === 0 && (
|
||||
<span className="text-xs text-text-faint">No params declared yet.</span>
|
||||
)}
|
||||
{declaredParams.map((p) => (
|
||||
<button
|
||||
key={p.name}
|
||||
type="button"
|
||||
@@ -287,6 +295,24 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{reservedParams.length > 0 && (
|
||||
<>
|
||||
<div className="mb-1 mt-2 text-xs text-text-subtle">
|
||||
Reserved (built in — present on every line, not editable)
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{reservedParams.map((p) => (
|
||||
<span
|
||||
key={p.name}
|
||||
className="rounded border border-dashed border-border-soft px-2 py-1 text-xs text-text-faint"
|
||||
title={`${p.name} (${p.kind}, reserved)`}
|
||||
>
|
||||
{p.name} ({p.kind})
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,6 +32,8 @@ export interface ParamDeclaration {
|
||||
kind: 'string' | 'number' | 'timestamp' | 'duration' | 'boolean'
|
||||
/** A third extraction source, distinct from `capture_group`/`json_field_path`: when true, this param's value is never parsed from text — it's computed as elapsed time since the previous event sharing the same label set. Only meaningful paired with `kind: 'duration'`. */
|
||||
elapsed_since_last?: boolean
|
||||
/** Set only for the built-in `ottyl_seq`/`ottyl_ts`/`ottyl_fmt` names, synthesized into `GET /api/params` for discoverability — they're usable in the filter bar (and `ottyl_seq`/`ottyl_ts` in dashboard PromQL queries) without ever being declared, and can't be edited or removed. */
|
||||
reserved?: boolean
|
||||
}
|
||||
|
||||
export interface TimelineBucket {
|
||||
|
||||
Reference in New Issue
Block a user