Observability · Analytics

All events. Your backend.

Every plugin, workflow, and service emits events through a single IAnalytics interface. DuckDB, SQLite, or flat file — data stays local, no third-party SaaS in the path.

Event tracking

One line in manifest. Analytics in every plugin.

Set analytics: true in permissions and useAnalytics() from the SDK — or ctx.platform.analytics — is available anywhere in the plugin. Event schema kb.v1: type, ts, source, runId, actor, ctx, payload.

The platform enriches context automatically — product, version, runId. Plugins only supply the meaningful fields.

typescript
// В любом плагине — через SDK // i18n-ignore
import { useAnalytics } from '@kb-labs/sdk';

const analytics = useAnalytics();

await analytics.track('commit.plan.generated', {
  scope:             'root',
  filesChanged:      14,
  commitsGenerated:  3,
  llmUsed:           true,
  tokensUsed:        1840,
  durationMs:        4200,
});
Backends

SQLite, DuckDB, or flat file.

Pick the backend in kb.config.json — one line. Data stays local, no external service.

Pino (structured logs)Default. JSON lines, compatible with any log aggregator.
OpenTelemetryExport traces and metrics to Jaeger, Tempo, or OTLP endpoint.
Custom adapterImplement ILogger/IMetrics and bind via kb.config.json.
json
// kb.config.json
{
  "platform": {
    "adapters": {
      "analytics": "@kb-labs/adapters-analytics-sqlite"
    },
    "adapterOptions": {
      "analytics": {
        "filename": ".kb/analytics/analytics.sqlite"
      }
    }
  }
}
Queries

getStats. getDailyStats. breakdownBy on payload.

DuckDB adapter implements full IAnalytics: time-series via date_trunc, group by any payload field using dot notation, filters on type/source/actor/from/to.

REST API exposes the same data via /api/v1/observability/metrics/history for dashboards.

typescript
// getStats() — агрегат по всем событиям // i18n-ignore
const stats = await analytics.getStats();
// {
//   totalEvents: 4821,
//   byType: {
//     "commit.plan.generated": 312,
//     "commit.push.success":   289,
//     "workflow.run.completed": 1840,
//   },
//   bySource: { "commit": 601, "workflow": 1840 },
//   byActor:  { "user:kirill": 4200 },
//   timeRange: { from: "2026-05-01T...", to: "2026-05-24T..." }
// }
Services

kb-monitor — health, logs, exec into container.

For deployed services — a dedicated Go binary. Health checks, streaming logs, exec into containers. Works with any service deployed via kb-deploy.

kb-monitor healthProbe every declared target. Pass/fail with latency.
kb-monitor statusRunning state, uptime, image SHA per target.
kb-monitor logs <target> --followStream live logs from any target. No SSH needed.
kb-monitor status --jsonMachine-readable output for agents and dashboards.
kb-monitor
$ kb-monitor health

  gateway       ✓  healthy   uptime 14d 3h
  rest-api      ✓  healthy   uptime 14d 3h
  workflow      ✓  healthy   uptime  6d 1h
  marketplace   ✓  healthy   uptime  6d 1h
  state         ✓  healthy   uptime 14d 3h

$ kb-monitor logs workflow --follow

  [workflow] 14:23:01 run abc123 started · trigger=manual
  [workflow] 14:23:02 step "checkout" completed [0.3s]
  [workflow] 14:23:08 step "build"    completed [5.9s]
  [workflow] 14:23:09 run abc123 finished · status=success
Self-hosted

Your data. No SaaS in the way.

Analytics adapters ship with the platform. kb-monitor is a standalone Go binary.

Observability — KB Labs