Created
April 3, 2023 10:08
-
-
Save wader/0e0257e04aedd29e5a278cb801ae3e4c to your computer and use it in GitHub Desktop.
jq syslog parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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