Skip to content

Instantly share code, notes, and snippets.

@suhlig
Created July 27, 2024 17:30
Show Gist options
  • Save suhlig/c432cb5b4f87e9f491bafd2cbccbefc1 to your computer and use it in GitHub Desktop.
Save suhlig/c432cb5b4f87e9f491bafd2cbccbefc1 to your computer and use it in GitHub Desktop.
Systemd can print logs as JSON, making custom log formats simple. In addition, if the messages themselves are JSON, jq can unescape them.
$ journalctl -u concourse-web -f -o json | jq '.MESSAGE | fromjson'
{
  "timestamp": "2024-07-27T17:29:50.525878425Z",
  "level": "info",
  "source": "atc",
  "message": "atc.scanner.tick.start",
  "data": {
    "session": "23.37"
  }
}
{
  "timestamp": "2024-07-27T17:29:50.542058050Z",
  "level": "info",
  "source": "atc",
  "message": "atc.scanner.tick.end",
  "data": {
    "session": "23.37"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment