Applications dynamic metrics

Get a list of application dynamic metrics

Description

Get a list of application dynamic metrics

URI

GET /admin-api/applications/http/{app_id}/dymetrics

URI Parameters

  • 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)

Example Request

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/applications/http/{app_id}/dymetrics?page=1&page_size=20&detail=1

Example Response

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
}

Create application dynamic metrics

Description

Create application dynamic metrics

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

Example Request

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{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"}'

Example Response

Status: 200 OK

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

Delete application dynamic metrics

Description

Delete application dynamic metrics

URI

DELETE /admin-api/applications/http/{app_id}/dymetrics/{aggr_id}

Example Request

Shell

curl -X delete \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/applications/http/1/dymetrics/1

Example Response

Status: 200 OK

{"status":0}

Get application dynamic metrics data

Description

Get application dynamic metrics data

URI

GET /admin-api/log_server/dymetrics/list_data

URI Parameters

  • 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

Example Request

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://{admin-site}/admin-api/log_server/dymetrics/list_data?type=app&id=1&start_time=1615883909&end_time=1615884909

Example Response

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