HOW TO: access to statistics about resource usage by user and by ORG

×

Warning message

You can't delete this newsletter because it has not been sent to all its subscribers.

The access to statistics about resource usage by user and by ORG can be useful to monitor the platform and to provide data to the market place on which the applications of the Snap4City platform are sold in a As a Service base. 

The platform enforces limits on the usage of resources (dashboards, Iot App, devices, MyKPI, data analytics, etc.). The limits are imposed by resource type, by user, by org and by role, and are imposed by RootAdmin only.

The main metrics area so far:

  • n_active_iotapps: number of active IoT Apps / Proc.Logics    
  • n_api_accesses: number of API accesses from the API Manager (see details below)
  • n_ascapi_accesses: number of API accesses for ASCAPI (see details below)
  • n_da_processes: number of Data Analytics (Python and RStudio processes) used via API Manager
  • n_device_messages: number of messages on its devices/entities registered/active or delegated in writing
  • n_devices: number of devices/entities registered/active
  • n_heatmaps: number of heatmaps produced and owned
  • n_odm_instances: number of ODMs produced and owned
  • n_traffic_flow: number of Traffic Flows produced and owned
  • number_of_users: number of users of the selected Organization (only if access by org view is selected)
  • sum_active_dashboards: number of Dashboards created and owned
  • to appear:
    • counting of executions of simulations via SUMO
    • ......

The access to statistics can be performed by Graphic user Interface and by API.

In both cases the access is regulated by Authentication and Authorization. There a special authorization to be provided to users and market place managers to access to the metrics. 
Please note that user belonging to multiple organization my have data from all of them. 
Market place operators for multiple organizations may have access to all users of all organizations for which they have received the delegation in access by RootAdmin of the platform.

The menu items to access at the user and org statistics information are located on:

  • User Management item for Root Administrators
  • My profile item for the AreaManagers and Managers, and thus for maket place operators

User Stats via Graphic user Interface

Resourcesconsumption API endpoints guide

expected header: Bearer auth with token containing ou and unnested roles

base url: protocol+platform+/userstats/+endpoint

eg: https://<domain>/userstats/user/monthly

Endpoints with params:

/user/selected_usage

  • Expected roles: RootAdmin, AreaManager (with delegation to org), as regulated by the authorizations provided by RootAdmin.
  • required params: username
  • allowed params: date (as full date yyyy-mm-dd or month as yyyy-mm), (start_date, end_date as yyyy-mm-dd) sum(true,false)
  • Returns: Json summing all dates selected/Json for each date:

example for sum=false:

