[comment]: # translation:outdated

[comment]: # ({d1387fc4-f9178426})
# sla.getsli

[comment]: # ({/d1387fc4-f9178426})

[comment]: # ({3fde2eb3-531f7cc6})
### 説明

`object sla.getsli(object parameters)`

このメソッドを使用すると、サービスレベルアグリーメント (SLA) のサービスレベル指標 (SLI) データを計算できます。

::: noteclassic
このメソッドは、あらゆるタイプのユーザーが利用できます。このメソッドを呼び出す権限は、ユーザーロール設定で取り消すことができます。詳しくは、[ユーザーの役割](/manual/web_interface/frontend_sections/users/user_roles) をご覧ください。
:::

[comment]: # ({/3fde2eb3-531f7cc6})

[comment]: # ({270c9b0a-bcbf1cf2})
### パラメータ

`(object)` SLA ID、レポート期間、およびオプションでSLIを計算するサービスのIDを含むパラメータ

|パラメータ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|slaid|ID|可用性情報を返すSLAのID<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *必須*|
|period\_from|timestamp|SLIレポートの対象開始日（開始日を含む）<br><br>指定可能な値: timestamp|
|period\_to|timestamp|SLIレポートの対象終了日（終了日を含まない）<br><br>指定可能な値: timestamp|
|periods|配列|レポートする期間の推奨数<br><br>可能な値: 1～100|
|serviceids|ID/配列|SLIを返すサービスのID|

[comment]: # ({/270c9b0a-bcbf1cf2})

[comment]: # ({9478a80d-31bc72e4})
#### 期間の分割

以下の表は、パラメータの組み合わせに基づいて返される期間スライスの配置を示しています。

::: noteclassic
返される期間は、SLA の発効日に基づいて最初に利用可能な期間より前ではなく、現在の期間を超えません。
:::

|パラメータ| | |説明|
|--|--|--|----|
|**period\_from**|**period\_to**|**periods**| |
|-|-|-|最後の 20 期間を返します。|
|-|-|specified|**periods** パラメータで指定された最後の期間を返します。|
|-|specified|-|指定された **period\_to** 日付より前の最後の 20 期間を返します。|
|-|specified|specified|指定された **period\_to** 日付より前の、**periods** パラメータで指定された最後の期間を返します。|
|指定|-|-|指定された **period\_from** 日付から始まる最初の 20 期間を返します。|
|指定|-|指定|指定された **period\_from** 日付から始まる、**periods** パラメータで指定された最初の期間を返します。|
|指定|指定|-|指定された日付範囲内で最大 100 期間を返します。|
|指定|指定|指定|指定された日付範囲内で、**periods** パラメータで指定された期間を返します。|

[comment]: # ({/9478a80d-31bc72e4})

[comment]: # ({af9e88c4-b46f1257})
### 戻り値

`(object)` 計算結果を返します。

|プロパティ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|periods|配列|レポート対象期間のリスト<br><br>各レポート期間は、以下の要素で構成されるオブジェクトとして表されます。<br>- `period_from` - レポート対象期間の開始日（タイムスタンプ）<br>- `period_to` - レポート対象期間の終了日（タイムスタンプ）<br><br>期間は `period_from` フィールドで昇順にソートされます。|
|serviceids|配列|レポート対象期間のサービスIDのリスト<br><br>リストのソート順序は定義されていません。`serviceids` パラメータが `sla.getsli` メソッドに渡された場合でも、ソート順序は定義されていません。|
|sli|配列|報告された期間とサービスごとの SLI データ (**2 次元配列**)<br><br>`periods` プロパティのインデックスは、`sli` プロパティの **最初の** 次元として使用されます。<br><br>`serviceids` プロパティのインデックスは、`sli` プロパティの **2 番目の** 次元として使用されます。|

[comment]: # ({/af9e88c4-b46f1257})

[comment]: # ({aa24c098-ba0b5441})
#### SLI データ

報告された期間とサービスごとに返される SLI データは、以下の要素で構成されます。

|プロパティ|[タイプ](/manual/api/reference_commentary#data_types)|説明|
|--|--|------|
|uptime|integer|スケジュールされた稼働時間中にサービスが _OK_ 状態であった時間から、除外されたダウンタイムを差し引いた値|
|downtime|integer|スケジュールされた稼働時間中にサービスが _not OK_ 状態であった時間から、除外されたダウンタイムを差し引いた値|
|sli|float|稼働時間とダウンタイムに基づく SLI（総稼働時間の割合）|
|error\_budget|integer|SLI と SLO に基づくエラー バジェット（秒単位）|
|excluded\_downtimes|array|このレポート期間に除外されたダウンタイムの配列<br><br>各オブジェクトには、次のパラメーターが含まれます。<br>- `name` - 除外されたダウンタイムの名前<br>- `period_from` - 除外されたダウンタイムの開始日時 (含む)<br>- `period_to` - 除外されたダウンタイムの終了日時 (含まない)<br><br>除外されたダウンタイムは、period_from フィールドで昇順に並べ替えられます。|

[comment]: # ({/aa24c098-ba0b5441})

[comment]: # ({b41637d2-b41637d2})
### 例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({new-610cd288})
#### Calculating SLI for a daily SLA

Retrieve SLI data for services with IDs "1" and "4" that are linked to the SLA with ID "1".
Retrieve data for a single period until "1761861599" (Oct 30 2025 23:59:59 GMT+0200).
Since the [reporting period](/manual/it_services/sla) of the SLA is daily, SLI data is retrieved from "1761775200" (Oct 30 2025 00:00:00 GMT+0200) to "1761861600" (Oct 31 2025 00:00:00 GMT+0200).

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "sla.getsli",
    "params": {
        "slaid": "1",
        "serviceids": [
            1,
            4
        ],
        "periods": 1,
        "period_to": 1761861599,
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "periods": [
            {
                "period_from": 1761775200,
                "period_to": 1761861600
            }
        ],
        "serviceids": [
            1,
            4
        ],
        "sli": [
            [
                {
                    "uptime": 43843,
                    "downtime": 0,
                    "sli": 100,
                    "error_budget": 0,
                    "excluded_downtimes": [
                        {
                            "name": "Maintenance OCT",
                            "period_from": 1761825600,
                            "period_to": 1761829200
                        }
                    ]
                },
                {
                    "uptime": 32225,
                    "downtime": 0,
                    "sli": 100,
                    "error_budget": 0,
                    "excluded_downtimes": []
                }
            ]
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-610cd288})

[comment]: # ({16e0ca76-c6c818e1})
#### SLIの計算

ID"5"のSLAにリンクされているID"50"、"60"、"70"のサービスのSLIデータを取得します。
2021年11月1日から3期間のデータを取得します。

[リクエスト](/manual/api#performing-requests) :

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

レスポンス :

```json
{
    "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
}
```

[comment]: # ({/16e0ca76-c6c818e1})

[comment]: # ({13a91d62-a5414084})
### ソース

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

[comment]: # ({/13a91d62-a5414084})
