Skip to content

Instantly share code, notes, and snippets.

@wader
Created April 3, 2023 10:08
Show Gist options
  • Save wader/0e0257e04aedd29e5a278cb801ae3e4c to your computer and use it in GitHub Desktop.
Save wader/0e0257e04aedd29e5a278cb801ae3e4c to your computer and use it in GitHub Desktop.
jq syslog parser
def from_syslog:
( split("\n")
| map(
( capture("^(?<ts>\\w{3}\\s+\\d{1,2} +[\\d:]+) (?<host>\\w+) (?<process>\\w+)\\[(?<pid>\\d+)\\]: (?<message>.*)$")
| .ts |= strptime("%b %d %H:%M:%S")
| .pid |= tonumber
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment