

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Amazon Managed Service for Prometheus API Reference
<a name="AMP-APIReference"></a>

Amazon Managed Service for Prometheus は、次の 2 種類の API を提供しています。

1. **Amazon Managed Service for Prometheus API** - これらの API を使用すると、ワークスペース、スクレイパー、アラートマネージャー定義、ルールグループ名前空間、ログ記録用のオペレーションなどを含め、Amazon Managed Service for Prometheus ワークスペースを作成および管理できます。これらの API を操作するには、さまざまなプログラミング言語で利用できる AWS SDK を使用します。

1. **Prometheus 互換 API** - Amazon Managed Service for Prometheus は、Prometheus と互換性のある HTTP API をサポートしています。これらの API を使用すると、カスタムアプリケーションの構築、ワークフローの自動化、他のサービスやツールとの統合、Prometheus クエリ言語 (PromQL) を使用したモニタリングデータのクエリと操作が可能になります。

このセクションでは、Amazon Managed Service for Prometheus でサポートされる API オペレーションとデータ構造の一覧を示します。

シリーズ、ラベル、API リクエストのクォータについては、「*Amazon Managed Service for Prometheus ユーザーガイド*」の「[Amazon Managed Service for Prometheus のサービスクォータ](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP_quotas.html)」を参照してください。

**Topics**
+ [Amazon Managed Service for Prometheus API](AMP-APIReference-AMPApis.md)
+ [Prometheus 互換 API](AMP-APIReference-Prometheus-Compatible-Apis.md)

# Amazon Managed Service for Prometheus API
<a name="AMP-APIReference-AMPApis"></a>

Amazon Managed Service for Prometheus は、Amazon Managed Service for Prometheus ワークスペースを作成および管理する API オペレーションを提供しています。これには、ワークスペース、スクレイパー、アラートマネージャー定義、ルールグループ名前空間、ログ記録用の API が含まれます。

Amazon Managed Service for Prometheus API の詳細については、「[Amazon Managed Service for Prometheus API Reference](https://docs.aws.amazon.com/prometheus/latest/APIReference/Welcome.html)」を参照してください。

## AWS SDK での Amazon Managed Service for Prometheus の使用
<a name="AMP-APIReference-SDKs"></a>

AWS Software Development Kit (SDK) は、多くの一般的なプログラミング言語で使用できます。各 SDK には、デベロッパーが好みの言語で AWS アプリケーションを簡単に構築できるようにする API、コード例、およびドキュメントが提供されています。言語別の SDK とツールのリストについては、「AWS *デベロッパーセンター*」の「[AWS での構築ツール](https://aws.amazon.com/developer/tools/)」を参照してください。

**SDK のバージョン**  
プロジェクトで使用する AWS SDK やその他の SDK は最新ビルドを使用し、SDK を最新の状態に保つことをお勧めします。AWS SDK には、最新の特長と機能に加え、セキュリティアップデートも含まれています。

# Prometheus 互換 API
<a name="AMP-APIReference-Prometheus-Compatible-Apis"></a>

Amazon Managed Service for Prometheus では、以下の Prometheus 互換 API がサポートされています。

 Prometheus 互換 API の使用方法の詳細については、「[Prometheus 互換 API を使用したクエリ](AMP-onboard-query-APIs.md)」を参照してください。

**Topics**
+ [CreateAlertManagerAlerts](AMP-APIReference-CreateAlertManagerAlerts.md)
+ [DeleteAlertManagerSilence](AMP-APIReference-DeleteSilence.md)
+ [GetAlertManagerStatus](AMP-APIReference-GetAlertManagerStatus.md)
+ [GetAlertManagerSilence](AMP-APIReference-GetAlertManagerSilence.md)
+ [GetLabels](AMP-APIReference-GetLabels.md)
+ [GetMetricMetadata](AMP-APIReference-GetMetricMetadata.md)
+ [GetSeries](AMP-APIReference-GetSeries.md)
+ [ListAlerts](AMP-APIReference-ListAlerts.md)
+ [ListAlertManagerAlerts](AMP-APIReference-ListAlertManagerAlerts.md)
+ [ListAlertManagerAlertGroups](AMP-APIReference-ListAlertManagerAlertGroups.md)
+ [ListAlertManagerReceivers](AMP-APIReference-ListAlertManagerReceivers.md)
+ [ListAlertManagerSilences](AMP-APIReference-ListAlertManagerSilences.md)
+ [ListRules](AMP-APIReference-ListRules.md)
+ [PutAlertManagerSilences](AMP-APIReference-PutAlertManagerSilences.md)
+ [QueryMetrics](AMP-APIReference-QueryMetrics.md)
+ [RemoteWrite](AMP-APIReference-RemoteWrite.md)

# CreateAlertManagerAlerts
<a name="AMP-APIReference-CreateAlertManagerAlerts"></a>

`CreateAlertManagerAlerts` オペレーションは、ワークスペースにアラートを作成します。

有効な HTTP 動詞:  
`POST`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/alerts`

URL クエリパラメータ:  
`alerts` オブジェクトの配列。各オブジェクトは 1 つのアラートを表します。アラートブジェクトの例を以下に示します。  

```
[
  {
    "startsAt": "2021-09-24T17:14:04.995Z",
    "endsAt": "2021-09-24T17:14:04.995Z",
    "annotations": {
      "additionalProp1": "string",
      "additionalProp2": "string",
      "additionalProp3": "string"
    },
    "labels": {
      "additionalProp1": "string",
      "additionalProp2": "string",
      "additionalProp3": "string"
    },
    "generatorURL": "string"
  }
]
```

**リクエスト例**

```
POST /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/alerts HTTP/1.1
Content-Length: 203, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0

[
  {
    "labels": {
      "alertname": "test-alert"
    },
    "annotations": {
      "summary": "this is a test alert used for demo purposes"
    },
    "generatorURL": "https://www.amazon.com/"
  }
]
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 0
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin
```

# DeleteAlertManagerSilence
<a name="AMP-APIReference-DeleteSilence"></a>

`DeleteSilence` は、1 つのアラートサイレンスを削除します。

有効な HTTP 動詞:  
`DELETE`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/silence/silenceID`

URL クエリパラメータ: なし  


**リクエスト例**

```
DELETE /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/silence/d29d9df3-9125-4441-912c-70b05f86f973 HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 0
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin
```

# GetAlertManagerStatus
<a name="AMP-APIReference-GetAlertManagerStatus"></a>

`GetAlertManagerStatus` は、アラートマネージャーのステータスに関する情報を取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/status`

URL クエリパラメータ: なし  


**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/status HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 941
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
    "cluster": null,
    "config": {
        "original": "global:\n  resolve_timeout: 5m\n  http_config:\n    follow_redirects: true\n  smtp_hello: localhost\n  smtp_require_tls: true\nroute:\n  receiver: sns-0\n  group_by:\n  - label\n  continue: false\nreceivers:\n- name: sns-0\n  sns_configs:\n  - send_resolved: false\n    http_config:\n      follow_redirects: true\n    sigv4: {}\n    topic_arn: arn:aws:sns:us-west-2:123456789012:test\n    subject: '{{ template \"sns.default.subject\" . }}'\n    message: '{{ template \"sns.default.message\" . }}'\n    workspace_arn: arn:aws:aps:us-west-2:123456789012:workspace/ws-58a6a446-5ec4-415b-9052-a449073bbd0a\ntemplates: []\n"
    },
    "uptime": null,
    "versionInfo": null
}
```

# GetAlertManagerSilence
<a name="AMP-APIReference-GetAlertManagerSilence"></a>

`GetAlertManagerSilence` は、1 つのアラートサイレンスに関する情報を取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/silence/silenceID`

URL クエリパラメータ: なし  


**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/silence/d29d9df3-9125-4441-912c-70b05f86f973 HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 310
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
    "id": "d29d9df3-9125-4441-912c-70b05f86f973",
    "status": {
        "state": "active"
    },
    "updatedAt": "2021-10-22T19:32:11.763Z",
    "comment": "hello-world",
    "createdBy": "test-person",
    "endsAt": "2023-07-24T01:05:36.000Z",
    "matchers": [
        {
            "isEqual": true,
            "isRegex": true,
            "name": "job",
            "value": "hello"
        }
    ],
    "startsAt": "2021-10-22T19:32:11.763Z"
}
```

# GetLabels
<a name="AMP-APIReference-GetLabels"></a>

`GetLabels` オペレーションは、時系列に関連付けられているラベルを取得します。

有効な HTTP 動詞:  
`GET`, `POST`

有効な URI:  
`/workspaces/workspaceId/api/v1/labels`  
`/workspaces/workspaceId/api/v1/label/label-name/values` この URI は GET リクエストのみをサポートします。

URL クエリパラメータ:  
`match[]=<series_selector>` ラベル名を読み取るシリーズを選択する、シリーズセレクターの繰り返しを含む引数。オプション。  
`start=<rfc3339 | unix_timestamp>` 開始タイムスタンプ。オプション。  
`end=<rfc3339 | unix_timestamp>` 終了タイムスタンプ。オプションです。

**`/workspaces/workspaceId/api/v1/labels` のサンプルリクエスト**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/labels HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**`/workspaces/workspaceId/api/v1/labels` のサンプル応答**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 1435
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
    "status": "success",
    "data": [
        "__name__",
        "access_mode",
        "address",
        "alertname",
        "alertstate",
        "apiservice",
        "app",
        "app_kubernetes_io_instance",
        "app_kubernetes_io_managed_by",
        "app_kubernetes_io_name",
        "area",
        "beta_kubernetes_io_arch",
        "beta_kubernetes_io_instance_type",
        "beta_kubernetes_io_os",
        "boot_id",
        "branch",
        "broadcast",
        "buildDate",
        ...
    ]
}
```

**`/workspaces/workspaceId/api/v1/label/label-name/values` のサンプルリクエスト**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/label/access_mode/values HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**`/workspaces/workspaceId/api/v1/label/label-name/values` のサンプル応答**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 74
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
    "status": "success",
    "data": [
        "ReadWriteOnce"
    ]
}
```

# GetMetricMetadata
<a name="AMP-APIReference-GetMetricMetadata"></a>

`GetMetricMetadata` オペレーションは、現在ターゲットからスクレイピングされているメトリクスに関するメタデータを取得します。ターゲット情報は提供されません。

クエリ結果のデータセクションはオブジェクトで構成されます。各オブジェクトのキーはメトリクス名を表し、値には、そのメトリクス名で公開されている固有のメタデータオブジェクトが、すべてのターゲットにわたるリストとして含まれます。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/api/v1/metadata`

URL クエリパラメータ:  
`limit=<number>` 取得するメトリクスの最大数。  
`metric=<string>` メタデータをフィルタリングするメトリクス名。空のままにすると、すべてのメトリクスメタデータが取得されます。

**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/metadata HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
Transfer-Encoding: chunked

{
    "status": "success",
    "data": {
        "aggregator_openapi_v2_regeneration_count": [
            {
                "type": "counter",
                "help": "[ALPHA] Counter of OpenAPI v2 spec regeneration count broken down by causing APIService name and reason.",
                "unit": ""
            }
        ],
        ...
    }
}
```

# GetSeries
<a name="AMP-APIReference-GetSeries"></a>

`GetSeries` オペレーションは、特定のラベルセットに一致する時系列のリストを取得します。

有効な HTTP 動詞:  
`GET`, `POST`

有効な URI:  
`/workspaces/workspaceId/api/v1/series`

URL クエリパラメータ:  
`match[]=<series_selector>` 取得するシリーズを選択する、シリーズセレクターの繰り返しを含む引数。少なくとも 1 つの `match[]` 引数を指定する必要があります。  
`start=<rfc3339 | unix_timestamp>` 開始タイムスタンプ。オプションです。  
`end=<rfc3339 | unix_timestamp>` 終了タイムスタンプ。オプションです。

**リクエスト例**

```
POST /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/series --data-urlencode 'match[]=node_cpu_seconds_total{app="prometheus"}' --data-urlencode 'start=1634936400' --data-urlencode 'end=1634939100' HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
content-encoding: gzip

{
    "status": "success",
    "data": [
        {
            "__name__": "node_cpu_seconds_total",
            "app": "prometheus",
            "app_kubernetes_io_managed_by": "Helm",
            "chart": "prometheus-11.12.1",
            "cluster": "cluster-1",
            "component": "node-exporter",
            "cpu": "0",
            "heritage": "Helm",
            "instance": "10.0.100.36:9100",
            "job": "kubernetes-service-endpoints",
            "kubernetes_name": "servicesstackprometheuscf14a6d7-node-exporter",
            "kubernetes_namespace": "default",
            "kubernetes_node": "ip-10-0-100-36.us-west-2.compute.internal",
            "mode": "idle",
            "release": "servicesstackprometheuscf14a6d7"
        },
        {
            "__name__": "node_cpu_seconds_total",
            "app": "prometheus",
            "app_kubernetes_io_managed_by": "Helm",
            "chart": "prometheus-11.12.1",
            "cluster": "cluster-1",
            "component": "node-exporter",
            "cpu": "0",
            "heritage": "Helm",
            "instance": "10.0.100.36:9100",
            "job": "kubernetes-service-endpoints",
            "kubernetes_name": "servicesstackprometheuscf14a6d7-node-exporter",
            "kubernetes_namespace": "default",
            "kubernetes_node": "ip-10-0-100-36.us-west-2.compute.internal",
            "mode": "iowait",
            "release": "servicesstackprometheuscf14a6d7"
        },
        ...
    ]
}
```

# ListAlerts
<a name="AMP-APIReference-ListAlerts"></a>

`ListAlerts` オペレーションは、ワークスペースで現在アクティブなアラートを取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/api/v1/alerts`

**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/alerts HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 386
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
  "status": "success",
  "data": {
    "alerts": [
      {
        "labels": {
          "alertname": "test-1.alert",
          "severity": "none"
        },
        "annotations": {
          "message": "message"
        },
        "state": "firing",
        "activeAt": "2020-12-01T19:37:25.429565909Z",
        "value": "1e+00"
      }
    ]
  },
  "errorType": "",
  "error": ""
}
```

# ListAlertManagerAlerts
<a name="AMP-APIReference-ListAlertManagerAlerts"></a>

`ListAlertManagerAlerts` は、ワークスペースのアラートマネージャーで現在発生しているアラートに関する情報を取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/alerts`

**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/alerts HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 354
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

[
    {
        "annotations": {
            "summary": "this is a test alert used for demo purposes"
        },
        "endsAt": "2021-10-21T22:07:31.501Z",
        "fingerprint": "375eab7b59892505",
        "receivers": [
            {
                "name": "sns-0"
            }
        ],
        "startsAt": "2021-10-21T22:02:31.501Z",
        "status": {
            "inhibitedBy": [],
            "silencedBy": [],
            "state": "active"
        },
        "updatedAt": "2021-10-21T22:02:31.501Z",
        "labels": {
            "alertname": "test-alert"
        }
    }
]
```

# ListAlertManagerAlertGroups
<a name="AMP-APIReference-ListAlertManagerAlertGroups"></a>

`ListAlertManagerAlertGroups` オペレーションは、ワークスペースのアラートマネージャーで構成されているアラートグループのリストを取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/alerts/groups`

URL クエリパラメータ:  
`active` ブール値。true の場合、返されるリストにはアクティブなアラートが含まれます。デフォルトは True です。オプションです。  
`silenced` ブール値。true の場合、返されるリストには無音のアラートが含まれます。デフォルトは True です。オプションです。  
`inhibited` ブール値。true の場合、返されるリストには禁止されたアラートが含まれます。デフォルトは True です。オプションです。  
`filter` 文字列の配列。アラートをフィルタリングするマッチャーのリスト。オプションです。  
`receiver` 文字列。アラートをフィルタリングするレシーバーに一致する正規表現。オプションです。

**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/alerts/groups HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 443
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

[
    {
        "alerts": [
            {
                "annotations": {
                    "summary": "this is a test alert used for demo purposes"
                },
                "endsAt": "2021-10-21T22:07:31.501Z",
                "fingerprint": "375eab7b59892505",
                "receivers": [
                    {
                        "name": "sns-0"
                    }
                ],
                "startsAt": "2021-10-21T22:02:31.501Z",
                "status": {
                    "inhibitedBy": [],
                    "silencedBy": [],
                    "state": "unprocessed"
                },
                "updatedAt": "2021-10-21T22:02:31.501Z",
                "generatorURL": "https://www.amazon.com/",
                "labels": {
                    "alertname": "test-alert"
                }
            }
        ],
        "labels": {},
        "receiver": {
            "name": "sns-0"
        }
    }
]
```

# ListAlertManagerReceivers
<a name="AMP-APIReference-ListAlertManagerReceivers"></a>

`ListAlertManagerReceivers` オペレーションは、アラートマネージャーで構成されているレシーバーに関する情報を取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/receivers`

URL クエリパラメータ: なし  


**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/receivers HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 19
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

[
    {
        "name": "sns-0"
    }
]
```

# ListAlertManagerSilences
<a name="AMP-APIReference-ListAlertManagerSilences"></a>

`ListAlertManagerSilences` は、ワークスペースに構成されているアラートサイレンスに関する情報を取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/silences`

**リクエスト例**

```
GET /workspaces/ws-58a6a446-5ec4-415b-9052-a449073bbd0a/alertmanager/api/v2/silences HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 312
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

[
    {
        "id": "d29d9df3-9125-4441-912c-70b05f86f973",
        "status": {
            "state": "active"
        },
        "updatedAt": "2021-10-22T19:32:11.763Z",
        "comment": "hello-world",
        "createdBy": "test-person",
        "endsAt": "2023-07-24T01:05:36.000Z",
        "matchers": [
            {
                "isEqual": true,
                "isRegex": true,
                "name": "job",
                "value": "hello"
            }
        ],
        "startsAt": "2021-10-22T19:32:11.763Z"
    }
]
```

# ListRules
<a name="AMP-APIReference-ListRules"></a>

`ListRules` は、ワークスペースに構成されているルールに関する情報を取得します。

有効な HTTP 動詞:  
`GET`

有効な URI:  
`/workspaces/workspaceId/api/v1/rules`

**リクエスト例**

```
GET /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/rules HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 423
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
    "status": "success",
    "data": {
        "groups": [
            {
                "name": "test-1.rules",
                "file": "test-rules",
                "rules": [
                    {
                        "name": "record:1",
                        "query": "sum(rate(node_cpu_seconds_total[10m:1m]))",
                        "labels": {},
                        "health": "ok",
                        "lastError": "",
                        "type": "recording",
                        "lastEvaluation": "2021-10-21T21:22:34.429565909Z",
                        "evaluationTime": 0.001005399
                    }
                ],
                "interval": 60,
                "lastEvaluation": "2021-10-21T21:22:34.429563992Z",
                "evaluationTime": 0.001010504
            }
        ]
    },
    "errorType": "",
    "error": ""
}
```

# PutAlertManagerSilences
<a name="AMP-APIReference-PutAlertManagerSilences"></a>

`PutAlertManagerSilences` オペレーションは、新しいアラートサイレンスの作成または既存のアラートサイレンスの更新を行います。

有効な HTTP 動詞:  
`POST`

有効な URI:  
`/workspaces/workspaceId/alertmanager/api/v2/silences`

URL クエリパラメータ:  
`silence` サイレンスを表すオブジェクト。形式を次に示します。  

```
{
  "id": "string",
  "matchers": [
    {
      "name": "string",
      "value": "string",
      "isRegex": Boolean,
      "isEqual": Boolean
    }
  ],
  "startsAt": "timestamp",
  "endsAt": "timestamp",
  "createdBy": "string",
  "comment": "string"
}
```

**リクエスト例**

```
POST /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/alertmanager/api/v2/silences HTTP/1.1
Content-Length: 281, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0

