With the introduction of the Package Activity API and accompanying CLI command, you can now quickly and easily check your entire repository for packages' activity status or even take a detailed approach and view packages individually (per day/per package).
You can save on your storage costs by eliminating inactive packages and retaining only the packages you or your users derive value from storing and distributing via Cloudsmith.
The excellent news is that once you identify those inactive packages, you can make use of Automated retention/lifetime rules (available on the Velocity plan and above). These rules allow you to automatically manage storage for packages by deleting or moving packages that fall outside of the defined retention rules.
Assets can be expired based on the number of packages (count), size of packages (bytes), or by the number of days (time); however, to first create these rules, you first need to understand how your users are interacting with your existing packages. However, understanding when to delete the packages was challenging, until now!
So how does it work?
Every package has an aggregated count of the number of total downloads for a given package calculated daily. A package is considered active when there have been downloads for that package for a given range. If there are no downloads during a specified period, then it's deemed to be inactive.
The easiest way to get started exploring these metrics is to check out the metrics command within the Cloudsmith CLI. Alternatively, to get more fine-grained metrics, you can implement a programmatic solution using our API or one of the API binding libraries published in various languages.
For example, to check if a package has ever been "active" and received downloads, you can request the "packages" metric for an entire repository and use the --inactive=true flag to display a list of inactive packages to identify candidates that will help you create a retention rule to automate the removal in future.
Getting started quickly
Using the Cloudsmith CLI you can quickly and easily query the total number of active/inactive packages for your repository by running the following command with your organisation/repository.
cloudsmith metrics packages your-organisation/your-repository
If you want to specify a specific package, you can also supply one or more packages as a comma separated string.
cloudsmith metrics packages cloudsmith/example --packages=ZGCV58VqT8Sl
Querying between a range is easy using ISO 8601 formatted datetimes. Supplying a start and finish helps drilling down to answer specific questions like:
- Has package activity increase or decreased since last month?
- Has the number of inactive packages increased since last year?
- How many active packages has been added this week?
cloudsmith metrics packages cloudsmith/example --start=2019-01-01T00:00:00Z --finish=2019-12-31T00:00:00Z
Although the summary overview provides a general feel for the increase/decrease of inactive/active packages, it can be useful to drill down into what those packages are by using the
--inactive-packages=true flags to identify what's been added or what can potentially be removed.
cloudsmith metrics packages cloudsmith/example --active-packages=true
The package slug has been omitted from these screenshots but when running the command you can use the slug to identify the package uniquely.
cloudsmith metrics packages cloudsmith/example --inactive-packages=true
It's that simple to get started!