Skip to content

Commit 08dc291

Browse files
committed
1 parent 4e6e93b commit 08dc291

29 files changed

+176
-168
lines changed

cloud/api.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,8 @@ <h3 id="create-and-wait"><a class="header" href="#create-and-wait">Create and Wa
298298
redisctl api cloud get /tasks/$TASK_ID -q 'response.resourceId'
299299
</code></pre>
300300
<h3 id="bulk-operations"><a class="header" href="#bulk-operations">Bulk Operations</a></h3>
301-
<pre><code class="language-bash"># Get all database IDs
302-
DBS=$(redisctl api cloud get /subscriptions/123/databases -q '[].databaseId')
303-
304-
# Process each
305-
for db in $(echo $DBS | jq -r '.[]'); do
301+
<pre><code class="language-bash"># Get all database IDs and process each
302+
for db in $(redisctl api cloud get /subscriptions/123/databases -q '[].databaseId' --raw); do
306303
redisctl api cloud get /subscriptions/123/databases/$db
307304
done
308305
</code></pre>

cloud/commands/databases.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,8 @@ <h3 id="import-data"><a class="header" href="#import-data">Import Data</a></h3>
334334
</code></pre>
335335
<h2 id="common-patterns"><a class="header" href="#common-patterns">Common Patterns</a></h2>
336336
<h3 id="get-connection-string"><a class="header" href="#get-connection-string">Get Connection String</a></h3>
337-
<pre><code class="language-bash">DB=$(redisctl cloud database get 123456:789)
338-
ENDPOINT=$(echo $DB | jq -r '.publicEndpoint')
339-
PASSWORD=$(echo $DB | jq -r '.password')
337+
<pre><code class="language-bash">ENDPOINT=$(redisctl cloud database get 123456:789 -q 'publicEndpoint')
338+
PASSWORD=$(redisctl cloud database get 123456:789 -q 'password')
340339
echo "redis://:$PASSWORD@$ENDPOINT"
341340
</code></pre>
342341
<h3 id="monitor-databases"><a class="header" href="#monitor-databases">Monitor Databases</a></h3>
@@ -346,8 +345,8 @@ <h3 id="monitor-databases"><a class="header" href="#monitor-databases">Monitor D
346345
-o table
347346
</code></pre>
348347
<h3 id="bulk-operations"><a class="header" href="#bulk-operations">Bulk Operations</a></h3>
349-
<pre><code class="language-bash"># List all database IDs
350-
for db in $(redisctl cloud database list -q "[].databaseId" | jq -r '.[]'); do
348+
<pre><code class="language-bash"># Process all database IDs
349+
for db in $(redisctl cloud database list -q '[].databaseId' --raw); do
351350
echo "Processing $db"
352351
done
353352
</code></pre>

cloud/commands/networking.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ <h3 id="set-up-aws-vpc-peering"><a class="header" href="#set-up-aws-vpc-peering"
261261
}' --wait)
262262

263263
echo "Accept peering request in AWS Console"
264-
echo "Peering ID: $(echo $PEERING | jq -r '.vpcPeeringId')"
264+
echo "Peering ID: $(redisctl cloud vpc-peering list --subscription 123456 -q '[0].vpcPeeringId')"
265265
</code></pre>
266266
<h3 id="list-all-network-connections"><a class="header" href="#list-all-network-connections">List All Network Connections</a></h3>
267267
<pre><code class="language-bash"># VPC peerings

cloud/commands/subscriptions.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,16 @@ <h2 id="related-commands"><a class="header" href="#related-commands">Related Com
348348
</ul>
349349
<h2 id="common-patterns"><a class="header" href="#common-patterns">Common Patterns</a></h2>
350350
<h3 id="list-all-databases-across-subscriptions"><a class="header" href="#list-all-databases-across-subscriptions">List All Databases Across Subscriptions</a></h3>
351-
<pre><code class="language-bash"># Get all subscription IDs
352-
SUBS=$(redisctl cloud subscription list -q "[].id" | jq -r '.[]')
353-
354-
# List databases for each subscription
355-
for sub in $SUBS; do
351+
<pre><code class="language-bash"># List databases for each subscription
352+
for sub in $(redisctl cloud subscription list -q '[].id' --raw); do
356353
echo "Subscription $sub:"
357354
redisctl cloud database list --subscription $sub
358355
done
359356
</code></pre>
360357
<h3 id="monitor-subscription-usage"><a class="header" href="#monitor-subscription-usage">Monitor Subscription Usage</a></h3>
361358
<pre><code class="language-bash"># Get memory usage across all databases
362-
redisctl cloud subscription get 123456 -q "databases[].{name: name, memory: memoryLimitInGb}" | \
363-
jq -r '.[] | "\(.name): \(.memory)GB"'
359+
redisctl cloud subscription get 123456 \
360+
-q "databases[].{name: name, memory: memoryLimitInGb}" -o table
364361
</code></pre>
365362
<h2 id="troubleshooting"><a class="header" href="#troubleshooting">Troubleshooting</a></h2>
366363
<h3 id="common-issues"><a class="header" href="#common-issues">Common Issues</a></h3>

