16 Logs

Logs

Every Klok route reports what it does as log events, and an integration that fails at night leaves its story in them. Logs turns those events into transactions you can read: how many start each minute, which failed and which hung, every event of one business flow from the route that started it to the route where it stopped, and Kloker's analysis of why. It is the page to open when someone asks "did last night's export reach Personec?", and the page the analysis mail links to.

  • In the menu: Run → Logs (/logs), with the tabs Live, Problems, Analyses and Settings
  • For: everyone in the tenant reads; developers and admins of the tenant or of a domain ask for analyses; the Tenant Admin changes the settings. A domain role sees the transactions of its own domains, common and public
  • Reads: klok.dev's own database, counted from the log events klok.dev follows on the broker; the analysis settings from tenant klok's ODL

What You See

Every route publishes one log event per status of each invocation, START, any PROGRESS, then exactly one FINISHED or FAILED, as KlokLogEventV4 on the tenant's common namespace. A transaction is every event with one correlation id: the route that started it and every route the message passed on its way. Two readers follow the events: klok.dev counts them into transactions for this page, and klok-egress-opensearch writes them to OpenSearch.

Tab What it holds
Live Transactions started per minute in the last hour, the figures (started, per minute, failed, in progress, hung) and the 200 latest transactions, in every environment or one. A change shows about a second after klok.dev stores it; Pause holds the list while you read. The search box finds a correlation id by its start, a route, a solution, an error code, or a file transfer by its exact file name, flow id or sha256
Problems The Hung transactions (still in progress five minutes after their first event, in the Klok standard) and the Failed ones, each with its analysis
Analyses Kloker's analyses, newest first, with how many later failures of the same error were counted on each (Repeats) and how many people got the mail
Settings When an analysis starts, what Kloker is given, the prompts and who gets the mail

A transaction's status is In progress, Finished, Partly failed (the inbound side ended, but an outbound call failed), Failed or Hung. klok.dev keeps transactions 7 days, their events 72 hours and analyses 30 days, by default. OpenSearch Dashboards, the button on every Logs page, keeps every event and transaction for 30 days, together with what each pod printed to its console; you sign in there with your Klok account (Finding And Searching Logs In OpenSearch Dashboards).

klok.dev follows tenant klok's log events today. Following every tenant's is frontend-klok-dev#51; until then the other tenants' transactions are in Dashboards.

Walkthrough: Find Out Why Last Night's Export Failed

  1. Open Problems. Last night three of the four KLK010 schedule exports ended Partly failed, each already analysed. A KLK007 reconcile above them never ended and is Hung.

  2. Open one of the exports. The transaction's page says what klok.dev counted: the routes it passed (KLK010P2_KonvojScheduleExport, KLK010E2_PersonecScheduleFileOfframp), where it failed and with what error, and In OpenSearch, the query that finds the same events in Dashboards.

  3. Read Events from the top. The export read the schedule from Konvoj and handed it on; the egress rendered the files, then could not log in to the Personec SFTP server. Each of the five retries is a red Progress · out, and then the route gave up with Failed. Open the last event: its Disposition is QUARANTINED, and Quarantine names the message on persistent://klok/hr/PersonnelScheduleExportV1_DLQ, where it waits to be sent again.

  4. Open the analysis under Analyses. Its headline is Kloker's one-sentence answer; What happened, Probable cause and What to do are its parts, each written by the model named beside it, and Mailed to lists who got it: the people of the failed route's project, and any address the settings add.

  5. Check The facts Kloker was given: the transaction, its events, the solution document, the failed route's source code and documentation, earlier analyses, the console lines around the failure and the route's failure history, each with where it came from. The facts are gathered by code before Kloker writes a word. The documentation of a project that only its members or admins read is never among them, since everyone in the domain reads the analysis.

  6. Act on it. Here the likely cause is a password that changed or expired on the SFTP server: a person updates the secret in Vault, tests the login and resends the export from the dead-letter topic. Logs suggests; it changes nothing.

Walkthrough: Ask For An Analysis Yourself

A hung transaction is not analysed by itself in the Klok standard. On Problems, open the row's ⋮ menu and choose Analyse now; on a transaction's own page, Analyse; on an analysis, Analyse again. The analysis page opens at once and says how far it has come: Queued, Gathering facts, Asking Kloker, then Analysed. An analysis you ask for runs whatever the settings say.

Walkthrough: Decide When Kloker Analyses

Settings shows the Klok standard and your tenant's changes to it:

  • When an analysis starts: automatic analyses on or off, the environments, which statuses start one (Failed and Partly failed in the standard, Hung if you add it), how long the same error is counted on the earlier analysis instead of starting a new one, and at most how many an hour.
  • What Kloker is given: the facts asked of the services and how long to wait for them, the console window around the failure, and the facts from klok.dev.
  • Prompts and Mail: the four prompts (headline, summary, cause, actions), which of them go into the mail, which environments are mailed (prod in the standard) and who else gets every mail.
  • Override shows exactly what is stored: only the differences from the standard.

Only a Tenant Admin (or a Klok Framework Admin) saves; everyone else in the tenant reads the page. The next analysis uses what is saved.

What Happens In Git

Nothing on this page writes to Git. Logs is operations, and its records are klok.dev's and the ODL's.

In klok.dev Where it lands Who By hand
Reading Live, Problems, Analyses Nothing: klok.dev's own database, counted from the log events it follows on the broker — Search the correlation id in OpenSearch Dashboards
Analyse, Analyse now, Analyse again An analysis in klok.dev's database; a fact request on the broker; one ai.log-analysis task per prompt in Klok AI; the mail when it is written A developer or admin of the tenant or of one of its domains —
Settings → Save The tenant's override, only the differences, as dev.klok.klok.datamodel.common.klok_log_analysis_v1.KlokLogAnalysisConfigV1 with the tenant as its id, in tenant klok's ODL A Tenant Admin or Klok Framework Admin The same object written to tenant klok's ODL; klok.dev reads a hand-written object within a few minutes
The fix Wherever the cause is: a merge request to the project, a secret in Vault, a resend from the dead-letter topic The people who own them —

See What klok.dev Does In Git for every page.

Who Does What

Automation Kloker You
klok.dev counts the transactions and their status from the log events. It recognises the same error (tenant, environment, route, error code and the message with ids, numbers and times masked) and counts repeats on the earlier analysis; it caps automatic analyses per hour. It gathers the facts, from its own database and from KLK001E3 and KLK001E4 of klok-egress-opensearch, and sends the mail Writes each part of an analysis from the facts: the headline, what happened, the likely cause with its evidence and how sure it is, and what to do first. Kloker-nothink writes most parts, Kloker the cause Decide whether to act and how; fix the cause in the code, the configuration or Vault; resend a quarantined message; decide in Settings what is analysed and who is mailed

See You, The Automation And Kloker.

How It Connects

Logs rests on the broker (Broker): the log events are messages like any other, and a message that fails after its retries waits on the topic's _DLQ. An analysis finds the failed route's source code and documentation through the Context Graph and its solution document through Solutions. File Flows link here with a file's name filled in, and a transaction that belongs to a run links to Process Runs. How The Run Pages Fit Together shows the whole picture.

Read More