Tenant statistics based on device type

I am developing an application to visualize the history of statistics of tenants.
Currently, I am using the statistics API route for that. Specifically, to visualize the device count by day (GET /tenant/statistics). The problem is that i also need to know the number of devices by device type (preferably grouped by the c8y_hardware Fragment).

But I currently see no way to get this kind of results from the API or generally filter historical statistic data in any kind.
Is there something I am missing here?

I don’t think you’re missing something. The Device Count is part of the usage statistics - but the count is not grouped by Device Type, it’s always the total Device Count.

What you could do is implementing a service that does these counts in a scheduled manner, e.g. once per day, via API. The count results you could send as Measurements to a dedicated Device. Once there you can create a Dashboard with e.g. KPI Widgets and Datapoint Graphs to display data - or work with the data in the App you are developing at the moment.

// Edit: To count devices you could use:

GET /inventory/managedObjects?q=$filter=(type eq 'your-device-type')&pageSize=1&withChildren=false&withTotalElements=true
or
GET /inventory/managedObjects?q=$filter=(c8y_Hardware.model eq 'your-hw-model')&pageSize=1&withChildren=false&withTotalElements=true

… and extract count from statistics.totalElements field.

3 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.