Analysis Schema Reference
Complete YAML schema for analysis definitions
Analysis definitions live in analysis.d/*.yaml and define scheduled AI analysis jobs that run against ingested data. They share the same AI operation format as source definitions but add scheduling and data query configuration.
schema_version: 1
name: anomaly_detection
display_name: "Anomaly Detection"
enabled: true
schedule:
interval: "5m"
data:
lookback: "1h"
min_records: 10
max_records: 500
layers:
- flights_commercial
- ships
ai:
enabled: true
operations:
- name: detect_anomalies
prompt: >
Analyze the following {{ .RecordCount }} records from the last {{ .Lookback }}...
output_schema:
type: object
properties:
anomalies:
type: array
max_tokens: 2048
temperature: 0.0
Top-level
schema_version
integername
string
requireddisplay_name
stringenabled
boolean
default: falsefalse, the definition is loaded but the scheduler does not run it.Schedule
Defines when the analysis job runs. Exactly one of interval or cron must be set.
schedule.interval
string"5m", "1h", "30s"). Mutually exclusive with cron.schedule.cron
string"*/5 * * * *" for every 5 minutes). Mutually exclusive with interval.interval or cron. Setting both or neither causes a validation error.Data
Defines what data to fetch for analysis. The engine queries the database for entity+observation records matching these criteria and passes them to the AI prompt template.
data.lookback
string
required"1h", "24h"). Only records with timestamps within this window from the current time are included.data.min_records
integer
default: 0data.max_records
integer
default: 5000, the default of 500 is used.data.layers
string[]data.filter
stringentity and observation map variables.data.sql
stringaiquery.ValidateReadOnlySQL (in fetchDataFromSQL) and aborts the run if the query is not read-only. It is not checked at load time, and a definition that sets data.sql fails its run if no query executor is configured.Dedup
Optional deduplication configuration. When set, records that already have recent insights (within the window) are filtered out before calling the LLM, preventing duplicate analysis.
data.dedup.window
string
required"2h"). Records with existing insights newer than this are excluded.data.dedup.key_fields
string[]
requiredAI Operations
The ai section uses the same SourceAIConfig structure as source definitions. See the Source Schema Reference for the full field reference on ai.enabled and ai.operations[].
Output Noise Control and Cross-Layer Refs
Two operations[].output fields are specific to analysis insight storage and are not covered by the source-schema delegation above.
operations[].output.min_attention
stringinfo, low, medium, high, critical (validator oneof). Results below this floor – including absent or unclassified attention, treated as info – are dropped. When results_path resolves to an empty array, the all-clear summary insight is suppressed if a floor is configured. When unset, the engine-wide ai.min_attention default applies (community default: low).operations[].output.ref_fields
object[]Cross-layer entity references. Each entry maps a field in the LLM result item (whose value is an external_id) to an entity in another layer, creating an extra ai_insight_refs row. Both keys are required per entry:
field(string, required) – result-item property holding the external IDlayer_type(string, required) – layer to scope theexternal_idlookup
output:
results_path: "assessments"
ref_fields:
- field: "conflict_external_id"
layer_type: "conflict_events"
Prompt Template Variables
Analysis operation prompts receive an AnalysisPromptData context with these variables:
| Variable | Type | Description |
|---|---|---|
.RecordCount | int | Total number of records in the query result |
.Lookback | string | The lookback duration string |
.Records | []AnalysisRecord | Array of entity+observation records |
.LayerCount | int | Number of distinct layer types in the results |
.LayerStats | []LayerStat | Per-layer statistics |
.OutputSchema | string | The JSON schema string for structured output |
Each AnalysisRecord contains:
| Field | Type | Description |
|---|---|---|
EntityID | string | Internal entity ID |
EntityName | string | Human-readable entity name |
ExternalID | string | External ID from the source |
LayerType | string | Layer type this record belongs to |
Lat | float64 | Latitude |
Lon | float64 | Longitude |
Altitude | float64 | Altitude in meters |
Metadata | map[string]string | Merged entity + observation metadata |
EntityMetadata | map[string]string | Entity-only metadata |
ObsMetadata | map[string]string | Observation-only metadata |
Timestamp | string | Observation timestamp |
CEL Filter Environment
Analysis CEL filters use a different environment from source filters. The available variables are:
| Variable | Type | Description |
|---|---|---|
entity | map[string]dyn | Entity fields including metadata |
observation | map[string]dyn | Observation fields including metadata |
The string extension library is available. Math and time custom functions from source CEL are not available in analysis filters.