{
   "matchers":[
      {
         "name":"job",
         "value":"up",
         "isRegex":false,
         "isEqual":true
      }
   ],
   "startsAt":"2020-07-23T01:05:36+00:00",
   "endsAt":"2023-07-24T01:05:36+00:00",
   "createdBy":"test-person",
   "comment":"test silence"
}
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 53
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin

{
    "silenceID": "512860da-74f3-43c9-8833-cec026542b32"
}
```

# QueryMetrics
<a name="AMP-APIReference-QueryMetrics"></a>

`QueryMetrics` オペレーションは、特定の時点において、または一定期間にわたってインスタントクエリを評価します。

有効な HTTP 動詞:  
`GET`, `POST`

有効な URI:  
`/workspaces/workspaceId/api/v1/query` この URI は、特定の時点でインスタントクエリを評価します。  
`/workspaces/workspaceId/api/v1/query_range` この URI は、一定期間にわたってインスタントクエリを評価します。

URL クエリパラメータ:  
`query=<string>` Prometheus 式のクエリ文字列。`query` と `query_range` の両方で使用されます。  
`time=<rfc3339 | unix_timestamp>` (オプション) `query` を使用して特定の時点でインスタントクエリを評価する場合、評価のタイムスタンプ。  
`timeout=<duration>` (オプション) 評価のタイムアウト。デフォルトは `-query.timeout` フラグの値で、この値が上限になります。`query` と `query_range` の両方で使用されます。  
`start=<rfc3339 | unix_timestamp>` `query_range` を使用して一定期間にわたってクエリを評価する場合、開始タイムスタンプ。  
`end=<rfc3339 | unix_timestamp>` `query_range` を使用して一定期間にわたってクエリを評価する場合、終了タイムスタンプ。  
`step=<duration | float>` クエリの解決ステップ幅 (`duration` 形式または `float` の秒数)。`query_range` を使用して一定期間にわたってクエリを評価するときに、そのクエリで必要とされる場合にのみ使用します。  
`max_samples_processed_warning_threshold=<integer>` (オプション) 処理されたクエリサンプル (QSP) の警告しきい値を設定します。クエリがこのしきい値に達すると、API レスポンスに警告メッセージが表示されます。  
`max_samples_processed_error_threshold=<integer>>` (オプション) 処理されたクエリサンプル (QSP) のエラーしきい値を設定します。このしきい値を超えるクエリはエラーで拒否され、課金されません。過剰なクエリコストを防ぐために使用されます。

**duration**

Prometheus 互換 API の `duration` には、数値に続けて以下の単位のいずれかを指定します。
+ `ms` ミリ秒
+ `s` 秒
+ `m` 分
+ `h` 時間
+ `d` 日 (1 日は常に 24h と想定)
+ `w` 週 (1 週間は常に 7d と想定)
+ `y` 年 (1 年は常に 365d と想定)

**リクエスト例**

```
POST /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/query?query=sum(node_cpu_seconds_total) HTTP/1.1
Content-Length: 0, 
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Grafana/8.1.0
```

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length: 132
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
content-encoding: gzip

{
    "status": "success",
    "data": {
        "resultType": "vector",
        "result": [
            {
                "metric": {},
                "value": [
                    1634937046.322,
                    "252590622.81000024"
                ]
            }
        ]
    }
}
```

