應用動態指標

獲取應用動態指標列表

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"
        ]
    ]
}