Using CheatSheets To Apply Best Practices

JQ CheatSheet

JQ CheatSheet

1.1 jq basic usage

curl $es_ip:9200/$index_name/_stats?pretty | jq '._all.primaries'

curl $es_ip:9200/$index_name/_stats?pretty | jq '._all.primaries | .docs, .merges, .segments'

curl $es_ip:9200/$index_name/_stats?pretty | jq '.[0] | ._all: promaries}'

curl $es_ip:9200/$index_name/_stats?pretty | jq '._all.primaries.docs[]'

curl $es_ip:9200/$index_name/_stats?pretty | jq '._all.primaries.docs[], ._all.primaries.segments[]'

curl $es_ip:9200/$index_name/_stats?pretty | jq '._all.primaries[]' | jq '.docs'

1.2 jq with watch

watch -n 0.5 "kubectl get configmaps map1 -o json | jq '.data[\"file1.conf\"]'"

watch "curl $es_ip:9200/$index_name/_stats?pretty | jq '._all.primaries | .docs, .merges, .segments'"

1.3 k8s jq

# List pods and containers
kubectl get pods -o='custom-columns=PODS:.metadata.name,CONTAINERS:.spec.containers[*].name'

# List pods, containers and images
kubectl get pods -o='custom-columns=PODS:.metadata.name,CONTAINERS:.spec.containers[*].name,Images:.spec.containers[*].image'

1.4 More Resources

License: Code is licensed under MIT License.

linkedin
github
slack




Leave a Reply

Your email address will not be published. Required fields are marked *