Count downloads from artifact registry Python Package

Hello, Community.

I'm currently developing a Python package that I would like to deploy using Artifact Registry, for authentication/security purposes.

Reading the docs, I didn't find anything related to repositories/package metrics, such as number of downloads. Is there any solution for this?

Solved Solved
0 2 501
1 ACCEPTED SOLUTION

There is no feature to track the metrics in Artifact Registry, but you can use the tools (cloud functions, pub/sub) provided by Google to be able to track the metrics: 

 

Enable Artifact Registry data logs[1]:    

  1. Go to “IAM & Admin” and click on “Audit Logs”. 
  2. In the main table on the Audit Logs page, select “Artifact Registry API” from the list. 
  3. In the Log Type tab, select the boxes: “Admin Read” and “Data Read” and then click Save. Please keep in mind that enabling the Data Access logs might result in your Cloud project being charged for the additional logs usage

Screenshot 2022-05-27 4.39.39 PM.png

 

4. Create a Pub/Sub topic [2].

5. Enable and export logs from the Artifact Registry instance to your Pub/Sub topic by creating a sink on Logging by following the steps described here [3].

6. Create a Cloud Function and use your Pub/Sub topic to trigger it. 

7. Create a cloud function to create your custom metrics (here; for example, you can choose to monitor downloads) as shown in [4].



[1]:https://cloud.google.com/logging/docs/audit/configure-data-access 

[2]:https://cloud.google.com/pubsub/docs/admin#pubsub_create_topic-gcloud 

[3]:https://cloud.google.com/logging/docs/export/configure_export_v2#console 

[4]:https://cloud.google.com/monitoring/custom-metrics/creating-metrics#monitoring_create_metric-protoco...

View solution in original post

2 REPLIES 2

There is no feature to track the metrics in Artifact Registry, but you can use the tools (cloud functions, pub/sub) provided by Google to be able to track the metrics: 

 

Enable Artifact Registry data logs[1]:    

  1. Go to “IAM & Admin” and click on “Audit Logs”. 
  2. In the main table on the Audit Logs page, select “Artifact Registry API” from the list. 
  3. In the Log Type tab, select the boxes: “Admin Read” and “Data Read” and then click Save. Please keep in mind that enabling the Data Access logs might result in your Cloud project being charged for the additional logs usage

Screenshot 2022-05-27 4.39.39 PM.png

 

4. Create a Pub/Sub topic [2].

5. Enable and export logs from the Artifact Registry instance to your Pub/Sub topic by creating a sink on Logging by following the steps described here [3].

6. Create a Cloud Function and use your Pub/Sub topic to trigger it. 

7. Create a cloud function to create your custom metrics (here; for example, you can choose to monitor downloads) as shown in [4].



[1]:https://cloud.google.com/logging/docs/audit/configure-data-access 

[2]:https://cloud.google.com/pubsub/docs/admin#pubsub_create_topic-gcloud 

[3]:https://cloud.google.com/logging/docs/export/configure_export_v2#console 

[4]:https://cloud.google.com/monitoring/custom-metrics/creating-metrics#monitoring_create_metric-protoco...

Thank you, Andre!