cloud/workflows.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,8 @@ <h2 id="comparison-workflow-vs-manual"><a class="header" href="#comparison-workf
290290
--memory-limit-in-gb 10 --create-database --database-name cache
291291
</code></pre>
292292
<p><strong>Manual equivalent:</strong></p>
293-
<pre><code class="language-bash"># 1. Create subscription
294-
SUB=$(redisctl cloud subscription create --data '{...}' --wait)
295-
SUB_ID=$(echo $SUB | jq -r '.id')
293+
<pre><code class="language-bash"># 1. Create subscription and get ID
294+
SUB_ID=$(redisctl cloud subscription create --data '{...}' --wait -q 'id')
296295

297296
# 2. Wait for active status
298297
while [ "$(redisctl cloud subscription get $SUB_ID -q 'status')" != "active" ]; do

common-features/output-formats.html

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,31 @@ <h2 id="combining-with-jmespath"><a class="header" href="#combining-with-jmespat
221221
</code></pre>
222222
<h2 id="use-cases"><a class="header" href="#use-cases">Use Cases</a></h2>
223223
<div class="table-wrapper"><table><thead><tr><th>Format</th><th>Best For</th></tr></thead><tbody>
224-
<tr><td>JSON</td><td>Scripting, piping to <code>jq</code>, CI/CD</td></tr>
224+
<tr><td>JSON</td><td>Scripting, CI/CD pipelines</td></tr>
225225
<tr><td>Table</td><td>Interactive use, quick overview</td></tr>
226226
<tr><td>YAML</td><td>Config files, readable structured data</td></tr>
227227
</tbody></table>
228228
</div>
229-
<h2 id="piping-to-other-tools"><a class="header" href="#piping-to-other-tools">Piping to Other Tools</a></h2>
230-
<pre><code class="language-bash"># Parse with jq
231-
redisctl cloud database list | jq '.[0].name'
229+
<h2 id="using-jmespath-queries"><a class="header" href="#using-jmespath-queries">Using JMESPath Queries</a></h2>
230+
<p>Use the built-in <code>-q/--query</code> flag for filtering and transforming output without external tools:</p>
231+
<pre><code class="language-bash"># Get first database name
232+
redisctl cloud database list -q '[0].name'
232233

233234
# Count items
234-
redisctl enterprise database list | jq 'length'
235+
redisctl enterprise database list -q 'length(@)'
235236

236-
# Convert to CSV
237-
redisctl cloud subscription list -o json | jq -r '.[] | [.id, .name] | @csv'
237+
# Get specific fields from all items
238+
redisctl cloud subscription list -q '[].{id: id, name: name}'
239+
240+
# Filter by condition
241+
redisctl enterprise database list -q "[?status=='active'].name"
242+
243+
# Get raw values for shell scripts (no JSON quotes)
244+
redisctl cloud database list -q '[0].name' --raw
238245
</code></pre>
246+
<blockquote>
247+
<p><strong>Note</strong>: JMESPath is built into redisctl, so you don't need external tools like <code>jq</code> for most operations.</p>
248+
</blockquote>
239249

240250
</main>
241251

cookbook/cloud/backup-restore.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,11 @@ <h3 id="scenario-2-point-in-time-recovery"><a class="header" href="#scenario-2-p
323323
</code></pre>
324324
<h3 id="scenario-3-clone-production-to-staging"><a class="header" href="#scenario-3-clone-production-to-staging">Scenario 3: Clone Production to Staging</a></h3>
325325
<p>Use backups to create staging environments:</p>
326-
<pre><code class="language-bash"># Get latest production backup
326+
<pre><code class="language-bash"># Get latest production backup using JMESPath
327327
BACKUP_ID=$(redisctl cloud database backup-status \
328328
--database-id 42:12345 \
329-
-o json \
330329
-q 'last_backup.backup_id' \
331-
| jq -r '.')
330+
--raw)
332331

333332
# Create staging database from production backup
334333
redisctl cloud database create \
@@ -424,6 +423,7 @@ <h3 id="pre-deployment-backup"><a class="header" href="#pre-deployment-backup">P
424423
--wait \
425424
-o json)
426425

426+
# Extract backup_id using jq (result is JSON from redisctl)
427427
BACKUP_ID=$(echo "$BACKUP_RESULT" | jq -r '.backup_id')
428428

