Calculate device availability for a duration of time or get device availability as shown in device availability tab of device management page

Calculate device availability for a duration of time or get device availability as shown in device availability tab of device management page like Hourly, Weekly and Monthly

Product/components used and version/fix level:

BACKEND: 1018.0.261
UI: 1016.0.170

Detailed explanation of the problem:

We need to display the device availability status in a dashboard widget for application created using Application Builder. What would be the best way to display the availability as % of Availability, Unavailability and In Maintenance possibly in the form of a Donut chart.

One approach, I can think of is to calculate the availability % for a duration and store as a managed object property in EPL, then display the same in a dashboard widget. In this case how to calculate the availability % in EPL?

Please suggest a better way to implement the use case.

Error messages / full error message screenshot / log file:

Question related to a free trial, or to a production (customer) instance?

production (customer)

Why not working with the times of the unavailability alarms? Whenever a device is not connected within the “required intervals”, it raises an alarm that has a creationTime and also updates with timestamps as soon as it comes online. I guess this can be used to calculate your % of Availability e.g. in a microservice. Maybe other colleagues have other ideas as well.

@Murat_Bayram
Thanks for your reply.
Could you please elaborate a bit how it can be done in EPL.
Any reference or link will be good.

Also, wondering how the device availability tab in device management is being populated, unable to find inspecting the network communication in Chrome, any idea on this please.

This tab is populated by core itself.

I´m not an EPL expert but my colleagues @Harald_Meyer, @Christof_Strack can make a suggestion here.

Regarding the built-in functionality, there are non-public APIs to get the historic availability of a device. You should see the APIs from the Browser developer tools being called when you go to the “Availability” tab.

Regarding Murat’s idea, when a device becomes unavailable a c8y_UnavailabilityAlarm is raised and it is cleared if the device becomes available again. In EPL you can react to the alarm:

on all Alarm(source="<<My device id>>", type="c8y_UnavailabilityAlarm",status="ACTIVE") as a {
  if(a.isCreate()) {
     on Alarm(id=a.id, status="CLEARED") as cleared {
        float unavailable := cleared.time - a.time;
     }
  }
}

This is not perfect as an alarm might be deleted, so maybe you want some additional conditions to terminate the inner listener. This will give you the time for a single unavailability. You could store these as measurements and then add them up for whatever timeframe you want to show.

This approach makes most sense if you want to have custom logic to define device unavailability. If you are ok with the standard availability provided by Cumulocity IoT, I suggest to look at the non-public APIs to get the existing data.

If you are not familiar with EPL Apps, you can find more information in our documentation:
https://cumulocity.com/guides/streaming-analytics/epl-apps/

1 Like

Thank You.
Will check.

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