Skip to content

Instantly share code, notes, and snippets.

@flrichar
Created June 7, 2024 15:25
Show Gist options
  • Save flrichar/8f9bfef286f00ddfdddc3a189d41bcd9 to your computer and use it in GitHub Desktop.
Save flrichar/8f9bfef286f00ddfdddc3a189d41bcd9 to your computer and use it in GitHub Desktop.
journal json parsing

K3S Journal JSON Parse

Parse some message fields from k3s' journal logs.

sudo journalctl -u k3s -g detail -n80 -ojson | jq -r '.MESSAGE'  | jq
...
##### Sample output:

{
  "level": "info",
  "ts": "2024-06-07T11:22:24.88894-0400",
  "caller": "traceutil/trace.go:171",
  "msg": "trace[218308905] transaction",
  "detail": "{read_only:false; response_revision:2980995; number_of_response:1; }",
  "duration": "298.040553ms",
  "start": "2024-06-07T11:22:24.590876-0400",
  "end": "2024-06-07T11:22:24.888916-0400",
  "steps": [
    "trace[218308905] 'process raft request'  (duration: 297.803135ms)"
  ],
  "step_count": 1
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment