errose28 commented on code in PR #4157:
URL: https://github.com/apache/ozone/pull/4157#discussion_r1095112749


##########
hadoop-hdds/docs/content/interface/Cli.md:
##########
@@ -207,3 +207,65 @@ $ ozone sh key info /vol1/bucket1/README.md
 ```shell
 $ ozone sh key get /vol1/bucket1/README.md /tmp/
 ```
+
+## Querying Cli Results
+
+Ozone cli returns JSON responses. [jq](https://stedolan.github.io/jq/manual/) 
is a command line JSON processor that can be used to filter cli output for 
desired information.

Review Comment:
   super minor nit but I think capitalizing CLI looks better.



##########
hadoop-hdds/docs/content/interface/Cli.md:
##########
@@ -207,3 +207,65 @@ $ ozone sh key info /vol1/bucket1/README.md
 ```shell
 $ ozone sh key get /vol1/bucket1/README.md /tmp/
 ```
+
+## Querying Cli Results
+
+Ozone cli returns JSON responses. [jq](https://stedolan.github.io/jq/manual/) 
is a command line JSON processor that can be used to filter cli output for 
desired information.
+
+For example:
+
+* List FSO buckets that are not links.
+```shell
+$ ozone sh bucket list /s3v | jq '.[] | select(.link==false and 
.bucketLayout=="FILE_SYSTEM_OPTIMIZED")'
+{
+  "metadata": {},
+  "volumeName": "s3v",
+  "name": "fso-bucket",
+  "storageType": "DISK",
+  "versioning": false,
+  "usedBytes": 0,
+  "usedNamespace": 0,
+  "creationTime": "2023-02-01T05:18:46.974Z",
+  "modificationTime": "2023-02-01T05:18:46.974Z",
+  "quotaInBytes": -1,
+  "quotaInNamespace": -1,
+  "bucketLayout": "FILE_SYSTEM_OPTIMIZED",
+  "owner": "om",
+  "link": false
+}
+```
+
+* List EC buckets with their replication config.
+```shell
+$ $ ozone sh bucket list /vol1 | jq -r '.[] | 
select(.replicationConfig.replicationType == "EC") | [.name, 
.replicationConfig]'
+[
+  "ec5",
+  {
+    "data": 3,
+    "parity": 2,
+    "ecChunkSize": 1048576,
+    "codec": "RS",
+    "replicationType": "EC",
+    "requiredNodes": 5
+  }
+]
+[
+  "ec9",
+  {
+    "data": 6,
+    "parity": 3,
+    "ecChunkSize": 1048576,
+    "codec": "RS",
+    "replicationType": "EC",
+    "requiredNodes": 9
+  }
+]

Review Comment:
   I think printing each result as an object instead of a list makes more sense.
   
   ```
   ozone sh bucket list /vol1 | jq -r '.[] | 
select(.replicationConfig.replicationType == "EC") | {"name": .name, 
"replicationType": .replicationConfig.replicationType}'
   {
     "name": "ec5",
     "replicationType": "EC"
   }
   {
     "name": "ec9",
     "replicationType": "EC"
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to