sla.getsli

Description

object sla.getsli(object parameters)

This method allows to calculate the Service Level Indicator (SLI) data.

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.

ParameterTypeDescription
slaid
(required)
stringIDs of services to return availability information for.
period_fromintegerStarting date (inclusive) to report the SLI for.

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

Possible values: timestamp.
periodsarrayPreferred number of periods to report.

Possible values: 1-100
serviceidsstring/arrayIDs of services to return the SLI for.

Partitioning of periods

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

ParametersDescription
period_fromperiod_toperiods
---The last 20 periods (including the current one) but not past the first available period based on the effective date of the SLA.
--specifiedThe last periods specified by the periods parameter.
-specified-The last 20 periods before the specified date, but not past the first available period based on the effective date of the SLA.
-specifiedspecifiedThe last periods specified by the periods parameter before the specified date.
specified--The first 20 periods (including the current one) but not past the current one.
specified-specifiedThe first periods specified by the periods parameter starting with the specified date.
specifiedspecified-Periods within the specified date range, but no more than 100 and not past the first available period based on the effective date of the SLA.
specifiedspecifiedspecifiedPeriods within the specified date range, but no more than the specified number of periods and not past the first available period based on the effective date of the SLA.

Return values

(object) Returns the results of the calculation.

PropertyTypeDescription
periodsarrayList 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.
serviceidsarrayList 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.
sliarraySLI 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:

PropertyTypeDescription
uptimeintegerAmount of time service spent in an OK state during scheduled uptime, less the excluded downtimes.
downtimeintegerAmount of time service spent in a not OK state during scheduled uptime, less the excluded downtimes.
slifloatSLI (per cent of total uptime), based on uptime and downtime.
error_budgetintegerError budget (in seconds), based on the SLI and the SLO.
excluded_downtimesarrayArray 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.

示例

Calculating SLI

Retrieve SLI on services with IDs “50, 60 and 70” linked to an SLA with ID of “5” for 3 periods starting from Nov 01, 2021.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "service.getsla",
  4. "params": {
  5. "slaid": "5",
  6. "serviceids": [
  7. 50,
  8. 60,
  9. 70
  10. ],
  11. "periods": 3,
  12. "period_from": "1635724800"
  13. },
  14. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  15. "id": 1
  16. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "periods": [
  5. {
  6. "period_from": 1635724800,
  7. "period_to": 1638316800
  8. },
  9. {
  10. "period_from": 1638316800,
  11. "period_to": 1640995200
  12. },
  13. {
  14. "period_from": 1640995200,
  15. "period_to": 1643673600
  16. }
  17. ],
  18. "serviceids": [
  19. 50,
  20. 60,
  21. 70
  22. ],
  23. "sli": [
  24. [
  25. {
  26. "uptime": 1186212,
  27. "downtime": 0,
  28. "sli": 100,
  29. "error_budget": 0,
  30. "excluded_downtimes": [
  31. {
  32. "name": "Excluded Downtime - 1",
  33. "period_from": 1637836212,
  34. "period_to": 1638316800
  35. }
  36. ]
  37. },
  38. {
  39. "uptime": 1186212,
  40. "downtime": 0,
  41. "sli": 100,
  42. "error_budget": 0,
  43. "excluded_downtimes": [
  44. {
  45. "name": "Excluded Downtime - 1",
  46. "period_from": 1637836212,
  47. "period_to": 1638316800
  48. }
  49. ]
  50. },
  51. {
  52. "uptime": 1186212,
  53. "downtime": 0,
  54. "sli": 100,
  55. "error_budget": 0,
  56. "excluded_downtimes": [
  57. {
  58. "name": "Excluded Downtime - 1",
  59. "period_from": 1637836212,
  60. "period_to": 1638316800
  61. }
  62. ]
  63. }
  64. ],
  65. [
  66. {
  67. "uptime": 1147548,
  68. "downtime": 0,
  69. "sli": 100,
  70. "error_budget": 0,
  71. "excluded_downtimes": [
  72. {
  73. "name": "Excluded Downtime - 1",
  74. "period_from": 1638439200,
  75. "period_to": 1639109652
  76. }
  77. ]
  78. },
  79. {
  80. "uptime": 1147548,
  81. "downtime": 0,
  82. "sli": 100,
  83. "error_budget": 0,
  84. "excluded_downtimes": [
  85. {
  86. "name": "Excluded Downtime - 1",
  87. "period_from": 1638439200,
  88. "period_to": 1639109652
  89. }
  90. ]
  91. },
  92. {
  93. "uptime": 1147548,
  94. "downtime": 0,
  95. "sli": 100,
  96. "error_budget": 0,
  97. "excluded_downtimes": [
  98. {
  99. "name": "Excluded Downtime - 1",
  100. "period_from": 1638439200,
  101. "period_to": 1639109652
  102. }
  103. ]
  104. }
  105. ],
  106. [
  107. {
  108. "uptime": 1674000,
  109. "downtime": 0,
  110. "sli": 100,
  111. "error_budget": 0,
  112. "excluded_downtimes": []
  113. },
  114. {
  115. "uptime": 1674000,
  116. "downtime": 0,
  117. "sli": 100,
  118. "error_budget": 0,
  119. "excluded_downtimes": []
  120. },
  121. {
  122. "uptime": 1674000,
  123. "downtime": 0,
  124. "sli": 100,
  125. "error_budget": 0,
  126. "excluded_downtimes": []
  127. }
  128. ]
  129. ]
  130. },
  131. "id": 1
  132. }

来源

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