minio / mc

Unix like utilities for object store
https://min.io/download
GNU Affero General Public License v3.0
2.86k stars 548 forks source link

stat: print information about all buckets when only alias are set #5002

Closed dormanze closed 2 months ago

dormanze commented 3 months ago

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 license. By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 license.

Description

Motivation and Context

When view information about all buckets at a time, details such as the bucket usage cannot be printed. image Buckets should be treated as special directories because we have metrics for bucket.

How to test this PR?

mc stat myminio --verbose image

Types of changes

Checklist:

shtripat commented 3 months ago

Can you please add Motivation and Context for the change?

dormanze commented 3 months ago

Can you please add Motivation and Context for the change?

I've added it, please review my pr. Thank you.

dormanze commented 3 months ago

Changes look fine. But for a huge deployment with lot of buckets the output would be huge. Is the output like streaming of data? What would be the case for --json output?

--json output is just like:

{
 "status": "success",
 "name": "mateinfo-1002/",
 "lastModified": "2024-07-30T18:22:19.15033127+08:00",
 "size": 0,
 "Versioning": {
  "status": "Enabled",
  "MFADelete": ""
 },
 "Encryption": {},
 "ObjectLock": {
  "enabled": "",
  "mode": "",
  "validity": ""
 },
 "Replication": {
  "enabled": false,
  "config": {
   "Rules": null,
   "Role": ""
  }
 },
 "Policy": {
  "type": "none"
 },
 "location": "us-east-1",
 "ilm": {},
 "notification": {
  "config": {
   "XMLName": {
    "Space": "http://s3.amazonaws.com/doc/2006-03-01/",
    "Local": "NotificationConfiguration"
   },
   "LambdaConfigs": null,
   "TopicConfigs": null,
   "QueueConfigs": null
  }
 },
 "Usage": {
  "size": 1410523501,
  "objectsPendingReplicationTotalSize": 0,
  "objectsFailedReplicationTotalSize": 0,
  "objectsReplicatedTotalSize": 0,
  "objectReplicaTotalSize": 0,
  "objectsPendingReplicationCount": 0,
  "objectsFailedReplicationCount": 0,
  "versionsCount": 4241,
  "objectsCount": 4240,
  "deleteMarkersCount": 0,
  "objectsSizesHistogram": {
   "BETWEEN_1024B_AND_1_MB": 2997,
   "BETWEEN_1024_B_AND_64_KB": 1723,
   "BETWEEN_10_MB_AND_64_MB": 24,
   "BETWEEN_128_MB_AND_512_MB": 0,
   "BETWEEN_1_MB_AND_10_MB": 220,
   "BETWEEN_256_KB_AND_512_KB": 229,
   "BETWEEN_512_KB_AND_1_MB": 241,
   "BETWEEN_64_KB_AND_256_KB": 804,
   "BETWEEN_64_MB_AND_128_MB": 0,
   "GREATER_THAN_512_MB": 0,
   "LESS_THAN_1024_B": 999
  },
  "objectsVersionsHistogram": {
   "BETWEEN_1000_AND_10000": 0,
   "BETWEEN_100_AND_1000": 0,
   "BETWEEN_10_AND_100": 0,
   "BETWEEN_2_AND_10": 1,
   "GREATER_THAN_10000": 0,
   "SINGLE_VERSION": 4239,
   "UNVERSIONED": 0
  }
 }
}
{
 "status": "success",
 "name": "mateinfo-1003/",
 "lastModified": "2024-07-30T18:22:19.197559258+08:00",
 "size": 0,
 "Versioning": {
  "status": "",
  "MFADelete": ""
 },
 "Encryption": {},
 "ObjectLock": {
  "enabled": "",
  "mode": "",
  "validity": ""
 },
 "Replication": {
  "enabled": false,
  "config": {
   "Rules": null,
   "Role": ""
  }
 },
 "Policy": {
  "type": "none"
 },
 "location": "us-east-1",
 "ilm": {},
 "notification": {
  "config": {
   "XMLName": {
    "Space": "http://s3.amazonaws.com/doc/2006-03-01/",
    "Local": "NotificationConfiguration"
   },
   "LambdaConfigs": null,
   "TopicConfigs": null,
   "QueueConfigs": null
  }
 },
 "Usage": {
  "size": 0,
  "objectsPendingReplicationTotalSize": 0,
  "objectsFailedReplicationTotalSize": 0,
  "objectsReplicatedTotalSize": 0,
  "objectReplicaTotalSize": 0,
  "objectsPendingReplicationCount": 0,
  "objectsFailedReplicationCount": 0,
  "versionsCount": 0,
  "objectsCount": 0,
  "deleteMarkersCount": 0,
  "objectsSizesHistogram": {
   "BETWEEN_1024B_AND_1_MB": 0,
   "BETWEEN_1024_B_AND_64_KB": 0,
   "BETWEEN_10_MB_AND_64_MB": 0,
   "BETWEEN_128_MB_AND_512_MB": 0,
   "BETWEEN_1_MB_AND_10_MB": 0,
   "BETWEEN_256_KB_AND_512_KB": 0,
   "BETWEEN_512_KB_AND_1_MB": 0,
   "BETWEEN_64_KB_AND_256_KB": 0,
   "BETWEEN_64_MB_AND_128_MB": 0,
   "GREATER_THAN_512_MB": 0,
   "LESS_THAN_1024_B": 0
  },
  "objectsVersionsHistogram": {
   "BETWEEN_1000_AND_10000": 0,
   "BETWEEN_100_AND_1000": 0,
   "BETWEEN_10_AND_100": 0,
   "BETWEEN_2_AND_10": 0,
   "GREATER_THAN_10000": 0,
   "SINGLE_VERSION": 0,
   "UNVERSIONED": 0
  }
 }
}
klauspost commented 2 months ago

Quite nice change. It does however feel very verbose, and listing 50 buckets will make it pretty useless as @shtripat points out.

Could we add the extended information behind a -v/--verbose flag.

As a bonus, could you make it so 1970 (unix zero) dates aren't shown?

dormanze commented 2 months ago

Quite nice change. It does however feel very verbose, and listing 50 buckets will make it pretty useless as @shtripat points out.

Could we add the extended information behind a -v/--verbose flag.

As a bonus, could you make it so 1970 (unix zero) dates aren't shown?

verbose is a good idea.please review again.