# App 动态指标

# 获取应用动态指标列表

# 简介

获取应用动态指标列表

# Uri
GET /admin-api/applications/http/{app_id}/aggrs
# 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}/aggrs?page=1&page_size=20&detail=1

# 响应示例
Status: 200 OK
{
    "status": 0,
    "data": {
        "data": [
            {
                "_created_unix": 1615599380.883,
                "_modified_unix": 1615599380.883,
                "id": 5, // aggr id
                "el": {
                    "description": "request latency",
                    "charts_type": {
                        "hist_linear": {
                            "unit": "s"
                        }
                    },
                    "code": "aggregate $aggr_req_latency :resolution(0.1), :hist-linear(0, 1), :description(\"request latency\"), :unit('s'), :title('req latency');\n\ntrue => $aggr_req_latency <<< req-latency;",
                    "title": "req latency",
                    "var_name": "aggr_req_latency"
                }
            }
        ],
        "meta": {
            "count": 1
        }
    }
}

# 新建应用动态指标

# 简介

使用 edgelang 语言来创建应用动态指标, 这里我们提供一个统计各个节点最大最小和平均上游响应时间的例子

# Uri
POST /admin-api/applications/http/{app_id}/aggrs
# Json body 参数
{
    "el": {
        "code": "aggregate $upstream_response_time :title('upstream response time'), :min, :max, :avg, :unit('ms');true => $upstream_response_time <<< server-addr <<< to-num(upstream-total-response-time) * 1000;"
    }
}
# 请求示例
# Shell
curl \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/applications/http/1/aggrs \
  -d $'{"el":{"code":"aggregate $upstream_response_time :title(\'upstream response time\'), :min, :max, :avg, :unit(\'ms\');true => $upstream_response_time <<< server-addr <<< to-num(upstream-total-response-time) * 1000;"}}'

# 响应示例
Status: 200 OK

{"status":0,"data":{"id":1}}

# 删除应用动态指标

# 简介

删除应用动态指标

# Uri
DELETE /admin-api/applications/http/{app_id}/aggrs/{aggr_id}
# 请求示例
# Shell
curl -X delete \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/applications/http/1/aggrs/1
# 响应示例
Status: 200 OK

{"status":0}