全局动态指标

获取全局动态指标列表

URI

GET /admin-api/global/1/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/global/1/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/global/1/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/global/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/global/1/dymetrics/{aggr_id}

请求示例

Shell

curl -X delete \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/global/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=global&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",
            "/mmmmsturl/adfsaaaa"
        ],
        [
            129,
            52,
            129,
            "test.com",
            "/nwe/adfsaaaa"
        ]
    ]
}