# RemoteWrite
<a name="AMP-APIReference-RemoteWrite"></a>

`RemoteWrite` オペレーションは、Prometheus サーバーからリモート URL にメトリクスを標準化された形式で書き込みます。通常、このオペレーションを呼び出すには、Prometheus サーバーなどの既存のクライアントを使用します。

有効な HTTP 動詞:  
`POST`

有効な URI:  
`/workspaces/workspaceId/api/v1/remote_write`

URL クエリパラメータ:  
なし

`RemoteWrite` での取り込みレートは 70,000 サンプル/秒、取り込みバーストサイズは 1,000,000 サンプルです。

**リクエスト例**

```
POST /workspaces/ws-b226cc2a-a446-46a9-933a-ac50479a5568/api/v1/remote_write --data-binary "@real-dataset.sz" HTTP/1.1
Authorization: AUTHPARAMS
X-Amz-Date: 20201201T193725Z
User-Agent: Prometheus/2.20.1
Content-Type: application/x-protobuf
Content-Encoding: snappy
X-Prometheus-Remote-Write-Version: 0.1.0

body
```

**注記**  
リクエスト本文の構文については、[https://github.com/prometheus/prometheus/blob/1c624c58ca934f618be737b4995e22051f5724c1/prompb/remote.pb.go\$1L64](https://github.com/prometheus/prometheus/blob/1c624c58ca934f618be737b4995e22051f5724c1/prompb/remote.pb.go#L64) のプロトコルバッファの定義を参照してください。

**レスポンス例**

```
HTTP/1.1 200 OK
x-amzn-RequestId: 12345678-abcd-4442-b8c5-262b45e9b535
Content-Length:0
Connection: keep-alive
Date: Tue, 01 Dec 2020 19:37:25 GMT
Content-Type: application/json
Server: amazon
vary: Origin
```