应用动态指标
获取应用动态指标列表
URI
GET /admin-api/applications/http/{app_id}/dymetrics
URI 参数
detail
type: integer
required: no
description: Are detailed results required (default 0)
page
type: integer
required: no
description: Results page (default 1)
page_size
type: integer
required: no
description: Results page size (default 20)
请求示例
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
http://{admin-site}/admin-api/applications/http/{app_id}/dymetrics?page=1&page_size=20&detail=1
响应示例
Status: 200 OK
{
"data": {
"data": [
{
"creator": 1,
"id": 1,
"interval": 60,
"meta": [
{
"group_by": [
{
"name": "host",
"table": "ngx.reqs",
"type": "Str"
},
{
"name": "uri",
"table": "ngx.reqs",
"type": "Str"
}
],
"select": [
{
"name": "host",
"table": "ngx.reqs",
"type": "Str"
},
{
"name": "uri",
"table": "ngx.reqs",
"type": "Str"
},
{
"expr": "count(*)",
"name": "count",
"type": "Int"
},
{
"expr": "avg(req_header_latency_s)",
"name": "avg",
"type": "Int"
},
{
"expr": "avg(req_size)",
"name": "avg",
"type": "Int"
},
{
"expr": "max(req_size)",
"name": "max",
"type": "Int"
}
]
}
],
"name": "metric1",
"sql": "select host, uri, count(*), avg(req_header_latency_s), avg(req_size), max(req_size) from ngx.reqs group by host, uri limit 10"
}
],
"meta": {
"count": 1
}
},
"status": 0
}
新建应用动态指标
URI
POST /admin-api/applications/http/{app_id}/dymetrics
JSON body 参数
{
"name": "metric1",
"interval": 60,
"sql": "select host, uri, count(*), avg(req_header_latency_s), avg(req_size), max(req_size) from ngx.reqs group by host, uri limit 10",
"note": "test"
}
请求示例
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
http://{admin-site}/admin-api/applications/http/1/dymetrics \
-d '{"name":"metric1","interval":60,"sql":"select host, uri, count(*), avg(req_header_latency_s), avg(req_size), max(req_size) from ngx.reqs group by host, uri limit 10","note":"test"}'
响应示例
Status: 200 OK
{"status":0,"data":{"id":1}}
删除应用动态指标
URI
DELETE /admin-api/applications/http/{app_id}/dymetrics/{aggr_id}
请求示例
Shell
curl -X delete \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
http://{admin-site}/admin-api/applications/http/1/dymetrics/1
响应示例
Status: 200 OK
{"status":0}
获取应用指标数据
URI
GET /admin-api/log_server/dymetrics/list_data
URI参数
type
type: string
required: yes
description: dymetrics type(app/global)
chart_type
type: string
required: yes
description: dymetrics chart type(line/bar/pie)
id
type: integer
required: yes
description: dymetrics id
start_time
type: integer
required: no
description: start time for obtaining dymetrics data
end_time
type: integer
required: no
description: end time for obtaining dymetrics data
请求示例
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
http://{admin-site}/admin-api/log_server/dymetrics/list_data?type=app&id=1&start_time=1615883909&end_time=1615884909
响应示例
Status: 200 OK
{
"status": 0,
"data": [
[
"agg_avg_req_size",
"agg_count___star__",
"agg_max_req_size",
"col_ngx__reqs__host",
"col_ngx__reqs__uri"
],
[
135,
78,
135,
"test.com",
"/hello/future"
],
[
129,
52,
129,
"test.com",
"/hello/world"
]
]
}