eden
eden

Reputation: 11

When retrieving the storage summary of repos in Artifactory, is there a way to order them by size?

I'm trying to view what repos are taking up the most storage space in artifactory by using the below API call, but I can't find a way to order them. I also seen in Jfrogs documentation that you cant sort based on properties. Any suggestions as to how do to do this?

https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-GetStorageSummaryInfo

Upvotes: 1

Views: 973

Answers (1)

Eldad Assis
Eldad Assis

Reputation: 11045

In this case, jq is your friend!

Pipe the output of the API to a jq with using the sort_by() functions.

Example:

curl -s -uadmin:password https://server/artifactory/api/storageinfo | jq '[.repositoriesSummaryList[] | {repoKey: .repoKey, itemsCount: .itemsCount, usedSpaceInBytes: .usedSpaceInBytes}] | sort_by(.usedSpaceInBytes)'

You can play around with the options.

Look for more details on the jq sorting in this good jq sorting doc.

Upvotes: 4

Related Questions