SearchFn
Operations

Observability

Structured logging, health checks, and failure classification for SearchFn.

Structured Logging

Pass a logger to createSearchFnServer to receive structured log events for every operation:

const server = await createSearchFnServer({
  adapter,
  logger: {
    info: (msg, ctx) => console.log(JSON.stringify({ level: "info", msg, ...ctx })),
    warn: (msg, ctx) => console.warn(JSON.stringify({ level: "warn", msg, ...ctx })),
    error: (msg, ctx) => console.error(JSON.stringify({ level: "error", msg, ...ctx })),
    debug: (msg, ctx) => console.debug(JSON.stringify({ level: "debug", msg, ...ctx })),
  },
});

Log Events

The server emits these event names:

  • request.start
  • request.end
  • request.error
  • authorization.denied
  • authorization.error
  • server.close

Log Fields

Each log event includes:

FieldTypeDescription
operationstringThe action being performed (search, index, remove, etc.)
adapterstringAdapter name (memory, postgres, meilisearch, etc.)
durationMsnumberTime taken for the operation in milliseconds
statusnumberHTTP status code from the response
successbooleanWhether the operation succeeded
errorCodestring?Error code if the operation failed

Sensitive values are automatically redacted before logging. See Security for details.

Health Endpoint

GET /searchfn/status provides a readiness check for load balancers and monitoring:

{
  "ok": true,
  "result": {
    "adapter": "postgres",
    "capabilities": {
      "persistent": true,
      "searchAll": true,
      "fuzzy": true,
      "fieldBoosts": false
    },
    "uptimeMs": 84200
  }
}

Use this endpoint for:

  • Kubernetes readiness probes
  • Load balancer health checks
  • Monitoring dashboards

Failure Classification

Errors fall into five categories. Use these to build alerts and dashboards:

CategoryError codesCauseAction
ValidationDFQL_INVALID, LIMIT_EXCEEDEDMalformed request or exceeded limitsFix client-side request construction
AuthorizationFORBIDDENAuth callback denied accessCheck credentials and permissions
UnsupportedDFQL_UNSUPPORTEDAdapter doesn't support the operationUse a different adapter or remove unsupported options
RuntimeINTERNALUnexpected backend failureCheck backend health and logs
CancellationDFQL_ABORTEDClient cancelled the requestNo action needed (expected behavior)

Alerting Recommendations

  • Alert on INTERNAL errors — these indicate backend problems that need investigation.
  • Monitor LIMIT_EXCEEDED rates — a spike may indicate a client bug or abuse.
  • Track durationMs percentiles — degrading latency can signal backend capacity issues.
  • Ignore DFQL_ABORTED — these are normal when users navigate away or cancel searches.