/api/annotation

这些端点提供了一种添加,编辑或删除存储在 OpenTSDB 后端中的 Comments 的方法。注解是非常基本的对象,用于在某个点记录任意事件的 Comments,并可选地与时间序列关联。Comments 并不打算用作基于跟踪或事件的系统,而是通过在图形上显示通知或通过 API 查询调用来提供到此类系统的链接很有用。

在创建,修改或删除 Comments 时,所有更改都将传播到搜索插件(如果已配置)。

CommentsAPI 端点

默认的/annotation端点一次处理一个符号。 /annotation/bulk端点允许一次添加或更新多个 Comments。

Verbs

Requests

所有 Comments 均由startTime字段和可选的tsuid字段标识。每个音符可以是全局的,这意味着它与所有时间序列相关联,也可以是局部的,这意味着它与特定的 tsuid 相关联。如果未提供 tsuid 或其值为空,则 Comments 将被视为全局 Comments。

Name Data Type Required Description Default QS RW Example
startTime Integer Required Unix 纪元时间戳,以秒为单位,标记应记录 Comments 事件的时间 start_time RW 1369141261
endTime Integer Optional 事件的可选结束时间(如果已完成或已解决) 0 end_time RW 1369141262
tsuid String Optional TSUID(如果 Comments 与时间序列关联)。如果 Comments 用于全局事件,则可以为 null 或为空 tsuid RW 000001000001000001
description String Optional 事件的简短描述。由于这可能会出现在 GnuPlot 图表上,因此说明应非常简短,最好少于 25 个字符。 description RW Network Outage
notes String Optional 有关事件的详细说明 notes RW 开关#5 死亡并被更换
custom Map Optional 键/值 Map 表,用于存储自定义字段和值 null RW See Below

Note

自定义字段不能通过查询字符串传递。您必须使用POSTPUT动词。

Warning

如果您的请求使用PUT,那么您未随请求提供的任何字段都将被其默认值覆盖。例如,description字段将被设置为空字符串,而custom字段将被重置为null

GET 请求示例

http://localhost:4242/api/annotation?start_time=1369141261&tsuid=000001000001000001

POST 请求示例

{
  "startTime":"1369141261",
  "tsuid":"000001000001000001",
  "description": "Testing Annotations",
  "notes": "These would be details about the event, the description is just a summary",
  "custom": {
      "owner": "jdoe",
      "dept": "ops"
  }
}

Response

GETPOSTPUT请求的成功响应将返回具有请求的更改的完整对象。成功的DELETE呼叫将返回204状态代码且没有正文。修改数据时,如果不存在任何更改,即调用未提供要存储的任何数据,则响应将为304而没有任何正文内容。如果系统中不存在所请求的 Comments,则会返回404并显示错误消息。如果提供了无效数据,将返回400错误。

Example Response

{
    "tsuid": "000001000001000001",
    "description": "Testing Annotations",
    "notes": "These would be details about the event, the description is just a summary",
    "custom": {
        "owner": "jdoe",
        "dept": "ops"
    },
    "endTime": 0,
    "startTime": 1369141261
}
首页