sla.getsli

Description

object sla.getsli(object parameters)

This method allows to calculate the Service Level Indicator (SLI) data for a Service Level Agreement (SLA).

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters containing the SLA ID, reporting periods and, optionally, the IDs of the services - to calculate the SLI for.

Parameter Type Description
slaid ID ID of the SLA to return availability information for.

Parameter behavior:
- required
period_from timestamp Starting date (inclusive) to report the SLI for.

Possible values: timestamp.
period_to timestamp Ending date (exclusive) to report the SLI for.

Possible values: timestamp.
periods array Preferred number of periods to report.

Possible values: 1-100
serviceids ID/array IDs of services to return the SLI for.

Partitioning of periods

The following table demonstrates the arrangement of returned period slices based on combinations of parameters.

The returned periods will not precede the first available period based on the effective date of the SLA and will not exceed the current period.

Parameters Description
period_from period_to periods
- - - Return the last 20 periods.
- - specified Return the last periods specified by the periods parameter.
- specified - Return the last 20 periods before the specified period_to date.
- specified specified Return the last periods specified by the periods parameter before the specified period_to date.
specified - - Return the first 20 periods starting with the specified period_from date.
specified - specified Return the first periods specified by the periods parameter starting with the specified period_from date.
specified specified - Return up to 100 periods within the specified date range.
specified specified specified Return periods specified by the periods parameter within the specified date range.

Return values

(object) Returns the results of the calculation.

Property Type Description
periods array List of the reported periods.

Each reported period is represented as an object consisting of:
- period_from - Starting date of the reported period (timestamp).
- period_to - Ending date of the reported period (timestamp).

Periods are sorted by period_from field ascending.
serviceids array List of service IDs in the reported periods.

The sorting order of the list is not defined. Even if serviceids parameter was passed to the sla.getsli method.
sli array SLI data (as a two-dimensional array) for each reported period and service.

The index of the periods property is used as the first dimension of the sli property.

The index of the serviceids property is used as the second dimension of the sli property.

SLI data

The SLI data returned for each reported period and service consists of:

Property Type Description
uptime integer Amount of time service spent in an OK state during scheduled uptime, less the excluded downtimes.
downtime integer Amount of time service spent in a not OK state during scheduled uptime, less the excluded downtimes.
sli float SLI (per cent of total uptime), based on uptime and downtime.
error_budget integer Error budget (in seconds), based on the SLI and the SLO.
excluded_downtimes array Array of excluded downtimes in this reporting period.

Each object will contain the following parameters:
- name - Name of the excluded downtime.
- period_from - Starting date and time (inclusive) of the excluded downtime.
- period_to - Ending date and time (exclusive) of the excluded downtime.

Excluded downtimes are sorted by period_from field ascending.

Examples

Calculating SLI

Retrieve SLI data on services with IDs "50", "60" and "70" that are linked to the SLA with ID "5". Retrieve data for 3 periods starting from Nov 01, 2021.

Request:

{
           "jsonrpc": "2.0",
           "method": "sla.getsli",
           "params": {
               "slaid": "5",
               "serviceids": [
                   50,
                   60,
                   70
               ],
               "periods": 3,
               "period_from": "1635724800"
           },
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "periods": [
                   {
                       "period_from": 1635724800,
                       "period_to": 1638316800
                   },
                   {
                       "period_from": 1638316800,
                       "period_to": 1640995200
                   },
                   {
                       "period_from": 1640995200,
                       "period_to": 1643673600
                   }
               ],
               "serviceids": [
                   50,
                   60,
                   70
               ],
               "sli": [
                   [
                       {
                           "uptime": 1186212,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": [
                               {
                                   "name": "Excluded Downtime - 1",
                                   "period_from": 1637836212,
                                   "period_to": 1638316800
                               }
                           ]
                       },
                       {
                           "uptime": 1186212,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": [
                               {
                                   "name": "Excluded Downtime - 1",
                                   "period_from": 1637836212,
                                   "period_to": 1638316800
                               }
                           ]
                       },
                       {
                           "uptime": 1186212,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": [
                               {
                                   "name": "Excluded Downtime - 1",
                                   "period_from": 1637836212,
                                   "period_to": 1638316800
                               }
                           ]
                       }
                   ],
                   [
                       {
                           "uptime": 1147548,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": [
                               {
                                   "name": "Excluded Downtime - 1",
                                   "period_from": 1638439200,
                                   "period_to": 1639109652
                               }
                           ]
                       },
                       {
                           "uptime": 1147548,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": [
                               {
                                   "name": "Excluded Downtime - 1",
                                   "period_from": 1638439200,
                                   "period_to": 1639109652
                               }
                           ]
                       },
                       {
                           "uptime": 1147548,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": [
                               {
                                   "name": "Excluded Downtime - 1",
                                   "period_from": 1638439200,
                                   "period_to": 1639109652
                               }
                           ]
                       }
                   ],
                   [
                       {
                           "uptime": 1674000,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": []
                       },
                       {
                           "uptime": 1674000,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": []
                       },
                       {
                           "uptime": 1674000,
                           "downtime": 0,
                           "sli": 100,
                           "error_budget": 0,
                           "excluded_downtimes": []
                       }
                   ]
               ]
           },
           "id": 1
       }

Source

CSla::getSli() in ui/include/classes/api/services/CSla.php