Fast API inventory results?

Emmert
Valued Contributor

Hi guys, I have some advanced inventory searches that I'd like to get info from, (count of iPads by model, counts of iPad by iOS version, etc.) and would like to get those numbers from the API, but it seems that running the advanced search pulls down quite a bit of information about each device, which I don't need. It takes 10-20 seconds just to grab one number using this method.

Is there another way to do what I'm trying to accomplish?

Thanks!

9 REPLIES 9

mm2270
Legendary Contributor III

When you use the API to pull up a saved advanced search, it actually runs that search on your JSS, same as if you were in the GUI and opened on the saved search and clicked "View"
I don't think there's a way to not have it run the search live at the time you access it. Maybe you could use a Smart Group and access the Smart Group via the API instead, which should already have all the info in it, meaning its already being calculated on the backend so it doesn't need to run the query at the time its accessed.

Emmert
Valued Contributor

That's a great suggestion, thanks!

jrwilcox
Contributor

You can also reduce the amount of data by taking out all of the unnecessary fields in the report.

mm2270
Legendary Contributor III

@jrwilcox makes a great point. If you remove all the unnecessary default fields in the saved report, and only leave in the ones you care about, it does help speed up the report generation. Its still going to take a small amount of time since its still doing a live query, but yes, removing unneeded fields does help.

chriscollins
Valued Contributor

Yep. When we just need device counts or specific devices by serial or uuid, we actually have specific advanced searches that only have UUID or whatnot as a field to show so they only show up in the report. So for instance if we want to know all North American macs that are filevaulted, we have an advanced search that can just pull the machines with only a few attributes and just count the amount of objects returned. Only takes a second to return.

jchurch
Contributor II

i would stay way from the smart group approach. every time a machine submits an inventory update every smart group get recalculated. a couple hundred smart groups times a couple thousand machines equals lots of unnecessary overhead on your JSS.

Emmert
Valued Contributor

I must be missing something - I've unchecked all the boxes on my inventory report except for "full name," and the report that the API is returning is 15000 lines for 1500 devices. There's a bunch of info in there like udid and stuff that I don't need, and it's still taking 30 seconds to generate.

Using smart groups instead is working fine for me, we have less than 50 of them.

mm2270
Legendary Contributor III

@Emmert I may be able to explain that. So, as of at least JSS 9.82 and possibly all the way up to the current JSS versions, there are actually 2 different saved advanced search URI items listed in the API. One is an older version that may end up being deprecated in a later release, although I really hope not, and I may make an appeal to Jamf to keep it there. This one is labeled as /computerreports You'll see in the built in API documentation, that this one only contains a few GET parameters. There are no PUT, POST or other parameters available for it. Its just for pulling saved advanced search results. But the good thing about it is, it much more closely matches the criteria columns you enable in the saved search. It will only have the items you specified in the saved search, with maybe the exception of some identifying item like the computer name or something.
The other path, which I'm guessing is what you're using for this pull, is called /advancedcomputersearches This one, while having more options, also includes several columns by default in the output regardless of whether you enabled them in the saved report. Its going to have those UUID lines like you mentioned, even if you don't have them explicitly checked in the saved report. IOW, it may not match what you see in the GUI exactly as opposed to the other item, which likely will.

You can try using /computerreports as the path instead of /advancedcomputersearches to see if that helps you get a faster API result.

duo-endpoints
New Contributor

In the New api is there a similar approach we can take. Currently it's taking us an hour to sync a device inventory that contains 60k devices . We only need the udid. each request per page is taking 15 - 20 seconds using the computer inventory route.