

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

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

`GetLabels` 操作检索与时间序列关联的标签。

有效的 HTTP 动词：  
`GET`, `POST`

有效 URIs：  
`/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"
    ]
}
```