On this page
/api/search
该端点提供了搜索 OpenTSDB 元数据的基本方法。启用后,可以针对tsdb-meta
表执行查找。 (可选)可以安装搜索插件,以从外部搜索索引服务(例如 Elastic Search)发送和检索信息。由每个搜索插件来实现此终结点的各个部分并以一致的格式返回数据。搜索和返回的对象类型取决于所选的端点。
Note
如果未配置或启用该插件,则/api/search/lookup
以外的端点将返回异常。
搜索 API 端点
/ api/search/tsmeta-TSMETA Response
/ api/search/tsmeta_summary-TSMETA_SUMMARY Response
/ api/search/tsuids-TSUIDS Response
/ api/search/uidmeta-UIDMETA Response
/ api/search /Comments-Annotation Response
Verbs
GET
POST
Requests
搜索端点使用的参数包括:
Name | Data Type | Required | Description | Default | QS | RW | Example |
---|---|---|---|---|---|---|---|
query | String | Optional | 基于字符串的查询传递给搜索引擎。引擎或插件将对此进行解析以执行实际搜索。允许的值取决于插件。忽略查找。 | query | name:sys.cpu.* | ||
limit | Integer | Optional | 限制每个查询返回的结果数,以免覆盖 TSD 或搜索引擎。允许的值取决于插件。忽略查找。 | 25 | limit | 100 | |
startIndex | Integer | Optional | 与limit 值结合使用以翻阅结果。允许的值取决于插件。忽略查找。 |
0 | start_index | 42 | |
metric | String | Optional | 查找查询的度量标准或通配符的名称 | * | metric | tsd.hbase.rpcs | |
tags | Array | Optional | 具有用于查询查询的标签名称和/或标签值的一个或多个键/值对象。见/api/search/lookup | tags | See /api/search/lookup |
Example Request
Query String:
http://localhost:4242/api/search/tsmeta?query=name:*&limit=3&start_index=0
POST:
{
"query": "name:*",
"limit": 4,
"startIndex": 5
}
Response
根据调用的端点,输出将略有变化。但是,常见的字段包括:
Name | Data Type | Description | Example |
---|---|---|---|
type | String | 提交的查询类型,即调用的端点。将是上面列出的端点之一。 | TSMETA |
query | String | 查询字符串已提交。可以通过插件更改 | name:sys.cpu.* |
limit | Integer | 结果集中返回的最大项目数。请注意,返回的实际数字可能小于限制。 | 25 |
startIndex | Integer | 查询中提供的当前结果集的起始索引 | 0 |
metric | String | 用于查找的 Metrics | |
tags | Array | 用于查找查询的标记对列表。可能是一个空列表。 | [ ] |
time | Integer | 完成查询所花费的时间(以毫秒为单位) | 120 |
totalResults | Integer | 查询匹配的结果总数 | 1024 |
results | Array | 结果集。格式取决于请求的端点。 | See Below |
该端点几乎总是返回带有内容主体的200
。如果查询不匹配任何结果,则results
字段将为空数组,而totalResults
将为 0.如果发生错误(例如,插件被禁用或未配置),则将返回异常。
TSMETA Response
TSMeta 端点返回匹配的 TSMeta 对象的列表。
{
"type": "TSMETA",
"query": "name:*",
"metric": "*",
"tags": [],
"limit": 2,
"time": 675,
"results": [
{
"tsuid": "0000150000070010D0",
"metric": {
"uid": "000015",
"type": "METRIC",
"name": "app.apache.connections",
"description": "",
"notes": "",
"created": 1362655264,
"custom": null,
"displayName": ""
},
"tags": [
{
"uid": "000007",
"type": "TAGK",
"name": "fqdn",
"description": "",
"notes": "",
"created": 1362655264,
"custom": null,
"displayName": ""
},
{
"uid": "0010D0",
"type": "TAGV",
"name": "web01.mysite.com",
"description": "",
"notes": "",
"created": 1362720007,
"custom": null,
"displayName": ""
}
],
"description": "",
"notes": "",
"created": 1362740528,
"units": "",
"retention": 0,
"max": 0,
"min": 0,
"displayName": "",
"dataType": "",
"lastReceived": 0,
"totalDatapoints": 0
},
{
"tsuid": "0000150000070010D5",
"metric": {
"uid": "000015",
"type": "METRIC",
"name": "app.apache.connections",
"description": "",
"notes": "",
"created": 1362655264,
"custom": null,
"displayName": ""
},
"tags": [
{
"uid": "000007",
"type": "TAGK",
"name": "fqdn",
"description": "",
"notes": "",
"created": 1362655264,
"custom": null,
"displayName": ""
},
{
"uid": "0010D5",
"type": "TAGV",
"name": "web02.mysite.com",
"description": "",
"notes": "",
"created": 1362720007,
"custom": null,
"displayName": ""
}
],
"description": "",
"notes": "",
"created": 1362882263,
"units": "",
"retention": 0,
"max": 0,
"min": 0,
"displayName": "",
"dataType": "",
"lastReceived": 0,
"totalDatapoints": 0
}
],
"startIndex": 0,
"totalResults": 9688066
}
TSMETA_SUMMARY Response
TSMeta 摘要端点仅返回与时间序列相关的基本信息,包括 TSUID,度量标准名称和标记。搜索针对与 TSMeta 查询相同的索引运行,但返回数据的子集。
{
"type": "TSMETA_SUMMARY",
"query": "name:*",
"metric": "*",
"tags": [],
"limit": 3,
"time": 565,
"results": [
{
"tags": {
"fqdn": "web01.mysite.com"
},
"metric": "app.apache.connections",
"tsuid": "0000150000070010D0"
},
{
"tags": {
"fqdn": "web02.mysite.com"
},
"metric": "app.apache.connections",
"tsuid": "0000150000070010D5"
},
{
"tags": {
"fqdn": "web03.mysite.com"
},
"metric": "app.apache.connections",
"tsuid": "0000150000070010D6"
}
],
"startIndex": 0,
"totalResults": 9688066
}
TSUIDS Response
TSUIDs 端点返回与查询匹配的 TSUIDS 列表。搜索针对与 TSMeta 查询相同的索引运行,但返回数据的子集。
{
"type": "TSUIDS",
"query": "name:*",
"metric": "*",
"tags": [],
"limit": 3,
"time": 517,
"results": [
"0000150000070010D0",
"0000150000070010D5",
"0000150000070010D6"
],
"startIndex": 0,
"totalResults": 9688066
}
UIDMETA Response
UIDMeta 端点返回与查询匹配的 UIDMeta 对象的列表。
{
"type": "UIDMETA",
"query": "name:*",
"metric": "*",
"tags": [],
"limit": 3,
"time": 517,
"results": [
{
"uid": "000007",
"type": "TAGK",
"name": "fqdn",
"description": "",
"notes": "",
"created": 1362655264,
"custom": null,
"displayName": ""
},
{
"uid": "0010D0",
"type": "TAGV",
"name": "web01.mysite.com",
"description": "",
"notes": "",
"created": 1362720007,
"custom": null,
"displayName": ""
},
{
"uid": "0010D5",
"type": "TAGV",
"name": "web02.mysite.com",
"description": "",
"notes": "",
"created": 1362720007,
"custom": null,
"displayName": ""
}
],
"startIndex": 0,
"totalResults": 9688066
}
Annotation Response
Annotation 端点返回与查询匹配的 Annotation 对象的列表。
{
"type": "ANNOTATION",
"query": "description:*",
"metric": "*",
"tags": [],
"limit": 25,
"time": 80,
"results": [
{
"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
}
],
"startIndex": 0,
"totalResults": 1
}