@tiens.nguyen/gonext-ollama-cli
v1.0.0
Published
Ships filtered Ollama journald logs from the Ollama box to the GoNext API (Mongo-backed, TTL-bounded) so the web app can show live server activity.
Downloads
83
Readme
gonext-ollama-cli
Runs on the Ollama box (Ubuntu). Tails journalctl -u ollama -f, keeps only the
useful lines (requests, prompt-eval timings, model loads, errors), and ships them in
batches to the GoNext API over HTTPS. The API stores them in MongoDB with a 24h TTL,
and the web app can read them back (GET /api/ollama-logs) to show live server
activity while the agent is thinking.
The box never connects to MongoDB directly — auth is the same worker API key
(X-Worker-Key) the local worker uses, so no new credentials.
Ubuntu ollama box GoNext API web app
journalctl -u ollama -f ──filter──► POST /api/worker/ollama-logs ──► Mongo (ollama_logs, TTL 24h)
GET /api/ollama-logs ◄──────── Thinking panel pollSetup
# 1. Journal access without sudo (once, then re-login)
sudo usermod -aG adm $USER
# 2. Install (Node >= 18)
npm install -g @tiens.nguyen/gonext-ollama-cli
# 3. Configure — worker key from web app: Settings → Worker → reveal key
gonext-ollama-cli set <workerKey> --api-base https://your-gonext-api
# 4. Verify end-to-end (auth + insert)
gonext-ollama-cli test
# 5. Run in the foreground to sanity-check, then install the service
gonext-ollama-cli runRun as a service
See the comments in gonext-ollama-cli.service (user-level systemd unit with
enable-linger so it survives logout).
Tuning
Env vars (or ~/.gonext/ollama-cli.env):
| Var | Default | Meaning |
| --- | --- | --- |
| OLLAMA_LOG_UNIT | ollama | systemd unit to tail |
| OLLAMA_LOG_FILTER | requests/timings/loads/errors | regex of lines worth shipping |
| OLLAMA_LOG_HOST | os.hostname() | host label shown in the web app |
Server side: OLLAMA_LOG_TTL_SECONDS on the API (default 86400) controls how long
lines are kept. Note Mongo TTL values are baked into the index — changing it later
requires dropping the insertedAt index on ollama_logs first.
Behavior notes
- Batches flush every 2s or at 50 lines, whichever comes first.
- If the API is unreachable, lines buffer in memory (drop-oldest beyond 2000) and retry — the daemon never crashes on network errors.
journalctlexiting (rotation, permissions) triggers an automatic re-tail with backoff; it does not kill the daemon.
