Created
May 30, 2025 16:34
-
-
Save hoel-zr-o/a04d5f4e59acaf2077ff8c3c3f1e68c6 to your computer and use it in GitHub Desktop.
Some jq functions
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 parse_duration: | |
[scan("(?:(\\d+)m)|(?:(\\d+[.]\\d+)s)|(?:(\\d+[.]\\d+)ms)") | (60000 * ((.[0] // "0") | tonumber)) + (1000 * ((.[1] // "0") | tonumber)) + ((.[2] // "0") | tonumber) ] | reduce .[] as $item (0; . + $item) ; | |
def logfmt: | |
[ scan("(\\w+)=(?:(?:\"([^\"]+)\")|(\\S+))\\s*") | {key: .[0], value: (.[1] // .[2])}] | from_entries ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment