Skip to content

Instantly share code, notes, and snippets.

@palashkulsh
Created May 9, 2022 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palashkulsh/2ea98a351404221f1da8c096511fda6c to your computer and use it in GitHub Desktop.
Save palashkulsh/2ea98a351404221f1da8c096511fda6c to your computer and use it in GitHub Desktop.
extracting from jq without creating cross product
https://stackoverflow.com/questions/69973010/how-do-i-avoid-creating-a-cross-product-when-extracting-multiple-sub-elements-fr
cat /tmp/jira.txt | jq '.[] | {key} + (.changelog.histories[] | {created} + (.items[] | {field,fromString,toString})) | select (.field=="status")'
@palashkulsh
Copy link
Author

gojq
find all rules where length of summary is less than 350 characters
trick is to convert to flat and then do the work
gojq --yaml-input '.groups[].rules[] | {alert: .alert, summary: .annotations.summary} | select(.summary | length <350) | .alert ' cart.rules.yml

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