Skip to content

Instantly share code, notes, and snippets.

@lynsei
Created March 6, 2025 14:58
Show Gist options
  • Save lynsei/88decaee582f27d5e601102a39ee6625 to your computer and use it in GitHub Desktop.
Save lynsei/88decaee582f27d5e601102a39ee6625 to your computer and use it in GitHub Desktop.
[jfrog cloud] #artifactory #jfrog-cloud

JFrog Cloud API Calls for Storage, Downloads, and Throughput Analysis

1. Get Storage Information (Find the Largest Artifacts)

Retrieve total storage usage and identify largest artifacts.

A. Get Overall Storage Usage

curl -u "username:password" -X GET "https://site.jfrog.io/artifactory/api/storageinfo"

B. Find the Largest Artifacts in a Repository

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find({"repo": "my-repo"}).sort({"$desc":["size"]}).limit(10)'
'

2. Get Most Frequently Downloaded Artifacts

A. Get Download Statistics for a Specific Artifact

curl -u "username:password" -X GET "https://site.jfrog.io/artifactory/api/storage/my-repo/path/to/artifact.jar?stats"

B. Get Most Downloaded Artifacts Across a Repository

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find({"repo": "my-repo"}).sort({"$desc":["stat.downloads"]}).limit(10)'
'

3. Find Users Causing the Most Throughput (Ingress/Egress)

A. Get Recent Requests from JFrog Access Logs

curl -u "username:password" -X GET "https://site.jfrog.io/artifactory/api/access/api/v1/audit?limit=50"

B. Find Users Who Downloaded the Most Data

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find({"stat.downloads":{"$gt": 0}}).include("stat.downloads", "stat.downloaded_by").sort({"$desc":["stat.downloads"]}).limit(10)'
'

C. Find Users Uploading the Most Data

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find({"repo": "my-repo", "created_by": {"$ne": ""}}).include("size", "created_by").sort({"$desc":["size"]}).limit(10)'
'

4. Get Repositories Causing the Most Egress (Outgoing Traffic)

curl -u "username:password" -X GET "https://site.jfrog.io/artifactory/api/repositories"

For each repository, check download statistics:

curl -u "username:password" -X GET "https://site.jfrog.io/artifactory/api/storage/{repoKey}?stats"

5. Get Repositories Causing the Most Ingress (Incoming Traffic)

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find({"repo": "my-repo"}).include("size").sort({"$desc":["size"]}).limit(10)'
'

6. Automate Reporting for Large Artifacts and Egress

A. Generate a Daily Report for the 10 Largest Artifacts

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find().sort({"$desc":["size"]}).limit(10)'
' > largest_artifacts_report.json

B. Generate a Daily Report for Most Downloaded Artifacts

curl -u "username:password" -X POST "https://site.jfrog.io/artifactory/api/search/aql" -H "Content-Type: text/plain" --data '
items.find().sort({"$desc":["stat.downloads"]}).limit(10)'
' > most_downloaded_artifacts.json

7. Get Live Logs for Real-Time Monitoring

curl -u "username:password" -X GET "https://site.jfrog.io/artifactory/api/systemlogs?limit=100"

Summary of Key API Calls

Goal API Call
Get total storage usage GET /artifactory/api/storageinfo
Find largest artifacts AQL query sorting by size
Find most downloaded artifacts AQL query sorting by downloads
Get artifact download statistics GET /artifactory/api/storage/{repo}/{path}?stats
Get top users by egress AQL query filtering downloads by user
Get top users by ingress AQL query filtering uploads by user
Get top repositories by egress GET /artifactory/api/storage/{repo}?stats
Get real-time access logs GET /artifactory/api/access/api/v1/audit?limit=50

Would you like help automating these reports or integrating them with ClickHouse for analytics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment