Audit and lineage
How Goni records every mutating action to a tenant-scoped audit log and how the column-level lineage graph plus metric trust and blame make numbers verifiable.
What this page does for you
Two governance surfaces sit under /govern: an append-only audit log and a column-level lineage graph. Both are tenant-scoped, permission-gated, and grounded in the compiled semantic project.
You’ll learn:
- How to query the audit log from
/api/auditand export it for compliance sweeps.- Which endpoints emit audit events and how secrets are redacted on the way out.
- How to read the column-level lineage graph, the metric trust overlay, and the metric blame view.
- How business-glossary term assignments hang off the same lineage nodes.
Audit log
The query surface
The BI API exposes one endpoint for reading the log:
GET /api/audit?user=&action=&kind=&origin=&workspace=&from=&to=&limit=&cursor=&format=
Every call goes through three gates before it reads the log:
- The audit service must be initialised. A 503 comes back if it is not.
- The caller must hold
allow_admin_policies. This is the real admin capability, notallow_delete(which any content-editor role can hold). Callers without it get a 403 with the message “reading the audit log requires allow_admin_policies”. - Every query is scoped to the caller’s tenant from the JWT claims. There is no cross-tenant read path, even on shared-warehouse deployments.
Filters are optional: user, action, kind, origin, workspace, and a time window in RFC3339 (from, to). Bad timestamps surface as 400. Effective limit is clamped to [1, 1000] with a default of 200.
originaccepts one of the emitted provenance tags:user(a human interactive request, the default),ai:<playbook-id>(one ofai:data-analyst,ai:data-engineer,ai:data-architect,ai:diagnostic), orsystem:<subsystem>(server-side jobs:system:scheduler,system:retry,system:migration,system:mcp). Rows written before origin attribution was added carry the defaultuser. Example:?origin=ai:data-analystreturns only rows a chat-authored mutation produced.workspacescopes the returned rows to a specific workspace.?workspace=<id>requires the caller to be a member of that workspace (403 otherwise).?workspace=allopts back into the cross-workspace view (still gated byallow_admin_policies). Omitting the parameter defaults toallfor back-compat with the pre-filter/auditUI; a follow-up flips the default to the caller’s own workspaces once the SPA ships the picker. The gate is applied both up-front (403 on non-member) and post-query (rows whose target does not resolve to the requested workspace are dropped fail-closed). Membership itself is defined by the workspace record - see Access control - Workspaces and membership.
Pagination is opaque-cursor: the response returns next_cursor whenever the page filled, and the client sends it back as cursor for the next page. The cursor is base64url of occurred_at + "|" + event_id so it is decodable server-side but should be treated as a token by callers.
Compliance sweeps that need a spreadsheet export ask for format=csv. The CSV path applies the same tenant, capability, origin, and workspace gates as the JSON path; only the serialisation changes. The header row is 13 columns and mirrors the SELECT projection: event_id, occurred_at, user, roles, action, target_kind, target_id, request_id, ip, user_agent, detail, status, origin. Rows written before origin attribution was added carry user in the trailing column. next_cursor moves to the X-Next-Cursor response header so scripted paginators can still chain requests.
# CSV export scoped to connection mutations from August
curl -s -H "Authorization: Bearer $TOKEN" \
"https://your-goni.example.com/api/audit?kind=connection&from=2026-08-01T00:00:00Z&limit=500&format=csv" \
-o audit-connection-august.csv
# Every mutation the AI data-analyst persona has proposed and applied
curl -s -H "Authorization: Bearer $TOKEN" \
"https://your-goni.example.com/api/audit?origin=ai:data-analyst&limit=500"
# Restrict a sweep to a single workspace
curl -s -H "Authorization: Bearer $TOKEN" \
"https://your-goni.example.com/api/audit?workspace=finance&kind=chart&limit=500"
What gets logged
Every mutating endpoint records an audit event. Actions follow a resource.verb shape. The list below groups the families the BI API emits today; treat it as canonical for the surfaces named, and expect additions as new features land. The audit trail is the source of truth - if a family appears in a log row that is not enumerated here, the row is still authoritative and this doc is the drift that needs fixing.
- Artifact writes -
chart.{put,delete,create,view_sql},dashboard.{put,delete,fork,summary,tile.add},notebook.{put,delete},query.{update,delete,run},alert.{create,update,update.failed,mute,unmute,delete,delete.failed,run},metric.{create,create.failed,update,update.failed,delete,delete.failed},model.{create,create.failed,update,update.failed,delete,delete.failed},report.{create,create.failed,update,update.failed,delete,delete.failed,run},snippet.{add,delete},favorite.{add,remove},comment.add,ai_chat.save.failed. - Ad-hoc SQL -
query.adhoc(everyPOST /api/queryrun, whether it saves a row or not). - Auth -
auth.{login,logout,refresh,tenant.switch,consent.accepted},auth.magic_link.{requested,verified,throttled,request_failed},tenant.member.invite. - Workspace and users -
workspace.{put,delete},user.{enable,disable}. - Policies -
policies.update(write-through onPUT /api/policies). - MCP -
mcp.{describe_metric,list_dimensions,list_metrics,list_playbooks,query_metric,read_catalog,read_playbook,resources_list,list_connections,list_pipelines,list_warehouse_tables,describe_source_table,create_pipeline,list_models,describe_model,create_metric,create_model}. - AI -
ai.ask,ai.chat.dispatch,ai.config.{clear,update},ai.proposal.{list,apply,reject},ai.task.{create,update,run,delete},ai.handoff.create,ai.budget.peek,playbooks.{list,get}. - PAT -
pat.{mint,revoke}.pat.mintalso increments thegoni_security_event_total{event="pat.mint"}Prometheus counter and emits a Warn-level log line - see the observability bullet below. - Streaming -
streaming.subscription.{create,pause,resume,delete,reset-offset},streaming.dlq.{raw_view,redrive,resolve},streaming.orphan_supervisor_terminate. - Bundle -
bundle.{export,import}. - Connections and pipelines -
connection.{get,list,put,test,test-draft,schema,schema.columns,delete,status_changed},pipeline.{put,run,rerun,cancel,restore,purge,rebuild-target,delete}. - Data quality -
data_quality.{run_table,run_all,put_test,delete_test,profile}. - Glossary -
glossary.term.put. - Exports and datasets -
export.{xlsx,pptx},dataset.upload,file.upload. - Rate limiting -
ratelimit.deny(every 429 the ratelimit middleware fires; the security-sensitive trail auditors use to spot credential-stuffing and enumeration attempts). - Ops surfaces -
cache.purge,embed.mint,git.push,warehouse.config.{update,clear},feedback.{submit,status}. - Marketing capture -
marketing.{demo_request,enterprise_inquiry,lead.capture,trial_start,trial_retry}. - Audit side effects (background emitters) -
proposal.apply.status_write_failed,trial.gc,billing.checkout.completed,billing.subscription.{updated,canceled},billing.invoice.{paid,payment_failed},billing.{checkout_session,portal_session}.created.
Each row carries event_id, occurred_at, tenant_id, user, roles, action, target_kind, target_id, request_id, ip, user_agent, detail, origin, and status. origin is one of user, ai:<playbook-id> (ai:data-analyst, ai:data-engineer, ai:data-architect, ai:diagnostic), or system:<subsystem> (system:scheduler, system:retry, system:migration, system:mcp).
Retention
Audit rows live in Goni’s control-plane database, not in your warehouse, and are kept for 730 days (24 months, the SOC 2 baseline). Rows older than 730 days are deleted automatically. No ALTER statement or workspace setting changes this period; a longer period can be agreed in an Enterprise contract. Do not assume rows persist past the two-year mark: export them with /api/audit if you need them longer.
Secrets are redacted on every read
Connection secrets never appear in an audit row’s detail because they never leave the server in the clear. Password, token, and key fields are rewritten to a redaction placeholder plus a stable fingerprint before any response, log line, or audit event serialises. When a caller edits a connection and posts the placeholder back, the update path refills the value from the stored connection instead of writing the placeholder to disk.
Observability
Security-sensitive actions publish a Prometheus counter in addition to the audit row so on-call teams can page on bursts without waiting for the /api/audit query to catch up:
goni_security_event_total{event="pat.mint"}
goni_security_event_total{event="embed.mint"}
goni_security_event_total{event="policies.update"}
goni_security_event_total{event="warehouse.config.update"}
goni_security_event_total{event="warehouse.config.clear"}
goni_security_event_total{event="auth.magic_link.throttled"}
Five event families live today, matched by exact action or by the warehouse.config. prefix (so a future warehouse.config.rotate sub-verb auto-instruments):
pat.mint- Personal Access Token minted viaPOST /api/access_tokens.embed.mint- signed embed token minted viaPOST /api/embed/token.policies.update- RBAC policy YAML written viaPUT /api/policies.warehouse.config.*- warehouse credentials updated or cleared via the workspace warehouse settings endpoints.auth.magic_link.throttled- a magic-link request was rejected because the requester crossed the per-address rate cap; a burst is the credential-stuffing signal.
Every increment pairs with a Warn-level log line carrying the actor, target, and any relevant secondary identifiers (jti for PATs, dashboard id for embed tokens, actor for policies and warehouse config). When GONI_SECURITY_ALERT_WEBHOOK_URL is configured, each event also fans out to that webhook as a signed JSON payload; when it is empty, the counter and log still fire so on-call keeps the signal even without a webhook. Wire an alert on a sudden acceleration of any series (for example a five-minute rate that crosses your baseline by more than 3-sigma) to catch credential-provisioning attacks without hand-writing an audit-log query.
The counter is scraped at GET /metrics alongside the rest of the BI API’s Prometheus surface. See Environment variables for how to wire it into your existing scrape target.
Lineage
The column-level graph
GET /api/lineage
The response is the compiled semantic project’s lineage map, filtered to the caller’s allow_models. Each model entry has upstream_models, upstream_sources, and a columns map from output column to the upstream columns it depends on.
The graph is built at semantic-layer compile time. Every compiled ClickHouse SQL model is parsed and walked, and Goni records: table refs to upstream models or sources, and per-projection output name to the underlying alias.column references. The compiled lineage is loaded at Goni startup.
Two RBAC rules govern reads:
- Anonymous callers get a 401. Lineage names are treated as pre-attack recon material.
- Models the caller cannot see are stripped from the top-level map and also from every visible model’s
upstream_models, so a visible mart never reveals the names of restricted staging models it joins to.
curl -s -H "Authorization: Bearer $TOKEN" \
https://your-goni.example.com/api/lineage | jq '.lineage.fct_subscriptions.columns.arr_eur'
# ["stg_subscriptions.mrr_eur"]
If lineage has not compiled yet, the endpoint returns a 503 with the reason “lineage is not available yet - the semantic layer has not finished compiling”. No devops command is surfaced to the caller.
Metric trust overlay
GET /api/metric/{name}/trust
The trust overlay assembles four pieces into one response so an analyst can answer “why should I trust this number”:
- The metric definition and the compiled ClickHouse SQL that produces the value.
- The column-level lineage upstream to source tables.
- Recent semantic-test outcomes against the underlying model: totals, last failure, per-test detail.
- The most recent ETL timestamp from the source rows.
The endpoint enforces the same allow_metrics gate as /api/metric/{name}/query, so a metric hidden from a viewer does not leak its formula through the trust overlay either. See access control for how allow_metrics composes with allow_models.
Metric blame
GET /api/metric/{name}/blame
Blame returns line-level git blame for the YAML stanza that defines the metric, so users can see who last touched the formula, on which commit, and when. It reads from the semantic project location. When it is unavailable the endpoint returns {available: false} with a reason field, so the Lineage page can render a degraded state rather than a misleading 500.
Business glossary on lineage nodes
The glossary sits on the same governance layer. Terms live in your semantic project’s glossary/<workspace>/ directory and are edited through /api/glossary/terms. Every term carries a status (draft, review, approved, deprecated) whose transitions are role-gated by the state machine documented on the Business glossary page: authors move draft to review; reviewers can fast-track draft to approved and are the only role that can approve a term out of review; owners can deprecate from any state and can bounce an approved term back to review; un-deprecation to approved requires the caller to hold BOTH owner and reviewer roles. Assignments hang off any lineage node under a typed key:
GET /api/glossary/assignments/{kind}/{id}
PUT /api/glossary/assignments/{kind}/{id}
POST /api/glossary/assignments/batch
GET /api/glossary/terms/{id}/usages
kind is validated against a closed allow-list so typos never create stray buckets. The current allow-list is seven kinds; id is opaque and each kind picks the id format that makes sense for that surface:
| Kind | id format | Example |
|---|---|---|
column | <database>.<table>.<column> | analytics.fct_subscriptions.arr_eur |
table | <database>.<table> | analytics.fct_subscriptions |
model | <model_name> | fct_subscriptions |
metric | <metric_name> | active_arr |
chart | <chart_id> | weekly-arr-by-country |
dashboard | <dashboard_id> | exec-weekly-nps |
notebook | <notebook_id> | arr-decomposition |
The GET /api/glossary/assignments/{kind}/{id} response hydrates the attached terms in a single pass so a column drawer open does not fan out into N filesystem walks. The reverse-lookup /api/glossary/terms/{id}/usages returns the asset keys a given term is attached to, grouped by kind, so a user viewing a term can jump to every dashboard or column that references it.
When an analyst opens a column drawer with no terms attached, the picker calls:
GET /api/glossary/suggest/column/{database}/{table}/{column}
Suggestions rank by fuzzy token similarity between the column name and every term’s name, id, and synonyms. The scorer is Jaccard on token sets (scoreWord matches whole tokens across both name and synonym surfaces; scoreSyn runs the same Jaccard against each synonym string one at a time) plus a +0.3 substring bonus (scorePartial) when either the column string contains the candidate string or vice versa. Terms below a 0.34 minimum-score threshold are dropped, and single-token candidate names are also dropped when the column has more than one token so a term named simply “Customer” doesn’t Jaccard-1.0 match every *_id / customer_* column and flood the Suggested chips row.
The candidate pool includes ALL statuses except deprecated: a draft or review term in progress is still useful to attach in one click, but attaching a deprecated term to a fresh column would perpetuate the obsolete reference the deprecation was meant to retire. The endpoint oversamples 4x the visible cap and then post-filters by workspace access so callers who cannot see N-1 workspaces still get up to five accessible suggestions.
Related
- Tests, freshness, and data quality - the semantic tests that populate the trust overlay.
- Data quality governance - RBAC, custom_sql authorship, and how
data_quality.*events surface in this log. - Metrics - what a metric is and where its YAML lives.
- SQL IDE - the query surface that logs
query.runevents. - Audit and Tags API - endpoint-level reference for
GET /api/audit(filters, CSV export, origin taxonomy) andGET /api/tags. - REST API - full endpoint reference including trust, blame, and glossary.
- Business glossary - term shape, status state machine, workspace scoping, and how approved terms staple into Ask grounding.
- Environment variables - audit and lineage settings.
Last updated