Skip to main content

jq Command

The jq command filters and processes JSON input.

This command uses the well-known jq JSON processor to manipulate incoming JSON. Please refer to the jq manual for details.

Usage

jq <filter>

Options

OptionDescription
--no-rewriteWhen this option is enabled, the jq filter is not preprocessed by Resoto and given as is to jq.

By default, a jq filter expression is rewritten to match the currently defined section (see Property Path). A filter expression like .foo.bar will be rewritten to .reported.foo.bar. In order to access a property via an absolute path like /metadata.protected, you would need to write ./metadata.protected.

It is possible to use the --no-rewrite option to turn off this rewriting. Resoto will not rewrite the filter expression, sou you would need to pass: {bar: .reported.foo.bar, protected: .metadata.protected}.

Parameters

ParameterDescriptionRequired?Default Value
filterjq filter✔️N/A

Examples

Query EC2 instances and extract only the name property
> search is(aws_ec2_instance) limit 2 | jq .name
​build-node-1
​prod-23
Query EC2 instances and create a new JSON object for each entry with name and owner
> search is(aws_ec2_instance) limit 2 | jq {name: .name, owner: .tags.owner}
​name: build-node-1
​owner: frosty
​---
​name: prod-23
​owner: bog-team