The Linux agent captures LLM usage metadata using eBPF socket tracing. It attaches BPF probes to the kernel’s network stack and OpenSSL to extract SNI hostnames from outbound TLS connections — it never blocks traffic and never inspects content.Documentation Index
Fetch the complete documentation index at: https://docs.toktra.dev/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
- Linux kernel 5.10 or later with BTF (BPF Type Format) enabled
- systemd
- Root privileges for installation (required to load BPF programs)
BTF is required for CO-RE (Compile Once, Run Everywhere) compatibility. To check whether your kernel has BTF enabled, run
ls /sys/kernel/btf/vmlinux. If the file exists, your kernel is supported.How it works
The agent consists of two components:- eBPF programs — Seven BPF probes (tracepoints, kprobes, and OpenSSL uprobes) compiled with CO-RE for kernel 5.10+ portability. The probes track outbound TCP connections on port 443, measure bytes sent and received, and extract the TLS SNI hostname via OpenSSL uprobes attached to
libssl.so. The BPF programs never block connections — they only observe and record. - Rust daemon (
toktra-agent) — An async daemon that polls the BPF ring buffer, classifies events against known LLM provider hostnames, batches events (up to 50 events or 5 seconds), and transmits telemetry securely to Toktra over mTLS. The daemon runs as a systemd service.
The eBPF programs operate in observe-only mode. No BPF action ever drops or modifies a packet. All connections proceed normally.
Installation
- Debian / Ubuntu (.deb)
- RHEL / CentOS / Fedora (.rpm)
- From source
Installed paths
| Path | Contents |
|---|---|
/usr/bin/toktra-agent | Rust daemon binary |
/usr/lib/toktra/toktra_socket.bpf.o | Compiled eBPF object file |
/usr/lib/systemd/system/toktra-agent.service | systemd unit file |
/etc/toktra/ | Configuration directory |
Configuration
The agent loads configuration by layering: defaults ←/etc/toktra/agent.conf ← environment variables. Environment variables always take precedence.
Configuration file
Create or edit/etc/toktra/agent.conf (TOML format):
Environment variables
All configuration keys can be overridden with environment variables. Add overrides to/etc/toktra/agent.env (loaded by the systemd unit via EnvironmentFile):
Device enrollment
On first run, the daemon automatically enrolls the device:- Generates an Ed25519 key pair and writes the private key to
/etc/toktra/device.key. - Sends a CSR to the Toktra enrollment endpoint.
- Writes the signed device certificate to
/etc/toktra/device.crt. The certificate is valid for 90 days. - Uses the device certificate for mTLS on all subsequent transmissions.
systemd service
The agent runs as aType=notify systemd service and signals readiness with sd_notify. The unit applies security hardening directives:
Prometheus metrics
The daemon exposes Prometheus-format metrics on127.0.0.1:9090/metrics (configurable with metrics_port). Scrape this endpoint with Prometheus or a compatible collector.
Available metrics:
| Metric | Type | Description |
|---|---|---|
toktra_events_received_total | Counter | Events received from BPF ring buffer |
toktra_events_sent_total | Counter | Events sent to Toktra |
toktra_events_dropped_total | Counter | Events dropped due to overflow or send failure |
toktra_bpf_errors_total | Counter | BPF subsystem errors (load failures, map errors) |
toktra_send_errors_total | Counter | HTTP send errors |
toktra_batch_send_duration_seconds | Histogram | Batch send duration |
toktra_active_connections | Gauge | Connections currently tracked in BPF map |
toktra_buffered_events | Gauge | Events buffered awaiting send |
toktra_circuit_breaker_open | Gauge | Circuit breaker state (1=open, 0=closed) |
osquery extension (fleet-wide queries)
The agent ships a Go osquery table extension (toktra_extension) that exposes a toktra_connections virtual table. Use this with Fleet or Kolide to run fleet-wide LLM usage queries.
/run/toktra/connections.sock to read real-time connection data.
Example queries:
toktra_connections table schema:
| Column | Type | Description |
|---|---|---|
pid | integer | Process ID |
comm | text | Process name |
dst_hostname | text | Destination SNI hostname |
dst_ip | text | Destination IP address |
dst_port | integer | Destination port |
bytes_sent | bigint | Bytes sent |
bytes_received | bigint | Bytes received |
timestamp | bigint | Unix timestamp (nanoseconds) |
provider | text | Identified LLM provider |
category | text | Usage category |