304.md 1.9 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
# Dashboard annotations API

> 原文:[https://docs.gitlab.com/ee/api/metrics_dashboard_annotations.html](https://docs.gitlab.com/ee/api/metrics_dashboard_annotations.html)

*   [Create a new annotation](#create-a-new-annotation)

# Dashboard annotations API[](#dashboard-annotations-api "Permalink")

版本历史

*   在 GitLab 12.10 中在禁用的功能标志后面[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29089) .

指标仪表板注释使您可以在单个时间点或整个时间段内指示图形上的事件.

## Create a new annotation[](#create-a-new-annotation "Permalink")

```
POST /environments/:id/metrics_dashboard/annotations/
POST /clusters/:id/metrics_dashboard/annotations/ 
```

**注意:** `dashboard_path`的值将被视为 CGI 转义的路径,并自动取消转义.

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `dashboard_path` | string | yes | 需要注释的仪表盘的 ID. |
| `starting_at` | string | yes | 日期时间字符串,ISO 8601 格式,例如`2016-03-11T03:45:40Z` . 注释的时间戳标记起点. |
| `ending_at` | string | no | 日期时间字符串,ISO 8601 格式,例如`2016-03-11T03:45:40Z` . 注释的时间戳标记终点. 如果未提供,注释将在起点显示为单个事件. |
| `description` | string | yes | 注释的描述. |

```
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/environments/1/metrics_dashboard/annotations" \
 --data-urlencode "dashboard_path=.gitlab/dashboards/custom_metrics.yml" \
 --data-urlencode "starting_at=2016-03-11T03:45:40Z" \
 --data-urlencode "description=annotation description" 
```

示例响应:

```
{  "id":  4,  "starting_at":  "2016-04-08T03:45:40.000Z",  "ending_at":  null,  "dashboard_path":  ".gitlab/dashboards/custom_metrics.yml",  "description":  "annotation description",  "environment_id":  1,  "cluster_id":  null  } 
```