429429
echo "Backup created: $BACKUP_ID"
@@ -480,17 +480,18 @@ <h3 id="alert-on-backup-failures"><a class="header" href="#alert-on-backup-failu
480480
--database-id ${SUBSCRIPTION_ID}:${DATABASE_ID} \
481481
-o json)
482482

483+
# Parse JSON output with jq
483484
LAST_BACKUP_TIME=$(echo "$BACKUP_STATUS" | jq -r '.last_backup.timestamp')
484-
BACKUP_STATUS=$(echo "$BACKUP_STATUS" | jq -r '.last_backup.status')
485+
LAST_BACKUP_STATUS=$(echo "$BACKUP_STATUS" | jq -r '.last_backup.status')
485486

486487
# Calculate age in hours
487488
CURRENT_TIME=$(date +%s)
488489
BACKUP_TIME=$(date -d "$LAST_BACKUP_TIME" +%s)
489490
AGE_HOURS=$(( ($CURRENT_TIME - $BACKUP_TIME) / 3600 ))
490491

491-
if [ "$BACKUP_STATUS" != "completed" ] || [ $AGE_HOURS -gt $MAX_AGE_HOURS ]; then
492+
if [ "$LAST_BACKUP_STATUS" != "completed" ] || [ $AGE_HOURS -gt $MAX_AGE_HOURS ]; then
492493
echo "ALERT: Backup health check failed!"
493-
echo "Status: $BACKUP_STATUS"
494+
echo "Status: $LAST_BACKUP_STATUS"
494495
echo "Age: $AGE_HOURS hours"
495496
# Send alert (email, Slack, PagerDuty, etc.)
496497
exit 1

cookbook/cloud/configure-acls.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,24 +441,24 @@ <h2 id="using-configuration-files"><a class="header" href="#using-configuration-
441441
}
442442
EOF
443443

444-
# Create rules
445-
jq -r '.rules[] | @json' acl-setup.json | while read rule; do
444+
# Create rules - using jq to extract JSON objects from array
445+
for rule in $(jq -c '.rules[]' acl-setup.json); do
446446
redisctl cloud acl create-redis-rule \
447447
--subscription 42 \
448448
--data "$rule" \
449449
--wait
450450
done
451451

452452
# Create roles
453-
jq -r '.roles[] | @json' acl-setup.json | while read role; do
453+
for role in $(jq -c '.roles[]' acl-setup.json); do
454454
redisctl cloud acl create-role \
455455
--subscription 42 \
456456
--data "$role" \
457457
--wait
458458
done
459459

460460
# Create users
461-
jq -r '.users[] | @json' acl-setup.json | while read user; do
461+
for user in $(jq -c '.users[]' acl-setup.json); do
462462
redisctl cloud acl create-acl-user \
463463
--subscription 42 \
464464
--data "$user" \

cookbook/cloud/create-first-database.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ <h3 id="json-output-for-automation"><a class="header" href="#json-output-for-aut
318318
--wait \
319319
-o json)
320320

321-
DB_ID=$(echo "$DB_INFO" | jq -r '.database_id')
321+
DB_ID=$(redisctl cloud database list --subscription $SUB_ID -q '[0].databaseId')
322322
echo "Created database: $DB_ID"
323323
</code></pre>
324324
<h2 id="common-issues"><a class="header" href="#common-issues">Common Issues</a></h2>

cookbook/enterprise/node-management.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,17 @@ <h3 id="node-health-script"><a class="header" href="#node-health-script">Node He
300300
echo "Node Health Report"
301301
echo "=================="
302302

303-
redisctl enterprise node list -o json | jq -r '
304-
.[] |
305-
"Node \(.uid): \(.status) - CPU: \(.cpu_idle)% idle, " +
306-
"Memory: \((.used_memory / .total_memory * 100 | floor))% used, " +
307-
"Shards: \(.shard_count)"
308-
'
303+
# Using JMESPath sprintf() for formatted string output
304+
redisctl enterprise node list -q '
305+
[].sprintf(
306+
`"Node %s: %s - CPU: %.0f%% idle, Memory: %.0f%% used, Shards: %d"`,
307+
uid, status, cpu_idle,
308+
multiply(divide(used_memory, total_memory), `100`),
309+
shard_count
310+
)' --raw
311+
312+
# Alternative: Use JMESPath for structured table output
313+
redisctl enterprise node list -q '[].{node: uid, status: status, cpu_idle: cpu_idle, shards: shard_count}' -o table
309314
</code></pre>
310315
<h3 id="resource-alerts"><a class="header" href="#resource-alerts">Resource Alerts</a></h3>
311316
<pre><code class="language-bash"># Check for nodes with high resource usage

0 commit comments

Comments
 (0)