jt-glogarch ← Home GitHub

How jt-glogarch works

Which parts it is made of, where each one runs, what it reads and writes, and the exact path a record takes out of Graylog and back. Everything here describes what the code actually does.

System architecture

One Python service next to Graylog. It reads Graylog through its API and OpenSearch, keeps its own SQLite database and archive files, and writes to Graylog only when you ask it to.

System architecturejt-glogarch.service: one process, user jt-glogarchAdministratorsbrowser, Graylog accountExternal AIMCP clientWeb UI and APIFastAPI · HTTPS 8990SchedulerAPScheduler · cronAudit listenersyslog · UDP 8991MCP endpoint/mcpVerify and cleanupparallel SHA256, retentionSecurity runnerdetectors · SigmaAI chattools · identitiesImporterpreflight · GELF · BulkExporterAPI · OpenSearch DirectHealth guardpace, pause, stop oncePDF reportsheadless ChromiumData Node certificateissue, renew, probeThreat intel and SigmaHQopt-in downloadsNotifier8 channels, 3 languagesDatabase and case evidencejt-glogarch.db · case-evidence/Archive files/data/graylog-archives/*.json.gzSettings and certificatesconfig.yaml · certs/Graylog usersbrowser · API tokensnginxin front of GraylogGraylogREST API · GELF TCP inputOpenSearch or Data Nodescan per shard · _bulkLLM serversOpenAI-compatible · Claude APINotification channelsTelegram · Slack · e-mail …Public feedsSigmaHQ · Spamhaus · Tor · abuse.chjt-ipamhosts, networks · read-only MCPHTTPS 8990Graylog tokenproxiedaccess log by syslogREST API · GELFscan · _bulkchat completionssenddownload, when enabledwhose IP, when onread / write
records and requestscontrol and filesoptionalentry pointsworkers (threads)on diskoutside jt-glogarch

Process, user and files

◉One service

jt-glogarch.service

  • Web UI, API, scheduler, audit listener and MCP share one process
  • Exports, imports and verifies run in worker threads so the web UI stays responsive
  • Only one export per Graylog server at a time; a second request waits or is refused

⚿User and files

jt-glogarch

  • Runs as its own system user, in the systemd-journal group so the System Logs page can read the journal
  • Owns /opt/jt-glogarch (settings, database, certificates) and the archive path
  • Data Node keys: 0600 files in a 0700 folder, never returned by the API

◷Internal jobs

besides your own schedules

  • Daily disk outlook check; Data Node certificate renewal at 04:45
  • Security analysis, weekly summary, threat intelligence and SigmaHQ refresh, only when enabled
  • Identity directory daily while AI chat is on; jt-ipam subnets daily when connected
  • Registered at start and again whenever their settings are saved

Export

Two readers, one writer: both modes stream into hourly .json.gz files and share the same coverage rule, so they can be switched at any time.

Graylog API mode

  1. PlanFrom the resume point, minus covered time; holes from earlier runs (last 7 days) first.
  2. ChunkOne hour per chunk, so a failure costs at most one hour and archives line up.
  3. Page1,000 messages per page; past 10,000 the time window moves forward instead of the offset.
  4. PaceGraylog keeps every search result for 5 minutes; requests slow down as heap after GC rises.
  5. OverflowMore than 10,000 messages in one millisecond: what was read is kept, the millisecond recorded for OpenSearch Direct.
  6. RecordThe hour is sealed and recorded; a cancel discards only the unfinished hour.

OpenSearch Direct mode

  1. IndicesIndices whose time range meets the window; the active write index is skipped until it rotates.
  2. ExcludeCovered time goes into the query as must_not, so archived records are never fetched.
  3. Count_count first, so the scan can prove it returned every document.
  4. ScanOne search_after cursor per shard, pinned to the primary, merged back into time order.
  5. WriteAn hour closes the moment a timestamp crosses it, and is recorded at once.
  6. RefillAPI overflow milliseconds are fetched, minus the IDs the API archive already holds.

Deduplication: one rule

  • One rule decides what is covered, used both in the query and in the per-hour skip: only archives that hold all data for their range count
  • A stream-filtered API archive or a sister index holding a slice of the hour never hides missing data
  • Progress counts written records, so a scan that fetches and discards would show as stuck — the rule above is why it never does

Backpressure: keep Graylog responsive

An export is a guest on Graylog's cluster. It watches the host and gives way.

  1. SampleGraylog's metrics about every 15 seconds, on a fixed cadence independent of chunk size.
  2. HeapHeap after garbage collection, full GCs and GC time — not the raw used/max, which counts garbage.
  3. JournalUncommitted journal entries and the input, process and output buffers, on a sustained rise.
  4. PaceAPI exports wait between pages, from 0 at 70 % up to 5 seconds at 90 %.
  5. PauseUntil the signal drains; the job shows “Paused — source under load”. Unreadable metrics count as pressure.
  6. Stop onceIf it never drains, the run stops once, keeps what it archived, and retries after 60 minutes.

Why: on busy or HDD-backed storage a heavy export loads the same OpenSearch cluster Graylog indexes into, and can wedge Graylog until it is restarted. Every fast path — OpenSearch Direct export and Bulk import included — is throttled the same way; Bulk watches OpenSearch heap and this host’s free memory.

Import

Before anything is sent, the target is checked and prepared; afterwards the result is reconciled.

Preflight, before the first message

  1. ConnectCredentials, cluster health (RED aborts) and a running GELF input.
  2. BaselineIndexer failure count before the import, to compare afterwards.
  3. Field typesRecorded at export, so no archive has to be scanned again.
  4. CapacityRotation and retention of the target set: aborts if retention would delete the imported data.
  5. MappingsFields seen both as numbers and text are pinned to text, and the field limit raised to 10,000.
  6. CycleOne deflector cycle so the new mappings apply, then wait until the new index is ready.

Two ways in

⇄GELF (TCP 32202)

Every message goes through Graylog's input, pipelines, extractors and stream routing again. TCP gives backpressure, so nothing is dropped silently; a reconnect during the send means the result is not called “verified”.

⇶OpenSearch Bulk

Writes through the index set's deflector alias so Graylog finds the data at once, with gl2_message_id as the document ID (no duplicates) and a marker field. The response is checked document by document.

Compliance goal: zero lost messages and zero indexer failures. Archives are read in batches, never loaded whole — customer archives reach 1.2 GB compressed. Import slows down and shrinks its batch when the target’s journal, buffers or heap, or this host’s memory, are under pressure.

Integrity and retention

Every archive can prove it is the file that was written.

  1. WriteThe writer computes SHA256 while it streams the file.
  2. SealWith integrity enabled, a keyed HMAC-SHA256 too; the key comes from JT_HMAC_KEY or a 0600 key file.
  3. LedgerAn independent ledger table, and a manifest you can copy off the box.
  4. VerifyScheduled re-verification with several workers in parallel.
  5. StatusOk, corrupted (SHA256 differs), tampered (HMAC differs) or missing.
  6. Self-healA deleted archive frees its time range, and the next export fetches it again while Graylog still has it.
  • A plain checksum only shows a change against the stored value: whoever edits the file and the database together forges a consistent pair. The keyed HMAC cannot be forged without the key.
  • Honest limit: a key kept on the same box does not stop root. For that, supply the key by environment only and keep the ledger copy elsewhere.
  • Cleanup never deletes a file changed in the last 10 minutes, so a file still being written is safe.

Graylog 7 Data Node (beta)

A Data Node is Graylog-managed OpenSearch that accepts client certificates only. Measured on Graylog 6.3, 7.0, 7.1 and 7.2.

  1. IssuePOST /api/ca/clientcert as a Graylog admin: Graylog's CA signs a 90-day certificate and maps it to all_access.
  2. StoreKey, certificate and CA under certs/datanode/<server>/, replaced atomically.
  3. ConnectEvery OpenSearch connection presents it; the chain is always checked against Graylog's CA.
  4. RenewWhen a third of its lifetime is left, and by a daily job at 04:45.
  5. ProbeBefore each OpenSearch export and Bulk import: refused means re-issue once; unreachable means wait and try again (1, 2, 5 minutes).
  6. Fall backA scheduled run whose certificate still fails runs in API mode and notifies, so archiving never stops.

Each jt-glogarch server gets its own certificate name, so two servers on one cluster never revoke each other. A server with a connected Data Node cannot be deleted before Disconnect.

Security analysis

A scheduled run, off by default, that reads counts from Graylog with the detector's own server connection.

  1. AggregatePOST /api/search/aggregate per probe: grouped counts, never message text.
  2. DetectThresholds per detection; Sigma rules run as converted queries.
  3. LearnNew login sources and unusual volume compare with 7–14 days of history kept in the database.
  4. SuppressSuppressions are applied; they never change what Graylog counts.
  5. ContextTop values per finding: which source reported it, which site, which paths.
  6. Store and notifyIncidents are opened or updated; new or escalated ones notify; an AI verdict may follow, after the notification.
  • Every probe tries several field names and the coverage table reports what is missing: field names are not uniform even on one site
  • Events without the grouping field come back as one “(Empty Value)” row: that is the coverage measure, never an incident
  • Thresholds were calibrated on real data: machine accounts failing all day and constant scanner noise do not open incidents

AI chat

A loop between your question, the model and read-only tools, sized to the model you run.

  1. BudgetThe model's context is read from the server; answer, history and tool results each get a share.
  2. AskThe question goes to the model with the read-only tools it may call.
  3. QueryEach tool call runs as the signed-in user against Graylog and is audited.
  4. ShapeA result too large is kept in memory for 30 minutes and handed over page by page.
  5. GuardA model repeating itself is stopped and asked once more; the same call is never run twice.
  6. AnswerStreamed to the page with every query listed; it keeps running if the page is closed.
  • No write tools exist: the model can read through the tools, never change Graylog
  • Tool results go back to the model marked as data, so text inside a log cannot pose as an instruction
  • The MCP endpoint checks the Graylog token's role, limits requests per token and refuses repeated bad tokens per address
  • Graylog-side tools come from mcp_graylog, embedded unmodified with its version and checksum pinned

Upgrade safety

Customers upgrade unattended and the first scheduled run fires at night with nobody watching. Four rules override convenience.

1Keep the data

A change applied to state written by an older version may only go in the safe direction automatically: a cleanup never starts deleting what the previous version kept.

2Keep it usable

The service must start and serve; /api/health must report the new version before a release counts as done.

3Keep scheduled archiving running

Every schedule must survive and be registered; the first 03:00 run after an unattended upgrade must work.

4Survive an OS upgrade underneath

When Ubuntu moves Python 3.10 → 3.12 the installed package cannot be imported; every step before the reinstall uses only bash and the standard library.

What upgrade.sh does

  1. Back upAn online snapshot of the database (stdlib sqlite3 if the package cannot load).
  2. Updategit pull, or the offline bundle; a clone that diverged from the published history is reset safely.
  3. Reinstallpip install --force-reinstall, so the service never runs stale code.
  4. MigrateMissing database columns and settings are added on start; nothing is removed.
  5. RestartThe service restarts and every schedule is registered again.
  6. Check/api/health must answer with the new version; the PDF engine is tested by rendering a real page.

Boundaries

A tool that reads your whole logging platform should be clear about what it touches.

It writes to Graylog only when you ask

  • Import: messages and the index set, stream, fields it needs
  • Alerting: your chosen notifications, previewed, undoable
  • Packs you install or remove; dashboards and alerts from an AI answer
  • Clearing an import target: only after you type its prefix
  • A Data Node client certificate, when you click Connect

What it does not do

  • No telemetry: only the systems on the home page get data
  • Archives are deleted only by your retention, or by you
  • The AI cannot write: there are no write tools
  • Security analysis reads counts and never message bodies
  • Graylog's internal event index sets cannot be cleared
Open full size
100%