{

    "2025-04-28": {

        "api_manager": {

            "clearmltestreal": 16,

            "newapi": 2

        },

        "ascapi": {

            "api-iot-search": 3,

            "api-service-info": 2

        },

        "dashboard_activity_summary": [

            {

                "idDashboard": 2,

                "nAccessPerDay": 25,

                "nMinutesPerDay": 26

            },

            {

                "idDashboard": 4,

                "nAccessPerDay": 33,

                "nMinutesPerDay": 333

            }

        ],

        "n_active_dashboards": 4,

        "n_active_iotapps": 5,

        "n_api_accesses": 18,

        "n_ascapi_accesses": 5,

        "n_da_processes": 0,

        "n_device_messages": "55",

        "n_devices": 3,

        "n_heatmaps": 0,

        "n_odm_instances": 0,

        "n_traffic_flow": 0,

        "owned_dashboard_usage": {

            "2": {

                "total_accesses": 25,

                "total_minutes": 26

            },

            "4": {

                "total_accesses": 33,

                "total_minutes": 333

            }

        }

    },

/org/usage

  • Expected roles: RootAdmin, AreaManager (with delegation to org)
  • required params: org
  • allowed params: date (as full date yyyy-mm-dd or month as yyyy-mm), (start_date, end_date as yyyy-mm-dd), sum(true,false)
  • Returns: Json summing all dates selected/Json for each date:

example for sum= true:

{

    "active_dashboards": {

        "max": "6",

        "min": "6",

        "total_usage": "18"

    },

    "active_iotapps": {

        "max": "5",

        "min": "5",

        "total_usage": "15"

    },

    "api_manager": {

        "clearmltestreal": 18,

        "newapi": 668

    },

    "ascapi": {

        "api-iot-search": 61,

        "api-service-info": 620

    },

    "da_processes": {

        "max": "1",

        "min": "0",

        "total_usage": "2"

    },

    "dashboard_used_by_org": [

        {

            "idDashboard": 2,

            "total_accesses": "27",

            "total_minutes": "26"

        },

        {

            "idDashboard": 3,

            "total_accesses": "3",

            "total_minutes": "22"

        },

        {

            "idDashboard": 4,

            "total_accesses": "35",

            "total_minutes": "333"

        },

        {

            "idDashboard": 6,

            "total_accesses": "5",

            "total_minutes": "1278"

        }

    ],

    "devices": {

        "max": "5",

        "min": "4",

        "total_usage": "14"

    },

    "heatmaps": {

        "max": "0",

        "min": "0",

        "total_usage": "0"

    },

    "n_api_accesses": "684",

    "n_ascapi_accesses": "338",

    "n_device_messages": "520",

    "number_of_users": {

        "max": 4,

        "min": 4

    },

    "odm_instances": {

        "max": "0",

        "min": "0",

        "total_usage": "0"

    },

    "owned_dashboard_usage": {

        "2": {

            "total_accesses": 27,

            "total_minutes": 26

        },

        "3": {

            "total_accesses": 3,

            "total_minutes": 22

        },

        "4": {

            "total_accesses": 35,

            "total_minutes": 333

        },

        "6": {

            "total_accesses": 5,

            "total_minutes": 1278

        }

    },

    "traffic_flow": {

        "max": "0",

        "min": "0",

        "total_usage": "0"

    }

}

example for sum=false:

{

    "2025-04-28": {

        "api_manager": {

            "clearmltestreal": 16,

            "newapi": 668

        },

        "ascapi": {

            "api-iot-search": 3,

            "api-service-info": 335

        },

        "dashboard_used_by_org": [

            {

                "idDashboard": 2,

                "nAccessPerDay": 25,

                "nMinutesPerDay": 26

            },

            {

                "idDashboard": 4,

                "nAccessPerDay": 33,

                "nMinutesPerDay": 333

            }

        ],

        "n_active_iotapps": "5",

        "n_api_accesses": "684",

        "n_ascapi_accesses": "338",

        "n_da_processes": "0",

        "n_device_messages": "55",

        "n_devices": "4",

        "n_heatmaps": "0",

        "n_odm_instances": "0",

        "n_traffic_flow": "0",

        "number_of_users": 4,

        "owned_dashboard_activity": {

            "2": {

                "total_accesses": 25,

                "total_minutes": 26

            },

            "4": {

                "total_accesses": 33,

                "total_minutes": 333

            }

        },

        "sum_active_dashboards": "6"

    },

 

Endpoints with no params:

/all/monthly:

  • Expected Roles: RootAdmin, delegated AreaManager
  • Returns: Json containing Json for each user, and Json Array for each date:

{

    "userareamanager": {

        "04-2025": [

            {

                "api_calls": "{\"ascapi\":{\"api-iot-search\":61,\"api-service-info\":253},\"api_manager\":{\"clearmltestreal\":16,\"newapi\":2}}",

                "id": 18,

                "idUser": 1,

                "mm_yyyy": "04-2025",

                "total_n_da_processes": 2,

                "total_n_dashboard": 12,

                "total_n_devices": 11,

                "total_n_iot_apps": 15,

                "total_n_odm_instances": 0,

                "total_n_traffic_flow": 0,

                "total_owned_dashboard_activity_accesses": 70,

                "total_owned_dashboard_activity_minutes": 1659,

                "total_user_dashboard_activity_accesses": 63,

                "total_user_dashboard_activity_minutes": 1637

            }

        ]

    },

 

 

/user/monthly:

Returns: Json with username containing Json for each month:

{

    "03-2025": {

        "api_calls": {

            "api_manager": {},

            "ascapi": {}

        },

        "total_n_da_processes": 0,

        "total_n_dashboard": 0,

        "total_n_devices": 0,

        "total_n_iot_apps": 0,

        "total_n_odm_instances": 0,

        "total_n_traffic_flow": 0,

        "total_owned_dashboard_activity_accesses": 0,

        "total_owned_dashboard_activity_minutes": 0,

        "total_user_dashboard_activity_accesses": 11,

        "total_user_dashboard_activity_minutes": 514

    },

    "04-2025": {

        "api_calls": {

            "api_manager": {

                "clearmltestreal": 16,

                "newapi": 2

            },

            "ascapi": {

                "api-iot-search": 61,

                "api-service-info": 253

            }

        },

        "total_n_da_processes": 2,

        "total_n_dashboard": 12,

        "total_n_devices": 11,

        "total_n_iot_apps": 15,

        "total_n_odm_instances": 0,

        "total_n_traffic_flow": 0,

        "total_owned_dashboard_activity_accesses": 70,

        "total_owned_dashboard_activity_minutes": 1659,

        "total_user_dashboard_activity_accesses": 63,

        "total_user_dashboard_activity_minutes": 1637

    }

---end---