Finding Unused Feature Services

1563
5
05-13-2020 02:15 PM
JasonJordan00
Occasional Contributor

Hi all, would anyone know of a way to query the usage statistics in hosted feature services through any of the APIs to find items that haven't been used in 30, 90 days, etc? 

0 Kudos
5 Replies
mdonnelly
Esri Contributor

To my knowledge there isn't an easy way to do this. You can create usage reports on how much content is being created but usage on individual services is not straightforward, though Portal or ArcGIS Online. There is an Esri idea where people are asking for something similar:

Create Detailed AGOL Usage Report for Every Item 

If this is for an ArcGIS Enteprise deployment, rather than AGOL then you can get access to ArcGIS Server statistics in Server Manager. There you can view the number of requests for given services. It's not exactly what you are after but it allows you to see which services are getting requests and which are not.

Regards,
Mark
Katie_Clark
MVP Regular Contributor

Thanks for sharing that, Mark Donnelly‌! It would be SO helpful for organization administrators to be able to generate reports like that!

I did notice in the comments of that Idea that item.usage() from the Python API will produce similar results....maybe something that would be worth it to look into in the meantime. However, making this functionality available for all org admins, even those without programming experience, is essential!

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
JasonJordan00
Occasional Contributor

Good link, Mark. I'm definitely upvoting that. I'm playing around with the .usage() function that Katherine mentioned, looks like it could be promising. I'm definitely not familiar with the API so there's probably better ways to do this but plugging into a Notebook is giving good results so far. 

from arcgis.gis import GIS
from IPython.display import display
gis = GIS("home")
items = gis.content.search(query="type:Feature Service")
for item in items:
   try:
      itemHistory = item.usage(date_range='1Y', as_df=True)   # <--- Looking in the past 12 months
      total = itemHistory['Usage'].sum()
      if total <20:                                                                           # <--- Less than 20 total views
         display(item)
   except:
      pass

Katie_Clark
MVP Regular Contributor

Wow, thanks for posting the code! I'll need to give that a try as well!

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos
mdonnelly
Esri Contributor

Nice bit of code Jason.

I wasn't aware of the item.usage object, so thanks for sharing!

Regards,
Mark
0 Kudos